From 5c7391dcf843aaf007d0c6396f854e76c4e43fe1 Mon Sep 17 00:00:00 2001 From: andsy10 Date: Thu, 11 Jun 2026 01:56:42 +0800 Subject: [PATCH] refactor(segmentation): clean up cns config with use-package --- lisp/init-base.el | 5 ++-- lisp/init-dashboard.el | 3 ++- lisp/init-kbd-func.el | 1 - lisp/init-kbd.el | 6 ++--- lisp/init-org.el | 2 -- lisp/init-segmentation.el | 57 ++++++++++++++++++++------------------- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/lisp/init-base.el b/lisp/init-base.el index f2fe02a..8a6b155 100644 --- a/lisp/init-base.el +++ b/lisp/init-base.el @@ -120,6 +120,9 @@ (mode . eww-bookmark-mode) (mode . eww-buffers-mode) (mode . eww-history-mode))) + ("Calc" (or + (mode . calc-mode) + (mode . calc-trail-mode))) ("Shell" (or (mode . eshell-mode) (mode . eat-mode) @@ -192,8 +195,6 @@ (name . "^*Buffer List*") (name . "\\*discomfort\\*") (mode . calendar-mode) - (mode . calc-mode) - (mode . calc-trail-mode) (mode . grep-mode) (mode . occur-mode)))))) diff --git a/lisp/init-dashboard.el b/lisp/init-dashboard.el index f93c21e..dd6e06d 100644 --- a/lisp/init-dashboard.el +++ b/lisp/init-dashboard.el @@ -6,7 +6,8 @@ (use-package dashboard :autoload dashboard-setup-startup-hook - :init + :hook after-init + :config (setq dashboard-banner-logo-title (format "%s" emacs-version) dashboard-banner-ascii " ##### # # # # ####### # # # ##### ##### \n# # ## # # # # ## ## # # # # # # \n# # # # # # # # # # # # # # # \n# #### # # # # # ##### # # # # # # ##### \n# # # # # # # # # # ####### # # \n# # # ## # # # # # # # # # # # \n ##### # # ##### ####### # # # # ##### ##### " dashboard-startup-banner 'ascii diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el index 8f404c7..eb6b4c5 100644 --- a/lisp/init-kbd-func.el +++ b/lisp/init-kbd-func.el @@ -117,7 +117,6 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog "~/org/hugo/this-is-my-blog/"))) (timestamp (format-time-string "%Y-%m-%d %H:%M:%S")) (default-directory blog-dir)) - (save-buffer) (message "Adding files...") (eshell-command "git add .") (message "Committing: %s" timestamp) diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el index af754a7..80838b5 100644 --- a/lisp/init-kbd.el +++ b/lisp/init-kbd.el @@ -229,7 +229,8 @@ ;; org-mode (general-def org-mode-map "C-" 'org-cycle-parent-subtree - "C-c i" 'consult-outline + "M-g i" 'consult-outline + "M-g M-i" 'consult-outline "C-c t l" 'org-toggle-link-display "M-{" 'org-previous-visible-heading "M-}" 'org-next-visible-heading @@ -306,8 +307,6 @@ "r" 'restart-emacs "e" 'er/expand-region "s" 'consult-line - "i" 'consult-imenu - "I" 'consult-imenu-multi "a" 'org-agenda "l" 'org-store-link "k" 'comment-line @@ -368,6 +367,7 @@ "M-g g" 'avy-goto-line "M-g M-g" 'consult-goto-line "M-g i" 'consult-imenu + "M-g I" 'consult-imenu-multi "M-g M-i" 'consult-imenu ;; window diff --git a/lisp/init-org.el b/lisp/init-org.el index d9b2ec6..adcab3f 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -13,8 +13,6 @@ (org-mode . electric-pair-local-mode) :config - (require 'org-tempo) - (defun my-org-electric-pair-fix () (setq-local electric-pair-inhibit-predicate (lambda (char) diff --git a/lisp/init-segmentation.el b/lisp/init-segmentation.el index 5eef998..c5345d9 100644 --- a/lisp/init-segmentation.el +++ b/lisp/init-segmentation.el @@ -5,37 +5,38 @@ ;;; Code: ;; emacs-chinese-word-segmentation -(cond - (*is-windows* - (add-to-list 'load-path "h:/emacs/emacs-chinese-word-segmentation/") ;设置为进程调用方式 - (setq cns-process-type 'shell) ;设置可执行文件路径 - (setq cns-prog "h:/emacs/emacs-chinese-word-segmentation/cnws.exe") ;设置字典目录 - (setq cns-dict-directory "h:/emacs/emacs-chinese-word-segmentation/cppjieba/dict") ;直接设置进程命令,绕过 Windows shell 检测 - (setq cns-process-shell-command - (format "%s %s %s %s %s %s" - cns-prog - (concat (file-name-as-directory cns-dict-directory) "jieba.dict.utf8") - (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")))) +(use-package cns + :straight nil + :hook + (after-init . require-cns) + (after-init . global-cns-mode) + :init + (cond + (*is-windows* + (add-to-list 'load-path "h:/emacs/emacs-chinese-word-segmentation/") ;设置为进程调用方式 + (setq cns-process-type 'shell) ;设置可执行文件路径 + (setq cns-prog "h:/emacs/emacs-chinese-word-segmentation/cnws.exe") ;设置字典目录 + (setq cns-dict-directory "h:/emacs/emacs-chinese-word-segmentation/cppjieba/dict") ;直接设置进程命令,绕过 Windows shell 检测 + (setq cns-process-shell-command + (format "%s %s %s %s %s %s" + cns-prog + (concat (file-name-as-directory cns-dict-directory) "jieba.dict.utf8") + (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")))) - (t - (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/"))) + (t + (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) + :config + (defun require-cns () + (require 'cns nil t)) -;; 自动启动 -(when (featurep 'cns) - (add-hook 'after-init-hook 'global-cns-mode)) - -;; 取消C-绑定 -(with-eval-after-load 'cns + (setq cns-recent-segmentation-limit 40) (define-key cns-mode-map (kbd "C-") nil)) (provide 'init-segmentation)