commit 9cf8e08e223f34678ce76826f142cfccc2921d2a
parent 4dde3f27d103f662703732f477bcec7c9ec3f8f1
Author: andsy10 <andsy1016@gmail.com>
Date: Tue, 20 Oct 2026 23:46:30 +0800
Optimize configuration and update keybindings
Diffstat:
9 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/lisp/init-dired.el b/lisp/init-dired.el
@@ -27,15 +27,17 @@
;; dirvish
(my-use-package dirvish
+ :hook
+ (dired-load . dirvish-override-dired-mode)
:init
- (dirvish-override-dired-mode)
(defun my-dirvish-layout-toggle ()
"Toggle layout using the first recipe in `dirvish-layout-recipes' instead of
the hardcoded fallback recipe."
(interactive)
(let ((dv (or (dirvish-curr) (user-error "Not a dirvish buffer"))))
(unless (dv-curr-layout dv)
- (setf (dv-ff-layout dv) (car dirvish-layout-recipes)))
+ (aset dv (cl-struct-slot-offset 'dirvish 'ff-layout)
+ (car dirvish-layout-recipes)))
(dirvish-layout-toggle)))
:config
diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el
@@ -90,7 +90,8 @@ With prefix ARG, report for the entire buffer rather than the region."
(defun my-bounds-of-next-thing (thing)
"Return the bounds of THING at or after point."
(or (bounds-of-thing-at-point thing)
- (save-excursion (ignore-errors (forward-thing thing 1))
+ (save-excursion (ignore-errors (forward-thing thing 1)
+ (forward-thing thing -1))
(bounds-of-thing-at-point thing))))
(defun my-bounds-of-symbol-at-point-or-next-sexp ()
@@ -121,8 +122,8 @@ With prefix ARG, report for the entire buffer rather than the region."
(unless (and allow-extend
(or (and (eq last-command this-command) (mark t))
(region-active-p)))
- (when-let* ((pos (car (my-bounds-of-next-thing 'word))))
- (goto-char pos))))
+ (when-let* ((beg (car (my-bounds-of-next-thing 'word))))
+ (goto-char beg))))
(advice-add #'mark-word :before #'my-mark-word-hack)
;; from Bozhidar Batsov's crux
@@ -165,7 +166,7 @@ there's a region, all lines that region covers will be duplicated."
(defun my-eshell-input-from-history ()
"Insert command from eshell input history."
(interactive)
- (let ((history (append (cddr eshell-history-ring) nil)))
+ (let ((history (ring-elements eshell-history-ring)))
(insert
(completing-read
"Insert input from history: "
diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el
@@ -171,11 +171,11 @@
;; elisp
(general-def (emacs-lisp-mode-map lisp-interaction-mode-map)
- "C-c C-l l" #'my-elisp-load-this-file
- "C-c C-l j" #'my-elisp-eval-and-print-last-sexp
- "C-c C-l p" #'my-elisp-pp-macroexpand-last-sexp
- "C-c C-l e" #'pp-eval-last-sexp
- "C-c C-l h" #'my-elisp-headerise
+ "C-c C-l C-l" #'my-elisp-load-this-file
+ "C-c C-l C-j" #'my-elisp-eval-and-print-last-sexp
+ "C-c C-l C-p" #'my-elisp-pp-macroexpand-last-sexp
+ "C-c C-l C-e" #'pp-eval-last-sexp
+ "C-c C-l C-h" #'my-elisp-headerise
"C-c C-z" #'my-switch-to-ielm)
(general-def lisp-interaction-mode-map
"C-j" #'my-elisp-eval-and-print-last-sexp)
@@ -252,8 +252,8 @@
"C-c C-<f12>" #'my-persp-scratch-buffer
"z" #'avy-goto-char
"'" #'avy-goto-word-1
- "<f1>" #'eldoc-mouse-pop-doc-at-cursor
- "<f2>" #'my-open-init-file)
+ "<f1>" nil "<f2>" nil "<f3>" nil "<f4>" nil "<f5>" nil "<f6>" nil
+ "<f7>" nil "<f8>" nil "<f9>" nil "<f10>" nil "<f11>" nil "<f12>" nil)
;; gptel
(general-def gptel-mode-map
@@ -576,7 +576,9 @@
"s-SPC" #'xdg-launcher-run-app))
(when *is-emacs-mac-port*
- (general-def "<f12>" #'mac-toggle-frame-fullscreen))
+ (general-def
+ "M-<f11>" #'mac-toggle-frame-fullscreen
+ "<f12>" #'mac-toggle-frame-fullscreen))
(provide 'init-kbd)
;;; init-kbd.el ends here
diff --git a/lisp/init-org.el b/lisp/init-org.el
@@ -123,11 +123,14 @@
(defvar denote-excluded-files-regexp)
(defvar denote-journal-signature)
(defvar denote-file-prompt-extra-metadata)
+
(defun my-denote-find-file (&optional arg)
"Find file use denote-open-or-create."
(interactive "P")
(let ((denote-excluded-files-regexp
- (unless arg (concat denote-excluded-files-regexp "\\|==" denote-journal-signature))))
+ (unless arg (concat denote-excluded-files-regexp "\\|=="
+ denote-journal-signature
+ "\\|\\(png\\|jpe?g\\|svg\\|gif\\|webp\\|bpm\\|ppm\\|mp[34]\\|mov\\|avi\\|obj\\)$"))))
(call-interactively #'denote-open-or-create)))
(defun my-denote-find-backlink-with-location ()
@@ -251,6 +254,7 @@
;; extra tools for org
(my-use-package denote-org
+ :autoload denote-org--get-file-id-and-heading-id-or-context
:init
(defun my-denote-org-find-backlink-for-heading-with-location ()
"Like `denote-org-backlinks-for-heading' but with consult preview."
diff --git a/lisp/init-package.el b/lisp/init-package.el
@@ -60,7 +60,7 @@
(my-use-package eglot-ltex
(equal my-grammar-checker-backend 'languagetool)
:straight
- (eglot-letx :type git :host github :repo "emacs-languagetool/eglot-ltex")
+ (eglot-ltex :type git :host github :repo "emacs-languagetool/eglot-ltex")
:hook
(text-mode . (lambda () (require 'eglot-ltex)))
:init
diff --git a/lisp/init-prog.el b/lisp/init-prog.el
@@ -23,10 +23,7 @@
:autoload xref-show-definitions-completing-read
:init
(when (executable-find "rg")
- (setq xref-search-program 'ripgrep))
-
- (setq xref-show-definitions-function #'xref-show-definitions-completing-read
- xref-show-xrefs-function #'xref-show-definitions-completing-read))
+ (setq xref-search-program 'ripgrep)))
;; eldoc-mouse
(my-use-package eldoc-mouse
diff --git a/lisp/init-segmentation.el b/lisp/init-segmentation.el
@@ -9,7 +9,7 @@
(cns :type git
:host github
:repo "kanglmf/emacs-chinese-word-segmentation")
- :demand t
+ :autoload cns-start-process
:hook
(after-init . my-global-cns-boundary-mode)
:init
@@ -33,6 +33,7 @@
;; word segmentation via `find-word-boundary-function-table'
;; NOT compatible with any other modes that use this char table
+ (defvar cns-process nil)
(defconst my-cns-boundary-table
(let ((tab (make-char-table nil)))
(map-char-table
diff --git a/lisp/my-dark-theme.el b/lisp/my-dark-theme.el
@@ -27,7 +27,8 @@
`(font-lock-keyword-face ((,class (:foreground ,cyan :weight bold))))
`(elisp-shorthand-font-lock-face ((,class (:foreground ,yellow :weight bold))))
`(mode-line ((,class (:foreground ,base0 :background ,base02))))
- `(mode-line-inactive ((,class (:foreground ,base01 :background ,base03)))))))
+ `(mode-line-inactive ((,class (:foreground ,base01 :background ,base03))))
+ `(mode-line-highlight ((,class (:background ,green-d :box ,base0)))))))
(solarized-with-color-variables-with-palette
'dark
diff --git a/lisp/my-light-theme.el b/lisp/my-light-theme.el
@@ -35,6 +35,7 @@
`(region ((,class (:background ,my-light-yellow-l :extend nil))))
`(mode-line ((,class (:foreground ,base0 :background ,my-light-blue-l :box t))))
`(mode-line-inactive ((,class (:background ,base03 :box t))))
+ `(mode-line-highlight ((,class (:background ,my-light-yellow-l :box ,base0))))
`(org-verbatim ((,class (:foreground ,yellow))))
`(org-code ((,class (:foreground ,yellow)))))))