commit 3686ea67454c67989cb38285bf3ece2f1d10e4de
parent 99ca3c58f3a9dbf90239ccedeb6a192487d9669c
Author: andsy10 <andsy1016@gmail.com>
Date: Thu, 8 Oct 2026 17:59:02 +0800
Cleanup use-package declarations and keybindings
Diffstat:
10 files changed, 56 insertions(+), 79 deletions(-)
diff --git a/lisp/init-base.el b/lisp/init-base.el
@@ -43,22 +43,27 @@
(server-mode 1)))))
;; recently opened files
-(if (or (display-graphic-p) *is-android*)
- (use-package recentf
- :straight nil
- :hook
- (after-init . recentf-mode)
- :init
- (setq recentf-max-saved-items 30)
- :config
- (if *is-android*
- (add-to-list 'recentf-exclude "~/storage/shared/my-org-note/journal/.*\\.org\\'")
- (add-to-list 'recentf-exclude "~/org/my-org-note/journal/.*\\.org\\'")
- (add-to-list 'recentf-exclude "~/org/my-org-note/20260509T232442==agenda--all-my-todos\\.org")
- (add-to-list 'recentf-exclude "~/org/my-org-note/20260810T233455==agenda--all-about-game__game\\.org"))
- (add-to-list 'recentf-exclude "~/.emacs.d/emms/history")
- (add-to-list 'recentf-exclude "~/.emacs.d/bookmarks")
- (add-to-list 'recentf-exclude "~/hywiki/.hywiki.eld")))
+(use-package recentf
+ :straight nil
+ :hook
+ (after-init . recentf-mode)
+ :init
+ (setq recentf-max-saved-items 30
+ recentf-exclude
+ '("\\.?cache" ".cask" "url" "COMMIT_EDITMSG\\'" "bookmarks"
+ "\\.\\(?:gz\\|gif\\|svg\\|png\\|jpe?g\\|bmp\\|xpm\\)$"
+ "\\.?ido\\.last$" "\\.revive$" "/G?TAGS$" "/.elfeed/"
+ "^/tmp/" "^/var/folders/.+$" "^/ssh:" "/persp-confs/"
+ (lambda (file) (file-in-directory-p file package-user-dir))))
+ :config
+ (if *is-android*
+ (add-to-list 'recentf-exclude "~/storage/shared/my-org-note/journal/.*\\.org\\'")
+ (add-to-list 'recentf-exclude "~/org/my-org-note/journal/.*\\.org\\'")
+ (add-to-list 'recentf-exclude "~/org/my-org-note/20260509T232442==agenda--all-my-todos\\.org")
+ (add-to-list 'recentf-exclude "~/org/my-org-note/20260810T233455==agenda--all-about-game__game\\.org"))
+ (add-to-list 'recentf-exclude "~/.emacs.d/emms/history")
+ (add-to-list 'recentf-exclude "~/.emacs.d/bookmarks")
+ (add-to-list 'recentf-exclude "~/hywiki/.hywiki.eld"))
;; save minibuffer history
(use-package savehist
@@ -288,7 +293,7 @@
:straight nil
:init
(setq speedbar-window-default-width 30)
- :autoload my-speedbar
+ :commands my-speedbar
:config
(defun my-speedbar ()
"Run `speedbar-get-focus' if current buffer is not speedbar, otherwise run `speedbar'"
diff --git a/lisp/init-completion.el b/lisp/init-completion.el
@@ -5,10 +5,10 @@
;;; Code:
(use-package emacs
- :custom
- (tab-always-indent 'complete)
- (text-mode-ispell-word-completion nil)
- (read-extended-command-predicate #'command-completion-default-include-p))
+ :init
+ (setq tab-always-indent 'complete
+ text-mode-ispell-word-completion nil
+ read-extended-command-predicate #'command-completion-default-include-p))
;; minibuffer completion
(use-package vertico
@@ -17,8 +17,8 @@
;; orderless completion
(use-package orderless
- :custom
- (completion-styles '(orderless basic)))
+ :init
+ (setq completion-styles '(orderless basic)))
;; marginalia in minibuffer
(use-package marginalia
@@ -27,6 +27,8 @@
;; search and navigation
(use-package consult
+ :commands my-consult-git-grep-project consult-directory-externally
+ :commands consult-directory-externally my-open-current-directory my-consult-fd-home
:config
(defun my-consult-git-grep-project ()
"Run `consult-git-grep' in current project's root."
@@ -58,7 +60,7 @@
(interactive)
(consult-directory-externally default-directory))
- (defun consult-fd-home ()
+ (defun my-consult-fd-home ()
"Search for all files in home folder use fd."
(interactive)
(let ((consult-fd-args "fd -H -I -i -c never --full-path")
@@ -131,21 +133,10 @@
;; right-click
(use-package embark
- :commands
- embark-prefix-help-command
+ :commands embark-prefix-help-command
:init
(setq prefix-help-command 'embark-prefix-help-command)
:config
-
- ;; from centaur emacs
- (defun my-embark-preview ()
- "Previews candidate in vertico buffer, unless it's a consult command."
- (interactive)
- (unless (bound-and-true-p consult--preview-function)
- (save-selected-window
- (let ((embark-quit-after-action nil))
- (embark-dwim)))))
-
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
@@ -178,8 +169,7 @@ targets."
(setq embark-indicators
'(embark-which-key-indicator
- embark-highlight-indicator
- embark-isearch-highlight-indicator))
+ embark-highlight-indicator))
(defun embark-hide-which-key-indicator (fn &rest args)
"Hide the which-key indicator immediately when using the completing-read prompter."
@@ -196,8 +186,7 @@ targets."
;; corfu
(use-package corfu
- :autoload
- (corfu-quit consult-completion-in-region)
+ :autoload corfu-quit consult-completion-in-region
:bind
(:map corfu-map
("M-d" . corfu-popupinfo-documentation)
@@ -231,9 +220,8 @@ targets."
;; cape
(use-package cape
- :commands (cape-file cape-elisp-block cape-keyword)
- :autoload (cape-wrap-nonexclusive cape-wrap-buster)
- :autoload (cape-wrap-silent)
+ :commands cape-file cape-elisp-block cape-keyword
+ :autoload cape-wrap-nonexclusive cape-wrap-buster cape-wrap-silent
:init
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-file)
diff --git a/lisp/init-dired.el b/lisp/init-dired.el
@@ -93,8 +93,7 @@ the hardcoded fallback recipe."
;; gitignore
(use-package dired-gitignore
- :after
- (dirvish dirvish-vc transient)
+ :after dirvish-vc transient
:demand t
:config
(transient-define-suffix dirvish-toggle-gitignore ()
@@ -115,8 +114,7 @@ the hardcoded fallback recipe."
;; trashed
(unless *is-mac*
(use-package trashed
- :commands
- (trashed)
+ :commands trashed
:config
(setq trashed-action-confirmer 'y-or-n-p
trashed-use-header-line t
diff --git a/lisp/init-exwm.el b/lisp/init-exwm.el
@@ -107,11 +107,7 @@
(defun my-exwm-update-class ()
(exwm-workspace-rename-buffer exwm-class-name))
- (add-hook 'exwm-update-class-hook #'my-exwm-update-class)
-
- (require 'exwm-xim)
- (exwm-xim-mode)
- (exwm-wm-mode))
+ (add-hook 'exwm-update-class-hook #'my-exwm-update-class))
(use-package desktop-environment
:after exwm
@@ -137,12 +133,7 @@
:host github
:repo "emacs-exwm/xdg-launcher")
:bind
- (("s-SPC" . xdg-launcher-run-app))
- :init
- (with-eval-after-load 'consult
- (unless (memq 'xdg-launcher-consult-source consult-buffer-sources)
- (setq consult-buffer-sources
- (append consult-buffer-sources '(xdg-launcher-consult-source))))))
+ (("s-SPC" . xdg-launcher-run-app)))
(defun reboot ()
"Execute loginctl reboot command."
diff --git a/lisp/init-gptel.el b/lisp/init-gptel.el
@@ -146,7 +146,7 @@ explanations, no quotes, no punctuation, no file extension."
;; pi-coding-agent
(use-package pilish
- :autoload my-pilish
+ :commands my-pilish
:config
(defun my-pilish ()
"Run `pilish' in project root."
diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el
@@ -238,7 +238,8 @@
(general-def markdown-mode-map
"M-p" nil
"M-n" nil
- "C-<tab>" #'markdown-cycle-parent-subtree)
+ "C-<tab>" #'markdown-cycle-parent-subtree
+ "C-c C-e" #'markdown-do)
;; minibuffer
(general-def minibuffer-local-map
diff --git a/lisp/init-org.el b/lisp/init-org.el
@@ -183,9 +183,7 @@
(use-package denote-journal
:hook
(calendar-mode . denote-journal-calendar-mode)
- :autoload (my-denote-journal-path-to-existing-entry
- my-denote-journal-open-entry
- my-denote-journal-find-file)
+ :commands my-denote-journal-open-entry my-denote-journal-find-file
:config
(defun my-denote-journal-path-to-existing-entry (&optional date interval)
"Return the path of current denote journal if it exists, otherwise return nil."
@@ -340,7 +338,8 @@
;; presentation
(use-package org-tree-slide
- :init
+ :commands my-org-tree-slide-start my-org-tree-slide-stop
+ :config
(defun my-org-tree-slide-start ()
"Start `org-tree-slide'."
(interactive)
diff --git a/lisp/init-package.el b/lisp/init-package.el
@@ -69,7 +69,6 @@ Like normal Emacs `C-k'. Kill to end of line and put content in kill-ring."
(persp-mode-prefix-key (kbd "C-c p"))
:hook
(after-init . persp-mode)
- :commands my-persp-ibuffer my-persp-scratch-buffer
:config
(defun my-persp-scratch-buffer (arg)
"Switch to the current perspective's scratch buffer.
@@ -141,8 +140,7 @@ With a prefix ARG create a new *scratch* buffer."
(let ((buffers (ibuffer-get-marked-buffers)))
(persp-switch persp-name)
(dolist (buf buffers)
- (persp-set-buffer buf)))
- (ibuffer-update nil t))
+ (persp-set-buffer buf))))
(setq persp-switch-to-buffer-behavior 'switch
persp-sort 'oldest)
@@ -158,6 +156,7 @@ With a prefix ARG create a new *scratch* buffer."
;; magit
(use-package magit
+ :commands my-magit-toggle-parent-section
:config
(defun my-magit-toggle-parent-section ()
"Toggle parent magit section."
diff --git a/lisp/init-prog.el b/lisp/init-prog.el
@@ -34,7 +34,7 @@
(use-package ielm
:straight nil
- :autoload (my-switch-to-ielm my-repl-switch-back)
+ :commands my-switch-to-ielm my-repl-switch-back
:config
;; jump between ielm and elisp file
(defvar-local my-repl-original-buffer nil
@@ -102,12 +102,9 @@
;; markdown
(use-package markdown-mode
- :bind
- (:map markdown-mode-map
- ("C-c C-e" . markdown-do))
:hook
(markdown-mode . visual-line-mode)
- :init
+ :config
(defun markdown-cycle-parent-subtree()
"Cycle parent markdown subtree."
(interactive)
@@ -125,9 +122,7 @@
;; caddy
(use-package caddyfile-mode
- :mode
- (("Caddyfile\\'" . caddyfile-mode)
- ("caddy\\.conf\\'" . caddyfile-mode)))
+ :mode "Caddyfile\\'" "caddy\\.conf\\'")
;; some modes
(add-to-list 'auto-mode-alist '("\\.service\\'" . conf-unix-mode))
diff --git a/lisp/init-ui.el b/lisp/init-ui.el
@@ -31,8 +31,9 @@
(use-package color-picker
:straight (:type git :host github :repo "zHaOdANiuu/color-picker.el")
:commands color-picker my-pick-color
- :custom (color-picker-scale 2.0)
:config
+ (setq color-picker-scale 2.0)
+
(defun my-pick-color (arg)
"Pick and insert color."
(interactive "P")
@@ -47,10 +48,10 @@
(use-package colorful-mode
:hook (prog-mode . colorful-mode)
- :custom
- (colorful-use-prefix t)
- (colorful-only-strings 'only-prog)
+ :commands my-colorful-color-picker
:config
+ (setq colorful-use-prefix t
+ colorful-only-strings 'only-prog)
(add-to-list 'global-colorful-modes 'helpful-mode)
(when (display-graphic-p)