config: add macOS support with cross-platform compatibility
- Add platform-specific keybindings, paths, and settings for macOS - Update org-mode templates and agenda files for both Windows and Mac - Add vterm and lua-ts-mode packages (non-Windows) - Configure Chinese segmentation for macOS - Adjust font sizes and encoding settings per platform
This commit is contained in:
@@ -104,8 +104,10 @@
|
||||
;; 中键使用embark打开定义
|
||||
(global-set-key (kbd "<mouse-2>") 'xref-find-definitions)
|
||||
|
||||
;; 使用C-c <delete>切换到scrath buffer
|
||||
(global-set-key (kbd "C-c <delete>") 'scratch-buffer)
|
||||
;; 使用快速切换到scrath buffer
|
||||
(if *is-mac*
|
||||
(global-set-key (kbd "C-C <f12>") 'scratch-buffer)
|
||||
(global-set-key (kbd "C-c <delete>") 'scratch-buffer))
|
||||
|
||||
;; 调整window
|
||||
(global-set-key (kbd "<f5>") 'shrink-window-horizontally)
|
||||
|
||||
@@ -37,12 +37,19 @@
|
||||
(setq system-time-locale "C")
|
||||
|
||||
;; capture模板
|
||||
(setq org-capture-templates
|
||||
'(("t" "Todo" entry (file+headline "d:/emacs/org/todos.org" "Workspace")
|
||||
"* TODO [#B] %?\n %i\n %U"
|
||||
:empty-lines 1)
|
||||
("j" "Journal" entry (file+datetree "d:/emacs/org/journal.org")
|
||||
"* %?\nEntered on %U\n %i\n")))
|
||||
(when *is-windows*
|
||||
(setq org-capture-templates
|
||||
'(("t" "Todo" entry (file+headline "d:/emacs/org/todos.org" "Workspace")
|
||||
"* TODO [#B] %?\n %i\n %U"
|
||||
:empty-lines 1)
|
||||
("j" "Journal" entry (file+datetree "d:/emacs/org/journal.org")
|
||||
"* %?\nEntered on %U\n %i\n"))))
|
||||
|
||||
(when *is-mac*
|
||||
(setq org-capture-templates
|
||||
'(("t" "Todo" entry (file+headline "~/org/some-orgs/todos.org" "Workspace")
|
||||
"* TODO [#B] %?\n %i\n %U"
|
||||
:empty-lines 1))))
|
||||
|
||||
(global-set-key (kbd "C-c o c") 'org-capture)
|
||||
|
||||
@@ -63,12 +70,17 @@
|
||||
|
||||
;; agenda相关
|
||||
(global-set-key (kbd "C-c a") 'org-agenda)
|
||||
(with-eval-after-load 'org
|
||||
|
||||
(when *is-windows*
|
||||
(with-eval-after-load 'org
|
||||
(setq org-agenda-files '("d:/emacs/org/learning-org-mode.org"
|
||||
"d:/emacs/hugo/this-is-my-blog/all-blog.org"
|
||||
"d:/emacs/my-org-daily/"))) ; agenda文件,目录或文件
|
||||
(setq org-agenda-span 'day)
|
||||
"d:/emacs/my-org-daily/")))) ; agenda文件,目录或文件
|
||||
(when *is-mac*
|
||||
(with-eval-after-load 'org
|
||||
(setq org-agenda-files '("~/org/my-org-daily"))))
|
||||
|
||||
(setq org-agenda-span 'day)
|
||||
|
||||
;; hugo
|
||||
(with-eval-after-load 'org-capture
|
||||
@@ -150,8 +162,7 @@ See `org-capture-templates' for more information."
|
||||
;; org-journal
|
||||
(use-package org-journal
|
||||
:config
|
||||
(setq org-journal-dir "D:/emacs/my-org-daily/"
|
||||
org-journal-file-format "%Y-%m-%d.org"
|
||||
(setq org-journal-file-format "%Y-%m-%d.org"
|
||||
org-journal-file-header "#+title: Daily Journal\n#+category: journal\n\n"
|
||||
org-journal-time-format "%R \n:PROPERTIES:\n:Created: <%Y-%m-%d %a %H:%M:%S>\n:END:\n"
|
||||
org-journal-time-prefix "\n*** TODO "
|
||||
@@ -162,6 +173,14 @@ See `org-capture-templates' for more information."
|
||||
(format-time-string "%a" time)
|
||||
(format-time-string "%Y-%m-%d %a" time))))
|
||||
|
||||
(when *is-windows*
|
||||
(setq org-journal-dir "D:/emacs/my-org-daily/"))
|
||||
|
||||
(when *is-mac*
|
||||
(setq org-journal-dir "~/org/my-org-daily/"))
|
||||
|
||||
(add-hook 'org-journal-mode-hook 'font-lock-update)
|
||||
|
||||
(defun my/journal-setup-new-day ()
|
||||
(save-excursion
|
||||
(org-back-to-heading)
|
||||
@@ -192,7 +211,21 @@ See `org-capture-templates' for more information."
|
||||
(funcall org-journal-find-file org-journal-file)
|
||||
(unless (org-journal--daily-p)
|
||||
(org-journal--goto-entry date)))
|
||||
(message "No journal entry for this date.")))))
|
||||
(message "No journal entry for this date."))))
|
||||
|
||||
(defun my/org-journal-mark-old-todos-as-comment (entries)
|
||||
"Change of TODO entry's TODO key word to COMMENT after carryover."
|
||||
(save-excursion
|
||||
(mapc (lambda (entry)
|
||||
(let ((start (car entry))
|
||||
(end (cadr entry)))
|
||||
(goto-char start)
|
||||
(when (re-search-forward "^\\(\\*+ \\)TODO\\>" end t)
|
||||
(replace-match "\\1COMMENT" t nil))))
|
||||
(reverse entries)))
|
||||
(save-buffer))
|
||||
|
||||
(setq org-journal-handle-old-carryover-fn #'my/org-journal-mark-old-todos-as-comment))
|
||||
|
||||
;; 在org-journal加载cns-mode
|
||||
(add-hook 'org-journal-mode-hook
|
||||
|
||||
@@ -67,9 +67,14 @@
|
||||
|
||||
(define-key minibuffer-local-map (kbd "C-c C-e") 'embark-export)
|
||||
|
||||
(progn
|
||||
(setq consult-locate-args (encode-coding-string "es.exe -i -p -r" 'gbk))
|
||||
(add-to-list 'process-coding-system-alist '("es" gbk . gbk)))
|
||||
(if *is-windows*
|
||||
(progn
|
||||
(setq consult-locate-args (encode-coding-string "es.exe -i -p -r" 'gbk))
|
||||
(add-to-list 'process-coding-system-alist '("es" gbk . gbk))))
|
||||
|
||||
(when *is-mac*
|
||||
(setopt consult-locate-args "mdfind -name"))
|
||||
|
||||
|
||||
;; 启用savehist,保存命令顺序
|
||||
(use-package savehist
|
||||
@@ -99,7 +104,8 @@
|
||||
(use-package emms
|
||||
:init
|
||||
;; 设置音乐文件默认目录
|
||||
(setq emms-source-file-default-directory "F:/luping26-1-11/")
|
||||
(when *is-windows*
|
||||
(setq emms-source-file-default-directory "F:/luping26-1-11/"))
|
||||
|
||||
:config
|
||||
;; --- 基础设置 ---
|
||||
@@ -247,4 +253,17 @@
|
||||
(emms-play-directory-tree dir)
|
||||
(message "playing: %s" dir))
|
||||
|
||||
;; vterm
|
||||
(unless *is-windows*
|
||||
(use-package vterm))
|
||||
|
||||
;; lua
|
||||
(use-package lua-ts-mode
|
||||
:mode ("\\.lua\\'" . lua-ts-mode)
|
||||
:config
|
||||
(add-to-list 'treesit-language-source-alist
|
||||
'(lua "https://github.com/tree-sitter-grammars/tree-sitter-lua"))
|
||||
(add-to-list 'auto-mode-alist '("\\.lua\\'" . lua-ts-mode))
|
||||
(treesit-install-language-grammar 'lua))
|
||||
|
||||
(provide 'init-package)
|
||||
|
||||
@@ -18,15 +18,25 @@
|
||||
(concat (file-name-as-directory cns-dict-directory) "hmm_model.utf8")
|
||||
(concat (file-name-as-directory cns-dict-directory) "user.dict.utf8")
|
||||
(concat (file-name-as-directory cns-dict-directory) "idf.utf8")
|
||||
(concat (file-name-as-directory cns-dict-directory) "stop_words.utf8")))
|
||||
(concat (file-name-as-directory cns-dict-directory) "stop_words.utf8"))))
|
||||
|
||||
(when *is-mac*
|
||||
(add-to-list 'load-path "~/emacs-stuff/emacs-chinese-word-segmentation/")
|
||||
;; 设置为进程调用方式
|
||||
(setq cns-process-type 'shell)
|
||||
;; 设置可执行文件路径
|
||||
(setq cns-prog "~/emacs-stuff/emacs-chinese-word-segmentation/cnws")
|
||||
;; 设置字典目录
|
||||
(setq cns-dict-directory "~/emacs-stuff/emacs-chinese-word-segmentation/cppjieba/dict/"))
|
||||
|
||||
;; 其他配置
|
||||
(setq cns-recent-segmentation-limit 40)
|
||||
(require 'cns nil t)
|
||||
;; 自动启动
|
||||
(when (featurep 'cns)
|
||||
(add-hook 'find-file-hook 'cns-auto-enable))
|
||||
(add-hook 'find-file-hook 'global-cns-mode))
|
||||
;; 取消C-<backspace>绑定
|
||||
(with-eval-after-load 'cns
|
||||
(define-key cns-mode-map (kbd "C-<backspace>") nil)))
|
||||
(define-key cns-mode-map (kbd "C-<backspace>") nil))
|
||||
|
||||
(provide 'init-segmentation)
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
;;; init-startup.el
|
||||
;;; -*- lexical-binding: t -*-
|
||||
|
||||
;; mac自动全屏
|
||||
(when *is-mac*
|
||||
(toggle-frame-fullscreen)
|
||||
(global-unset-key (kbd "<f12>"))
|
||||
(global-set-key (kbd "<f12>") 'toggle-frame-fullscreen))
|
||||
|
||||
;; 配置备份文件和自动保存文件目录
|
||||
(setq backup-directory-alist
|
||||
`((".*" . ,(expand-file-name "backup/" user-emacs-directory)))
|
||||
@@ -13,6 +19,9 @@
|
||||
(setq auto-save-file-name-transforms
|
||||
`((".*" ,(expand-file-name "auto-save-list/" user-emacs-directory) t)))
|
||||
|
||||
;; 开启水平滚动
|
||||
(put 'scroll-left 'disabled nil)
|
||||
|
||||
;; 关闭lock文件
|
||||
(setq create-lockfiles nil)
|
||||
|
||||
@@ -24,6 +33,11 @@
|
||||
(add-to-list 'exec-path (expand-file-name "H/appppppppppp/scoop/apps/"))
|
||||
(setenv "PATH" (concat (expand-file-name "H/appppppppppp/scoop/apps/") ";" (getenv "PATH"))))
|
||||
|
||||
;; 同步brew目录
|
||||
(when *is-mac*
|
||||
(add-to-list 'exec-path (expand-file-name "/opt/homebrew/bin/"))
|
||||
(setenv "PATH" (concat (expand-file-name "/opt/homebrew/bin/") ":" (getenv "PATH"))))
|
||||
|
||||
;; 当文件被外部修改时自动刷新
|
||||
(global-auto-revert-mode 1)
|
||||
|
||||
@@ -42,6 +56,7 @@
|
||||
";; SCRATCH SCRATCH SCRATCH\n\n")
|
||||
|
||||
;; 开启server mode
|
||||
(server-start)
|
||||
(unless *is-mac*
|
||||
(server-start))
|
||||
|
||||
(provide 'init-startup)
|
||||
|
||||
@@ -5,8 +5,13 @@
|
||||
(when (fboundp 'set-charset-priority)
|
||||
(set-charset-priority 'unicode))
|
||||
|
||||
(set-language-environment 'chinese-gbk)
|
||||
(prefer-coding-system 'utf-8-auto)
|
||||
(if *is-windows*
|
||||
(progn
|
||||
(set-language-environment 'chinese-gbk)
|
||||
(prefer-coding-system 'utf-8-auto))
|
||||
(progn
|
||||
(set-language-environment "UTF-8")
|
||||
(prefer-coding-system 'utf-8)))
|
||||
|
||||
;; 安装solarized dark
|
||||
(use-package solarized-theme)
|
||||
@@ -61,10 +66,17 @@
|
||||
(throw 'found font)))))
|
||||
|
||||
;; 设置字体大小和字重变量
|
||||
(defvar tenon-font-size 125
|
||||
"默认字体大小")
|
||||
(defvar tenon-font-weight 'light
|
||||
"默认字重,选项有ultra-light,light,normal,medium,semibold,bold")
|
||||
(when *is-windows*
|
||||
(defvar tenon-font-size 125
|
||||
"默认字体大小")
|
||||
(defvar tenon-font-weight 'light
|
||||
"默认字重,选项有ultra-light,light,normal,medium,semibold,bold"))
|
||||
|
||||
(when *is-mac*
|
||||
(defvar tenon-font-size 160
|
||||
"默认字体大小")
|
||||
(defvar tenon-font-weight 'light
|
||||
"默认字重,选项有ultra-light,light,normal,medium,semibold,bold"))
|
||||
|
||||
;; 定义函数
|
||||
;;;###autoload
|
||||
|
||||
Reference in New Issue
Block a user