commit 94fdcfee37c7b2a11097c4f1b4e02b3deafe3ad4
parent 44bbde278ac4261b0420a01aee424e55609e4c2b
Author: andsy10 <andsy1016@gmail.com>
Date: Fri, 9 Oct 2026 16:47:26 +0800
Optimize configurations
Diffstat:
13 files changed, 80 insertions(+), 47 deletions(-)
diff --git a/lisp/init-base.el b/lisp/init-base.el
@@ -57,7 +57,8 @@
(lambda (file) (file-in-directory-p file package-user-dir))))
:config
(add-to-list 'recentf-exclude "~/.emacs.d/bookmarks")
- (add-to-list 'recentf-exclude "~/hywiki/.hywiki.eld"))
+ (add-to-list 'recentf-exclude "~/hywiki/.hywiki.eld")
+ (add-to-list 'recentf-exclude (abbreviate-file-name (straight--build-dir))))
;; save minibuffer history
(my-use-package savehist
@@ -96,6 +97,7 @@
(my-use-package which-key
:straight nil
:delight
+ :commands which-key-enable-god-mode-support
:hook
(after-init . which-key-mode))
diff --git a/lisp/init-completion.el b/lisp/init-completion.el
@@ -234,8 +234,7 @@ targets."
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-nonexclusive)
(defun my-org-completion-setup ()
- (add-hook 'completion-at-point-functions #'cape-file nil t)
- (add-hook 'completion-at-point-functions #'cape-elisp-symbol nil t))
+ nil)
(add-hook 'org-mode-hook #'my-org-completion-setup)
(defun my-minibuffer-completion-setup ()
diff --git a/lisp/init-dashboard.el b/lisp/init-dashboard.el
@@ -4,7 +4,7 @@
;;; Code:
-(use-package dashboard
+(my-use-package dashboard
:autoload dashboard-setup-startup-hook
:hook after-init
:config
diff --git a/lisp/init-edit.el b/lisp/init-edit.el
@@ -49,7 +49,7 @@
;; kmacro enhancement (and multiple cursors)
(my-use-package kmacro-x
:straight
- (kmacro-x :fork (:type git :repo "https://git.trogloxene.org/kmacro-x.git"))
+ (kmacro-x :fork (:type git :host nil :repo "https://git.trogloxene.org/kmacro-x.git"))
:delight
(kmacro-x-atomic-undo-mode nil)
:hook
@@ -85,8 +85,8 @@
(my-use-package god-mode
:init
(if *is-android* (add-hook 'after-init-hook 'god-mode-all))
+ (add-hook 'after-init-hook #'which-key-enable-god-mode-support)
:config
- (unless (or *is-android* (not use-package-always-defer)) (which-key-enable-god-mode-support))
(setq god-mode-enable-function-key-translation nil
god-exempt-major-modes
(cl-union '(diff-mode exwm-mode) god-exempt-major-modes :test 'equal)
diff --git a/lisp/init-elpa.el b/lisp/init-elpa.el
@@ -75,7 +75,7 @@ otherwise the macro expands to a plain `use-package' declaration."
(if (not condition-p)
`(use-package ,name ,@args)
`(progn
- ,@(when recipe `((straight-register-package ,recipe)))
+ ,@(when recipe `((straight-register-package ,recipe))) ;comment this line if you don't want to register unused packages
(when ,condition
(use-package ,name ,@args)))))))
diff --git a/lisp/init-gptel.el b/lisp/init-gptel.el
@@ -110,9 +110,7 @@ explanations, no quotes, no punctuation, no file extension."
(error (message "gptel save-session error: %S" err)))))))
(unless (plist-get (gptel-fsm-info fsm) :callback)
(message "WARNING: gptel-request did not register callback!")))))
-
- (with-eval-after-load 'gptel
- (define-key gptel-mode-map (kbd "C-c C-s") #'my-gptel-save-session)))
+ (keymap-set gptel-mode-map "C-c C-s" #'my-gptel-save-session))
(my-use-package gptel-agent
:after gptel
diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el
@@ -4,11 +4,17 @@
;;; Code:
-(defun open-init-file ()
+(defun my-open-init-file ()
"Open user's init.el file."
(interactive)
(find-file user-init-file))
+(defun my-open-custom-file ()
+ "Open user's `custom-file'."
+ (interactive)
+ (or (find-file custom-file)
+ (user-error "No custom file")))
+
;; from Bozhidar Batsov's crux
(defun my-kill-line-backwards ()
"Kill line backwards and adjust the indentation."
@@ -44,7 +50,7 @@ there's a region, all lines that region covers will be duplicated."
(goto-char (+ origin (* (length region) arg) arg))))
(defun enable-truncate-lines ()
- (toggle-truncate-lines 1))
+ (setq truncate-lines t))
(defun query-replace-case-sensitive ()
"Case-sensitive `query-replace'."
@@ -125,7 +131,7 @@ there's a region, all lines that region covers will be duplicated."
(org-table-map-tables 'org-table-align t))
(defun org-align-description-list ()
- "Adjust all `::' in active region. "
+ "Adjust all `::' in active region."
(interactive)
(align-regexp (region-beginning) (region-end) "\\(\\s-*\\)::" 1 1 nil))
diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el
@@ -11,7 +11,7 @@
"M-i" #'god-mode-all
;; buffer, file, and window
- "<f2>" #'open-init-file
+ "<f2>" #'my-open-init-file
"<mouse-4>" #'previous-buffer
"<mouse-5>" #'next-buffer
"M-[" #'previous-buffer
@@ -25,6 +25,7 @@
"C-x C-0" #'delete-window
;; edit
+ "M-j" #'join-line
"M-c" #'capitalize-dwim
"M-u" #'upcase-dwim
"M-l" #'downcase-dwim
@@ -119,7 +120,7 @@
"C-/" #'dired-undo
"<SPC>" #'my-dirvish-layout-toggle
"C-c C-r" #'dired-rsync
- "e" #'ediff)
+ "=" #'ediff)
(general-def (dired-mode-map dirvish-mode-map)
:prefix "C-c d"
"u" #'dirvish-setup-menu
@@ -200,7 +201,7 @@
"C-c C-<f12>" #'my-persp-scratch-buffer
"z" #'avy-goto-char
"'" #'avy-goto-word-1
- "<f2>" #'open-init-file)
+ "<f2>" #'my-open-init-file)
;; gptel
(general-def gptel-mode-map
@@ -345,7 +346,7 @@
"G" #'consult-git-grep
"e" #'consult-flycheck
"l" #'consult-locate
- "h" #'consult-fd-home
+ "h" #'my-consult-fd-home
"m" #'consult-man
"d" #'my-open-current-directory
"J" #'consult-register
@@ -354,7 +355,9 @@
"o" #'consult-outline
"i" #'consult-info
"s" #'consult-focus-lines
- "t" #'consult-ghostel)
+ "t" #'consult-ghostel
+ "a" #'hsys-consult-apropos
+ "L" #'find-library)
;; g for gptel
(general-def
@@ -471,14 +474,14 @@
:prefix "C-c x"
"e" #'eshell
"t" #'ghostel
+ "s" #'shell
"p" #'proced
"b" #'benchmark-init/show-durations-tree
"B" #'benchmark-init/show-durations-tabulated
- "S" #'syncthing
"f" #'elfeed
"k" #'pass
"g" #'gt-translate
- "s" #'my-synosaurus-lookup)
+ "w" #'my-synosaurus-lookup)
;;; other
diff --git a/lisp/init-org.el b/lisp/init-org.el
@@ -159,7 +159,7 @@
(with-eval-after-load 'savehist
(add-to-list 'savehist-ignored-variables 'denote-title-history)))
-;; denote-org
+;; extra tools for org
(my-use-package denote-org
:commands my-denote-org-find-backlink-for-heading-with-location
:config
@@ -172,7 +172,7 @@
(fetcher (lambda () (xref-matches-in-files heading-id files))))
(consult-xref fetcher nil))))
-;; denote-lint
+;; detect broken links
(my-use-package denote-lint
:straight
(denote-lint :type git
@@ -186,11 +186,11 @@
(calendar-mode . denote-journal-calendar-mode)
:commands my-denote-journal-open-entry my-denote-journal-find-file
:config
- (defun my-denote-journal-path-to-existing-entry (&optional date interval)
+ (defun my-denote-journal-path-to-existing-entry ()
"Return the path of current denote journal if it exists, otherwise return nil."
(let* ((internal-date
- (denote-journal--date-in-interval-p (or date (current-time)) interval))
- (files (denote-journal--get-entry internal-date interval)))
+ (denote-journal--date-in-interval-p (current-time) t))
+ (files (denote-journal--get-entry internal-date t)))
(if files
(denote-journal-select-file-prompt files))))
@@ -224,20 +224,35 @@
(setq denote-journal-signature "journal")
(setq denote-journal-keyword "daily"))
-;; denote-explore
+;; explore, maintain and visualise denote files
(my-use-package denote-explore
:commands my-denote-explore-isolate-files-dired
- :init
- (setq denote-explore-isolated-ignore-keywords '("daily"))
:config
+ (setq denote-explore-isolated-ignore-keywords '("daily"))
+ (require 'ansi-color)
+ (setq chart-face-color-list (list (face-foreground 'ansi-color-blue)
+ (face-foreground 'ansi-color-cyan)
+ (face-foreground 'ansi-color-green)
+ (face-foreground 'ansi-color-yellow)
+ (face-foreground 'ansi-color-red)
+ (face-foreground 'ansi-color-magenta)))
+
(defun my-denote-explore-isolate-files-dired ()
"Identify Denote files without (back)links."
(interactive)
(dired (cons "notes"
(mapcar (lambda (file) (car file))
- (denote-explore--idenitfy-isolated))))))
+ (denote-explore--idenitfy-isolated)))))
+
+ (defun my-denote-explore-network-with-excluded-regexp (fun &rest text-only)
+ (let* ((regexp (read-from-minibuffer "Excluded regexp: "))
+ (denote-excluded-files-regexp
+ (concat denote-excluded-files-regexp
+ (if (string-empty-p regexp) nil (concat "\\|" regexp)))))
+ (apply fun text-only)))
+ (advice-add #'denote-explore-network :around #'my-denote-explore-network-with-excluded-regexp))
-;; org-download
+;; easier to insert images
(my-use-package org-download
:after org
:demand t
@@ -318,8 +333,12 @@
(my-use-package org-capture
:straight nil
:init
- (setq my-org-capture-file (concat org-directory "/20260509T232442==agenda--all-my-todos.org"))
- (setq my-org-capture-game-file (concat org-directory "/20260810T233455==agenda--all-about-game__game.org"))
+ (defcustom my-org-capture-file
+ (concat org-directory "/20260509T232442==agenda--all-my-todos.org")
+ "File used to capture todos.")
+ (defcustom my-org-capture-game-file
+ (concat org-directory "/20260810T233455==agenda--all-about-game__game.org")
+ "File used to capture games")
:config
(setq org-capture-templates
`(("t" "TODO" entry
@@ -366,7 +385,6 @@
(cnfonts-decrease-fontsize 5)
(hl-line-mode 1)
(view-mode -1)
- (jinx-mode 1)
(org-tree-slide-mode -1))))
;; Chinese calendar
diff --git a/lisp/init-package.el b/lisp/init-package.el
@@ -140,6 +140,8 @@ With a prefix ARG create a new *scratch* buffer."
(persp-set-buffer buf))))
(setopt persp-mode-prefix-key (kbd "C-c p"))
+ (general-def perspective-map "d" #'persp-kill)
+
(setq persp-switch-to-buffer-behavior 'switch
persp-sort 'oldest)
(with-eval-after-load 'consult
@@ -258,7 +260,7 @@ against its previous revision."
;; helpful
(my-use-package helpful
:straight
- (helpful :fork (:type git :repo "https://git.trogloxene.org/helpful.git"))
+ (helpful :fork (:type git :host nil :repo "https://git.trogloxene.org/helpful.git"))
:bind
(([remap describe-function] . helpful-callable)
([remap describe-command] . helpful-command)
@@ -316,7 +318,7 @@ against its previous revision."
proced-show-remote-processes t
proced-enable-color-flag t
proced-format 'custom)
-
+
(add-to-list
'proced-format-alist
(if *is-mac*
@@ -390,7 +392,8 @@ Prefix ARG controls sort order, see `proced-sort-interactive'."
;; hyperbole
(my-use-package hyperbole
- :straight (hyperbole :type git :host github :repo "rswgnu/hyperbole")
+ :straight
+ (hyperbole :type git :host github :repo "rswgnu/hyperbole")
:defer 5
:delight
(hywiki-mode nil hywiki)
diff --git a/lisp/init-terminal.el b/lisp/init-terminal.el
@@ -185,7 +185,7 @@
`(xref-line-number ((t (:foreground ,my-green))))
`(match ((t (:foreground ,my-base1 :background ,my-base02 :weight bold))))))
-(defun open-init-file()
+(defun my-open-init-file()
"Open user's init.el file."
(interactive)
(find-file user-init-file))
@@ -268,7 +268,7 @@ there's a region, all lines that region covers will be duplicated."
;; global map
;; buffer, file, and window
-(keymap-global-set "<f2>" #'open-init-file)
+(keymap-global-set "<f2>" #'my-open-init-file)
(keymap-global-set "C-x C-b" #'ibuffer-other-window)
;; edit
diff --git a/lisp/init-ui.el b/lisp/init-ui.el
@@ -13,9 +13,7 @@
;; solarized
(my-use-package solarized-theme
:straight
- (solarized-emacs
- :fork
- (:type git :repo "https://git.trogloxene.org/solarized-emacs.git"))
+ (solarized-emacs :fork (:type git :host nil :repo "https://git.trogloxene.org/solarized-emacs.git"))
:init
(if (and (daemonp) (not *is-android*))
(add-hook 'after-make-frame-functions
@@ -29,11 +27,12 @@
;; color picker
;; from zHaOdANiuu's ElegantEmacs
(my-use-package color-picker
- :straight (:type git :host github :repo "zHaOdANiuu/color-picker.el")
+ :straight
+ (color-picker :type git :host github :repo "zHaOdANiuu/color-picker.el")
:commands color-picker my-pick-color
:config
(setq color-picker-scale 2.0)
-
+
(defun my-pick-color (arg)
"Pick and insert color."
(interactive "P")
@@ -128,7 +127,7 @@ from `readable-foreground-color'."
;; whitespace
(my-use-package whitespace
:straight nil
- :config
+ :init
(defun my-show-trailing-whitespace ()
"Enable display of trailing whitespace in this buffer."
(setq-local show-trailing-whitespace t))
@@ -140,7 +139,8 @@ from `readable-foreground-color'."
(my-use-package olivetti
:delight
:hook
- (text-mode . olivetti-mode)
+ ((org-mode markdown-mode md-ts-mode outline-mode kotl-mode rst-mode)
+ . olivetti-mode)
(olivetti-mode . (lambda () (display-line-numbers-mode -1)))
:init
(setq olivetti-body-width 85))
diff --git a/lisp/my-theme.el b/lisp/my-theme.el
@@ -27,7 +27,12 @@
`(mode-line-inactive ((,class (:foreground ,base01 :background ,base03))))
`(display-time-date-and-time ((,class (:foreground ,base1 :bold t))))
- `(trailing-whitespace ((,class (:inherit whitespace-trailing))))
+ `(comint-highlight-prompt ((,class (:foreground ,green))))
+ `(comint-highlight-input ((,class (:inherit bold))))
+
+ `(eshell-ls-readonly ((,class (:inherit error))))
+
+ `(trailing-whitespace ((,class (:foreground ,orange-lc :inverse-video t))))
`(outline-1 ((,class (:foreground ,orange :height 1.0 :weight normal))))
`(outline-2 ((,class (:foreground ,blue :height 1.0 :weight normal))))
@@ -187,5 +192,4 @@
`(gt-youdao-dict-phonetic-face ((,class (:inherit italic)))))))
(provide 'my-theme)
-
;;; my-theme.el ends here