commit 141e2b42bc71dfffac2a7d854c455601de3c5631
parent 7686a417076d70a33652e41c0fd1913f2d13a5d6
Author: andsy10 <andsy1016@gmail.com>
Date: Tue, 20 Oct 2026 10:44:07 +0800
Optimize cns configuration
Diffstat:
3 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/lisp/init-custom.el b/lisp/init-custom.el
@@ -70,11 +70,6 @@ I need to use `org-directory' before org is loaded."
(const :tag "Fullscreen" fullscreen))
:group 'trogloxene)
-(defcustom my-cns-dir "nil"
- "Directory for cns."
- :type 'directory
- :group 'trogloxene)
-
(defcustom my-proxy "127.0.0.1:7890"
"Proxy."
:type 'string
diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el
@@ -146,6 +146,16 @@ there's a region, all lines that region covers will be duplicated."
(skip-syntax-forward " " (line-end-position))
(backward-prefix-chars))
+(defun my-straight-package-dir (package)
+ "Return the source directory of PACKAGE if it exist.
+PACKAGE is a string."
+ (when-let* ((recipe
+ (ignore-errors
+ (or (gethash package straight--recipe-cache)
+ (straight--convert-recipe (intern package)))))
+ (local-repo (plist-get recipe :local-repo)))
+ (straight--repos-dir local-repo)))
+
(defun my-straight-packages-count ()
"Count how many straight.el package are currently installed."
(interactive)
diff --git a/lisp/init-segmentation.el b/lisp/init-segmentation.el
@@ -4,14 +4,20 @@
;;; Code:
-;; github@kanglmf/emacs-chinese-word-segmentation
-(my-use-package cns (file-exists-p my-cns-dir)
- :straight nil
+(my-use-package cns
+ :straight
+ (cns :type git
+ :host github
+ :repo "kanglmf/emacs-chinese-word-segmentation")
:demand t
:hook
(after-init . my-global-cns-boundary-mode)
:init
- (add-to-list 'load-path my-cns-dir)
+ (defvar my-cns-dir (my-straight-package-dir "cns"))
+ (defun my-compile-cns ()
+ (interactive)
+ (let ((default-directory my-cns-dir))
+ (compile "make")))
(setq cns-prog (expand-file-name (if *is-windows* "cnws.exe" "cnws") my-cns-dir)
cns-dict-directory (expand-file-name "cppjieba/dict" my-cns-dir)
cns-recent-segmentation-limit 40