.emacs.d

the most bloated Emacs config on this planet
git clone https://git.trogloxene.org/.emacs.d.git
Log | Files | Refs

commit 788f0146d20e0c37365c7a870787725112ebe321
parent 3686ea67454c67989cb38285bf3ece2f1d10e4de
Author: andsy10 <andsy1016@gmail.com>
Date:   Thu,  8 Oct 2026 22:15:53 +0800

Add my-use-package macro for conditional loading

Diffstat:
Mlisp/init-base.el | 70++++++++++++++++++++++++++++++++++------------------------------------
Mlisp/init-completion.el | 45++++++++++++++++++++++-----------------------
Mlisp/init-dired.el | 122++++++++++++++++++++++++++++++++++++++-----------------------------------------
Mlisp/init-edit.el | 28++++++++++++++--------------
Mlisp/init-elpa.el | 42+++++++++++++++++++++++++++++++++++++++---
Mlisp/init-exwm.el | 278+++++++++++++++++++++++++++++++++++++++----------------------------------------
Mlisp/init-gptel.el | 8++++----
Mlisp/init-org.el | 30+++++++++++++++---------------
Mlisp/init-package.el | 123++++++++++++++++++++++++++++++++++++++-----------------------------------------
Mlisp/init-prog.el | 26+++++++++++++-------------
Mlisp/init-segmentation.el | 4+++-
Mlisp/init-ui.el | 48+++++++++++++++++++++++-------------------------
Mlisp/init-window.el | 6+++---
13 files changed, 426 insertions(+), 404 deletions(-)

diff --git a/lisp/init-base.el b/lisp/init-base.el @@ -5,10 +5,10 @@ ;;; Code: ;; keybindings -(use-package general) +(my-use-package general) ;; mode names in mode line -(use-package delight +(my-use-package delight :config (delight `((eldoc-mode nil eldoc) @@ -17,7 +17,7 @@ (hs-minor-mode nil hideshow)))) ;; garbage collection -(use-package gcmh +(my-use-package gcmh :delight :hook (emacs-startup . gcmh-mode) @@ -27,14 +27,14 @@ gcmh-high-cons-threshold #x4000000)) ;; benchmark -(use-package benchmark-init +(my-use-package benchmark-init :init (benchmark-init/activate) :hook (after-init . benchmark-init/deactivate)) ;; server-mode -(use-package server +(my-use-package server :straight nil :demand t :hook @@ -43,7 +43,7 @@ (server-mode 1))))) ;; recently opened files -(use-package recentf +(my-use-package recentf :straight nil :hook (after-init . recentf-mode) @@ -66,7 +66,7 @@ (add-to-list 'recentf-exclude "~/hywiki/.hywiki.eld")) ;; save minibuffer history -(use-package savehist +(my-use-package savehist :straight nil :hook (after-init . savehist-mode) @@ -81,39 +81,38 @@ savehist-autosave-interval 300)) ;; save cursor place -(use-package saveplace +(my-use-package saveplace :straight nil :hook (after-init . save-place-mode)) ;; async -(unless *is-android* - (use-package async - :hook - (after-init . dired-async-mode))) +(my-use-package async (not *is-android*) + :hook + (after-init . dired-async-mode)) ;; autorevert buffer -(use-package autorevert +(my-use-package autorevert :straight nil :delight :hook (after-init . global-auto-revert-mode)) ;; display keybindings -(use-package which-key +(my-use-package which-key :straight nil :delight :hook (after-init . which-key-mode)) ;; save window changes -(use-package winner +(my-use-package winner :straight nil :hook (after-init . winner-mode)) ;; ibuffer -(use-package ibuffer +(my-use-package ibuffer :straight nil :config (setq ibuffer-saved-filter-groups @@ -244,7 +243,7 @@ ibuffer-default-sorting-mode 'alphabetic ibuffer-human-readable-size t)) -(use-package simple +(my-use-package simple :straight nil :hook (after-init . size-indication-mode) @@ -254,34 +253,33 @@ set-mark-command-repeat-pop t)) ;easier to pop marks ;; scroll -(unless *is-mac* - (use-package pixel-scroll - :straight nil - :hook - (after-init . pixel-scroll-precision-mode) - :init - (setq scroll-preserve-screen-position t - scroll-conservatively 101) - :config - (advice-add 'pixel-scroll-precision :around - (lambda (orig event) - (cl-letf (((symbol-function 'device-class) - (lambda (&rest _) 'mouse))) - (funcall orig event)))))) +(my-use-package pixel-scroll (not *is-mac*) + :straight nil + :hook + (after-init . pixel-scroll-precision-mode) + :init + (setq scroll-preserve-screen-position t + scroll-conservatively 101) + :config + (advice-add 'pixel-scroll-precision :around + (lambda (orig event) + (cl-letf (((symbol-function 'device-class) + (lambda (&rest _) 'mouse))) + (funcall orig event))))) ;; eww -(use-package eww +(my-use-package eww :straight nil :config (setq eww-auto-rename-buffer t)) -(use-package shr +(my-use-package shr :straight nil :config (setq shr-use-fonts nil)) ;; tramp -(use-package tramp +(my-use-package tramp :straight nil :config (setq tramp-default-method 'ssh @@ -289,7 +287,7 @@ (setq tramp-completion-use-auth-sources nil)) ;; speedbar -(use-package speedbar +(my-use-package speedbar :straight nil :init (setq speedbar-window-default-width 30) @@ -325,7 +323,7 @@ (setq speedbar-show-unknown-files t)) ;; isearch -(use-package isearch +(my-use-package isearch :straight nil :init ;; move lazy count numbers to mode-line diff --git a/lisp/init-completion.el b/lisp/init-completion.el @@ -4,29 +4,29 @@ ;;; Code: -(use-package emacs +(my-use-package emacs :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 +(my-use-package vertico :hook (after-init . vertico-mode)) ;; orderless completion -(use-package orderless +(my-use-package orderless :init (setq completion-styles '(orderless basic))) ;; marginalia in minibuffer -(use-package marginalia +(my-use-package marginalia :hook (after-init . marginalia-mode)) ;; search and navigation -(use-package consult +(my-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 @@ -132,7 +132,7 @@ :test 'equal))) ;; right-click -(use-package embark +(my-use-package embark :commands embark-prefix-help-command :init (setq prefix-help-command 'embark-prefix-help-command) @@ -182,34 +182,33 @@ targets." :around #'embark-hide-which-key-indicator)))) ;; embark-consult -(use-package embark-consult) +(my-use-package embark-consult) ;; corfu -(use-package corfu +(my-use-package corfu :autoload corfu-quit consult-completion-in-region :bind (:map corfu-map ("M-d" . corfu-popupinfo-documentation) ("RET" . nil)) - :custom - (corfu-auto t) - (corfu-auto-prefix 2) - (corfu-count 12) - (corfu-preview-current nil) - (corfu-on-exact-match nil) - (corfu-auto-delay 0.2) - (corfu-popupinfo-delay '(0.4 . 0.2)) - (global-corfu-modes '((not erc-mode - circe-mode - help-mode - gud-mode - vterm-mode) - t)) :hook (after-init . global-corfu-mode) (after-init . corfu-popupinfo-mode) (after-init . corfu-history-mode) :config + (setopt corfu-auto t + corfu-auto-prefix 2 + corfu-count 12 + corfu-preview-current nil + corfu-on-exact-match nil + corfu-auto-delay 0.2 + corfu-popupinfo-delay '(0.4 . 0.2) + global-corfu-modes '((not erc-mode + circe-mode + help-mode + gud-mode + vterm-mode) + t)) (add-hook 'before-save-hook #'corfu-quit) (add-hook 'eshell-mode-hook (lambda () @@ -219,7 +218,7 @@ targets." (lambda () (setq-local corfu-auto nil)))) ;; cape -(use-package cape +(my-use-package cape :commands cape-file cape-elisp-block cape-keyword :autoload cape-wrap-nonexclusive cape-wrap-buster cape-wrap-silent :init diff --git a/lisp/init-dired.el b/lisp/init-dired.el @@ -4,7 +4,7 @@ ;;; Code: -(use-package dired +(my-use-package dired :straight nil :config (when *is-mac* @@ -26,7 +26,7 @@ (put 'dired-find-alternate-file 'disabled nil)) ;; dirvish -(use-package dirvish +(my-use-package dirvish :init (dirvish-override-dired-mode) :config @@ -52,47 +52,45 @@ the hardcoded fallback recipe." dirvish-attributes '(file-time file-size) dirvish-yank-sources 'session dirvish-hide-cursor nil) - - :custom - (dirvish-quick-access-entries - (cond - (*is-windows* - '(("h" "~/" "Home") - ("e" "~/.emacs.d/" "Emacs config") - ("p" "c:/Users/gaozh/Pictures/Screenshots/" "Pictures") - ("d" "f:/下载25-2-10/" "Download") - ("v" "f:/luping26-1-11/" "Videos") - ("n" "h:/emacs/my-org-note/" "Notes"))) - - (*is-mac* - '(("h" "~/" "Home") - ("e" "~/.emacs.d/" "Emacs config") - ("p" "~/Pictures/" "Pictures") - ("d" "~/Downloads/" "Download") - ("v" "~/Movies/" "Videos") - ("m" "~/Music/" "Music") - ("n" "~/org/my-org-note/" "Notes") - ("g" "~/gptel/" "gptel sessions"))) - - (*is-linux* - '(("h" "~/" "Home") - ("e" "~/.emacs.d/" "Emacs config") - ("s" "~/.config/guix/" "System config") - ("p" "~/Pictures/" "Pictures") - ("d" "~/downloads/" "Downloads") - ("v" "~/视频/" "Videos") - ("n" "~/org/my-org-note/" "Notes") - ("g" "~/gptel/" "gptel sessions"))) - - (*is-android* - '(("h" "~/" "Home") - ("e" "~/.emacs.d" "Emacs") - ("n" "~/storage/shared/my-org-note/" "Notes") - ("g" "~/gptel/" "gptel sessions"))) - (t nil)))) + (setopt dirvish-quick-access-entries + (cond + (*is-windows* + '(("h" "~/" "Home") + ("e" "~/.emacs.d/" "Emacs config") + ("p" "c:/Users/gaozh/Pictures/Screenshots/" "Pictures") + ("d" "f:/下载25-2-10/" "Download") + ("v" "f:/luping26-1-11/" "Videos") + ("n" "h:/emacs/my-org-note/" "Notes"))) + + (*is-mac* + '(("h" "~/" "Home") + ("e" "~/.emacs.d/" "Emacs config") + ("p" "~/Pictures/" "Pictures") + ("d" "~/Downloads/" "Download") + ("v" "~/Movies/" "Videos") + ("m" "~/Music/" "Music") + ("n" "~/org/my-org-note/" "Notes") + ("g" "~/gptel/" "gptel sessions"))) + + (*is-linux* + '(("h" "~/" "Home") + ("e" "~/.emacs.d/" "Emacs config") + ("s" "~/.config/guix/" "System config") + ("p" "~/Pictures/" "Pictures") + ("d" "~/downloads/" "Downloads") + ("v" "~/视频/" "Videos") + ("n" "~/org/my-org-note/" "Notes") + ("g" "~/gptel/" "gptel sessions"))) + + (*is-android* + '(("h" "~/" "Home") + ("e" "~/.emacs.d" "Emacs") + ("n" "~/storage/shared/my-org-note/" "Notes") + ("g" "~/gptel/" "gptel sessions"))) + (t nil)))) ;; gitignore -(use-package dired-gitignore +(my-use-package dired-gitignore :after dirvish-vc transient :demand t :config @@ -112,17 +110,16 @@ the hardcoded fallback recipe." '("i" dirvish-toggle-gitignore))) ;; trashed -(unless *is-mac* - (use-package trashed - :commands trashed - :config - (setq trashed-action-confirmer 'y-or-n-p - trashed-use-header-line t - trashed-sort-key '("Date deleted" . t) - trashed-date-format "%Y-%m-%d %H:%M:%S"))) +(my-use-package trashed (not *is-mac*) + :commands trashed + :config + (setq trashed-action-confirmer 'y-or-n-p + trashed-use-header-line t + trashed-sort-key '("Date deleted" . t) + trashed-date-format "%Y-%m-%d %H:%M:%S")) ;; dired-rsync -(use-package dired-rsync +(my-use-package dired-rsync :config (setq dired-rsync-options "-az -e ssh") @@ -137,19 +134,18 @@ the hardcoded fallback recipe." (default-value 'mode-line-format))))) ;; mount disk -(when *is-linux* - (use-package debase - :straight - (debase :type git - :host codeberg - :repo "emacs-weirdware/debase")) - - (use-package discomfort - :commands discomfort - :straight - (discomfort :type git - :host codeberg - :repo "emacs-weirdware/discomfort"))) +(my-use-package debase *is-linux* + :straight + (debase :type git + :host codeberg + :repo "emacs-weirdware/debase")) + +(my-use-package discomfort *is-linux* + :commands discomfort + :straight + (discomfort :type git + :host codeberg + :repo "emacs-weirdware/discomfort")) (provide 'init-dired) ;;; init-dired.el ends here diff --git a/lisp/init-edit.el b/lisp/init-edit.el @@ -5,49 +5,49 @@ ;;; Code: ;; delete select -(use-package delsel +(my-use-package delsel :straight nil :hook (after-init . delete-selection-mode)) ;; insert pairs -(use-package elec-pair +(my-use-package elec-pair :straight nil :config (setq electric-pair-inhibit-predicate 'electric-pair-conservative-inhibit)) ;; subword movement -(use-package subword +(my-use-package subword :straight nil :delight :hook (after-init . global-subword-mode)) ;; hungry-delete -(use-package hungry-delete) +(my-use-package hungry-delete) ;; drag-stuff -(use-package drag-stuff) +(my-use-package drag-stuff) ;; better undo/redo -(use-package undo-fu +(my-use-package undo-fu :config (setq undo-fu-allow-undo-in-region t)) ;; save undo history across sessions -(use-package undo-fu-session +(my-use-package undo-fu-session :hook (after-init . undo-fu-session-global-mode)) ;; undo tree -(use-package vundo +(my-use-package vundo :init (setq undo-limit 67108864 undo-strong-limit 100663296 undo-outer-limit 1006632960)) ;; kmacro enhancement (and multiple cursors) -(use-package kmacro-x +(my-use-package kmacro-x :straight (kmacro-x :fork (:type git :repo "https://git.trogloxene.org/kmacro-x.git")) :delight @@ -59,7 +59,7 @@ (setq kmacro-x-mc-live-preview t)) ;; expand-region -(use-package expand-region +(my-use-package expand-region :commands (er/mark-symbol er/mark-word) :config @@ -68,21 +68,21 @@ (setq expand-region-contract-fast-key "c")) ;; Chinese support for avy -(use-package ace-pinyin +(my-use-package ace-pinyin :delight :hook (after-init . ace-pinyin-global-mode)) ;; avy-zap -(use-package avy-zap) +(my-use-package avy-zap) ;; faster replacement -(use-package substitute +(my-use-package substitute :config (setq substitute-ignore-narrowing nil)) ;; modal editing -(use-package god-mode +(my-use-package god-mode :init (if *is-android* (add-hook 'after-init-hook 'god-mode-all)) :config diff --git a/lisp/init-elpa.el b/lisp/init-elpa.el @@ -33,9 +33,6 @@ straight-use-package-version t straight-use-package-by-default t) -;; imenu -(setopt use-package-enable-imenu-support t) - ;; built-in packages (setq straight-built-in-pseudo-packages (cl-union straight-built-in-pseudo-packages @@ -43,5 +40,44 @@ eldoc flymake jsonrpc seq external-completion) :test 'equal)) +;; imenu +(setq use-package-form-regexp-eval + `(concat ,(eval-when-compile + (concat "^\\s-*(" + (regexp-opt '("my-use-package" "use-package" "require") t) + "\\s-+\\(")) + (or (bound-and-true-p lisp-mode-symbol-regexp) + "\\(?:\\sw\\|\\s_\\|\\\\.\\)+") + "\\)") + use-package-enable-imenu-support t) + +;; a pointless wrapper +;; https://github.com/radian-software/straight.el/blob/main/README.md#loading-packages-conditionally +(defmacro my-use-package (name &rest args) + "Like `use-package' but support conditional loading. + +Treat the first of ARGS as a loading condition if it's not a keyword, +otherwise the macro expands to a plain `use-package' declaration." + (declare (indent defun)) + (let (condition condition-p) + (when (and args (not (keywordp (car args)))) + (setq condition (pop args) + condition-p t)) + (let* ((pos (cl-position :straight args)) + (val (and pos (nth (1+ pos) args))) + (recipe + (cond + ((or (not pos) (eq val t)) `',name) + ((null val) nil) + ((symbolp val) `',val) + ((memq (car-safe val) '(quote \`)) val) + (t `',val)))) + (if (not condition-p) + `(use-package ,name ,@args) + `(progn + ,@(when recipe `((straight-register-package ,recipe))) + (when ,condition + (use-package ,name ,@args))))))) + (provide 'init-elpa) ;;; init-elpa.el ends here diff --git a/lisp/init-exwm.el b/lisp/init-exwm.el @@ -5,136 +5,6 @@ ;;; Code: (when *is-linux* - (use-package exwm - :hook - (exwm-init . restart-fcitx5) - (exwm-init . my-desktop-init) - :config - (setq pop-up-windows nil) - (setq exwm-workspace-number 1) - (exwm-input-set-key (kbd "s-&") - (lambda (command) - (interactive (list (read-shell-command "$ "))) - (let ((display-buffer-alist - '((".*" . (display-buffer-no-window . nil))))) - (async-shell-command command)))) - - (defun my--exwm-switch-to-workspace (delta) - (let ((target - (mod (+ exwm-workspace-current-index delta) - (length exwm-workspace--list)))) - (exwm-workspace-switch target))) - - (defun my-exwm-next-workspace () - "Switch to next exwm workspace." - (interactive) - (my--exwm-switch-to-workspace 1) - (if (= 1 (length exwm-workspace--list)) - (message "No next workspace"))) - - (defun my-exwm-previous-workspace () - "Switch to previous exwm workspace." - (interactive) - (my--exwm-switch-to-workspace -1) - (if (= 1 (length exwm-workspace--list)) - (message "No previous workspace"))) - - (global-set-key (kbd "s-]") #'my-exwm-next-workspace) - (global-set-key (kbd "s-[") #'my-exwm-previous-workspace) - - (add-to-list 'global-mode-string - '(:eval (propertize (format " WS:%d " exwm-workspace-current-index) - 'face 'mode-line-emphasis)) - t) - - (setq exwm-input-prefix-keys - '(?\C-x - ?\C-u - ?\C-c - ?\C-h - ?\M-x - ?\M-o - ?\M-[ - ?\M-] - ?\s-[ - ?\s-] - ?\s- - XF86AudioLowerVolume - XF86AudioRaiseVolume - XF86AudioMute - )) - (define-key exwm-mode-map [?\C-q] #'exwm-input-send-next-key) - - (setq exwm-input-global-keys - `(([?\s-r] . exwm-reset) - ([?\s-b] . windmove-left) - ([?\s-f] . windmove-right) - ([?\s-p] . windmove-up) - ([?\s-n] . windmove-down) - ([?\s-S] . desktop-environment-screenshot) - ([?\s-s] . desktop-environment-screenshot-part) - ([?\s-w] . exwm-workspace-switch) - ([?\s-o] . other-window) - ([?\s-m] . exwm-layout-toggle-mode-line) - ([?\s-`] . (lambda () (interactive) (exwm-workspace-switch-create 0))) - ,@(mapcar (lambda (i) - `(,(kbd(format "s-%d" i)) . - (lambda () - (interactive) - (exwm-workspace-switch-create ,i)))) - (number-sequence 0 9)))) - - (setq exwm-input-simulation-keys - `((,(kbd "C-f") . [right]) - (,(kbd "C-b") . [left]) - (,(kbd "C-p") . [up]) - (,(kbd "C-n") . [down]) - (,(kbd "C-a") . [home]) - (,(kbd "C-e") . [end]) - (,(kbd "M-f") . [C-right]) - (,(kbd "A-f") . [C-right]) - (,(kbd "M-b") . [C-left]) - (,(kbd "A-b") . [C-left]) - (,(kbd "C-d") . [delete]) - (,(kbd "C-k") . [S-end delete]) - (,(kbd "M-<backspace>") . ,(kbd "C-<backspace>")) - (,(kbd "M-d") . ,(kbd "C-<delete>")) - (,(kbd "M-w") . [?\C-c]) - (,(kbd "C-y") . [?\C-v]) - (,(kbd "C-w") . [?\C-x]) - (,(kbd "C-/") . [?\C-z]) - (,(kbd "C-?") . ,(kbd "C-S-z")))) - - (defun my-exwm-update-class () - (exwm-workspace-rename-buffer exwm-class-name)) - (add-hook 'exwm-update-class-hook #'my-exwm-update-class)) - - (use-package desktop-environment - :after exwm - :demand t - :init - (add-hook 'exwm-wm-mode-hook #'desktop-environment-mode) - :config - (advice-add 'desktop-environment-screenshot :after - (lambda (&rest _) (message "Saved fullscreen screenshot."))) - (advice-add 'desktop-environment-screenshot-part :after - (lambda (&rest _) (message "Saved partial screenshot."))) - :custom - (desktop-environment-screenshot-command - "import -window root ~/Pictures/screenshot-$(date +%Y%m%d-%H%M%S).png") - (desktop-environment-screenshot-partial-command - "import ~/Pictures/screenshot-$(date +%Y%m%d-%H%M%S).png")) - - (use-package xdg-launcher - :demand t - :after exwm - :straight - (xdg-launcher :type git - :host github - :repo "emacs-exwm/xdg-launcher") - :bind - (("s-SPC" . xdg-launcher-run-app))) - (defun reboot () "Execute loginctl reboot command." (interactive) @@ -167,16 +37,144 @@ (eshell-command "fcitx5 -d")) (eshell-command "fcitx5 -d")))) -(when *is-mac* - ;; launcher - (use-package launcher - :straight - (launcher - :type git - :host github - :repo "xiaoxinghu/launcher.el") - :bind - ("s-SPC" . launcher))) +(my-use-package exwm *is-linux* + :hook + (exwm-init . restart-fcitx5) + (exwm-init . my-desktop-init) + :config + (setq pop-up-windows nil) + (setq exwm-workspace-number 1) + (exwm-input-set-key (kbd "s-&") + (lambda (command) + (interactive (list (read-shell-command "$ "))) + (let ((display-buffer-alist + '((".*" . (display-buffer-no-window . nil))))) + (async-shell-command command)))) + + (defun my--exwm-switch-to-workspace (delta) + (let ((target + (mod (+ exwm-workspace-current-index delta) + (length exwm-workspace--list)))) + (exwm-workspace-switch target))) + + (defun my-exwm-next-workspace () + "Switch to next exwm workspace." + (interactive) + (my--exwm-switch-to-workspace 1) + (if (= 1 (length exwm-workspace--list)) + (message "No next workspace"))) + + (defun my-exwm-previous-workspace () + "Switch to previous exwm workspace." + (interactive) + (my--exwm-switch-to-workspace -1) + (if (= 1 (length exwm-workspace--list)) + (message "No previous workspace"))) + + (global-set-key (kbd "s-]") #'my-exwm-next-workspace) + (global-set-key (kbd "s-[") #'my-exwm-previous-workspace) + + (add-to-list 'global-mode-string + '(:eval (propertize (format " WS:%d " exwm-workspace-current-index) + 'face 'mode-line-emphasis)) + t) + + (setq exwm-input-prefix-keys + '(?\C-x + ?\C-u + ?\C-c + ?\C-h + ?\M-x + ?\M-o + ?\M-[ + ?\M-] + ?\s-[ + ?\s-] + ?\s- + XF86AudioLowerVolume + XF86AudioRaiseVolume + XF86AudioMute + )) + (define-key exwm-mode-map [?\C-q] #'exwm-input-send-next-key) + + (setq exwm-input-global-keys + `(([?\s-r] . exwm-reset) + ([?\s-b] . windmove-left) + ([?\s-f] . windmove-right) + ([?\s-p] . windmove-up) + ([?\s-n] . windmove-down) + ([?\s-S] . desktop-environment-screenshot) + ([?\s-s] . desktop-environment-screenshot-part) + ([?\s-w] . exwm-workspace-switch) + ([?\s-o] . other-window) + ([?\s-m] . exwm-layout-toggle-mode-line) + ([?\s-`] . (lambda () (interactive) (exwm-workspace-switch-create 0))) + ,@(mapcar (lambda (i) + `(,(kbd(format "s-%d" i)) . + (lambda () + (interactive) + (exwm-workspace-switch-create ,i)))) + (number-sequence 0 9)))) + + (setq exwm-input-simulation-keys + `((,(kbd "C-f") . [right]) + (,(kbd "C-b") . [left]) + (,(kbd "C-p") . [up]) + (,(kbd "C-n") . [down]) + (,(kbd "C-a") . [home]) + (,(kbd "C-e") . [end]) + (,(kbd "M-f") . [C-right]) + (,(kbd "A-f") . [C-right]) + (,(kbd "M-b") . [C-left]) + (,(kbd "A-b") . [C-left]) + (,(kbd "C-d") . [delete]) + (,(kbd "C-k") . [S-end delete]) + (,(kbd "M-<backspace>") . ,(kbd "C-<backspace>")) + (,(kbd "M-d") . ,(kbd "C-<delete>")) + (,(kbd "M-w") . [?\C-c]) + (,(kbd "C-y") . [?\C-v]) + (,(kbd "C-w") . [?\C-x]) + (,(kbd "C-/") . [?\C-z]) + (,(kbd "C-?") . ,(kbd "C-S-z")))) + + (defun my-exwm-update-class () + (exwm-workspace-rename-buffer exwm-class-name)) + (add-hook 'exwm-update-class-hook #'my-exwm-update-class)) + +(my-use-package desktop-environment *is-linux* + :after exwm + :demand t + :init + (add-hook 'exwm-wm-mode-hook #'desktop-environment-mode) + :config + (advice-add 'desktop-environment-screenshot :after + (lambda (&rest _) (message "Saved fullscreen screenshot."))) + (advice-add 'desktop-environment-screenshot-part :after + (lambda (&rest _) (message "Saved partial screenshot."))) + :custom + (desktop-environment-screenshot-command + "import -window root ~/Pictures/screenshot-$(date +%Y%m%d-%H%M%S).png") + (desktop-environment-screenshot-partial-command + "import ~/Pictures/screenshot-$(date +%Y%m%d-%H%M%S).png")) + +(my-use-package xdg-launcher *is-linux* + :demand t + :after exwm + :straight + (xdg-launcher :type git + :host github + :repo "emacs-exwm/xdg-launcher") + :bind + (("s-SPC" . xdg-launcher-run-app))) + +(my-use-package launcher *is-mac* + :straight + (launcher + :type git + :host github + :repo "xiaoxinghu/launcher.el") + :bind + ("s-SPC" . launcher)) (provide 'init-exwm) ;;; init-exwm.el ends here diff --git a/lisp/init-gptel.el b/lisp/init-gptel.el @@ -5,7 +5,7 @@ ;;; Code: -(use-package gptel +(my-use-package gptel :config (setq gptel-log-level t gptel-default-mode 'org-mode @@ -114,11 +114,11 @@ explanations, no quotes, no punctuation, no file extension." (with-eval-after-load 'gptel (define-key gptel-mode-map (kbd "C-c C-s") #'my-gptel-save-session))) -(use-package gptel-agent +(my-use-package gptel-agent :after gptel :demand t) -(use-package gptel-magit +(my-use-package gptel-magit :straight (gptel-magit :fork (:host github :repo "ArthurHeymans/gptel-magit")) :hook @@ -145,7 +145,7 @@ explanations, no quotes, no punctuation, no file extension." gptel-magit-backend (gptel-get-backend "gptel-Kimi-Code-magit")))) ;; pi-coding-agent -(use-package pilish +(my-use-package pilish :commands my-pilish :config (defun my-pilish () diff --git a/lisp/init-org.el b/lisp/init-org.el @@ -4,7 +4,7 @@ ;;; Code: -(use-package org +(my-use-package org :hook (org-mode . org-indent-mode) (org-mode . visual-line-mode) @@ -86,7 +86,7 @@ '(org-agenda-skip-entry-if 'todo '("COMMENT")))) ;; optimize line wrapping in tables -(use-package phscroll +(my-use-package phscroll :hook (org-mode . org-phscroll-activate) (markdown-mode . phscroll-mode) @@ -94,14 +94,14 @@ (setq org-startup-truncated nil)) ;; consult-denote -(use-package consult-denote +(my-use-package consult-denote :hook (after-init . consult-denote-mode) :init (setq consult-denote-buffer-sources nil)) ;; denote -(use-package denote +(my-use-package denote :hook (after-init . denote-rename-buffer-mode) (dired-mode . denote-dired-mode) @@ -159,7 +159,7 @@ (add-to-list 'savehist-ignored-variables 'denote-title-history))) ;; denote-org -(use-package denote-org +(my-use-package denote-org :commands my-denote-org-find-backlink-for-heading-with-location :config (defun my-denote-org-find-backlink-for-heading-with-location () @@ -172,7 +172,7 @@ (consult-xref fetcher nil)))) ;; denote-lint -(use-package denote-lint +(my-use-package denote-lint :straight (denote-lint :type git :repo "https://git.trogloxene.org/denote-lint.git") @@ -180,7 +180,7 @@ (setq org-link-elisp-confirm-function nil)) ;; denote-journal -(use-package denote-journal +(my-use-package denote-journal :hook (calendar-mode . denote-journal-calendar-mode) :commands my-denote-journal-open-entry my-denote-journal-find-file @@ -223,7 +223,7 @@ (setq denote-journal-keyword "daily")) ;; denote-explore -(use-package denote-explore +(my-use-package denote-explore :commands my-denote-explore-isolate-files-dired :init (setq denote-explore-isolated-ignore-keywords '("daily")) @@ -236,7 +236,7 @@ (denote-explore--idenitfy-isolated)))))) ;; org-download -(use-package org-download +(my-use-package org-download :after org :demand t :config @@ -249,15 +249,15 @@ org-return-follows-link t)) ;; org-ql -(use-package org-ql) +(my-use-package org-ql) ;; org-super-agenda -(use-package org-super-agenda +(my-use-package org-super-agenda :config (org-super-agenda-mode)) ;; agenda -(use-package org-agenda +(my-use-package org-agenda :straight nil :hook (org-agenda-finalize . enable-truncate-lines) @@ -313,7 +313,7 @@ (:name "game" :todo "GAME")))))))))) ;; capture -(use-package org-capture +(my-use-package org-capture :straight nil :init (setq my-org-capture-file (concat org-directory "/20260509T232442==agenda--all-my-todos.org")) @@ -337,7 +337,7 @@ "* GAME %?\n%T" :empty-lines 1)))) ;; presentation -(use-package org-tree-slide +(my-use-package org-tree-slide :commands my-org-tree-slide-start my-org-tree-slide-stop :config (defun my-org-tree-slide-start () @@ -368,7 +368,7 @@ (org-tree-slide-mode -1)))) ;; Chinese calendar -(use-package cal-china-x +(my-use-package cal-china-x :after calendar :autoload cal-china-x-setup :init diff --git a/lisp/init-package.el b/lisp/init-package.el @@ -5,35 +5,34 @@ ;;; Code: ;; keycast -(use-package keycast) +(my-use-package keycast) ;; spell checker -(unless *is-windows* - (use-package jinx - :delight - (jinx-mode " Jinx" jinx) - :bind - ([remap ispell-word] . jinx-correct) - :config - (setq jinx-languages "en_US") - (add-to-list 'jinx-exclude-regexps '(t "\\cc")) - (dolist (range '((#x4E00 . #x9FFF) - (#x3400 . #x4DBF) - (#x3000 . #x303F) - (#xFF00 . #xFFEF) - (#x20000 . #x2A6DF))) - (let ((start (car range)) - (end (cdr range))) - (dotimes (i (- end start)) - (modify-syntax-entry (+ start i) "_" jinx--syntax-table))))) - - (use-package consult-jinx - :straight - (consult-jinx :type git - :repo "https://git.trogloxene.org/consult-jinx.git"))) +(my-use-package jinx (not *is-windows*) + :delight + (jinx-mode " Jinx" jinx) + :bind + ([remap ispell-word] . jinx-correct) + :config + (setq jinx-languages "en_US") + (add-to-list 'jinx-exclude-regexps '(t "\\cc")) + (dolist (range '((#x4E00 . #x9FFF) + (#x3400 . #x4DBF) + (#x3000 . #x303F) + (#xFF00 . #xFFEF) + (#x20000 . #x2A6DF))) + (let ((start (car range)) + (end (cdr range))) + (dotimes (i (- end start)) + (modify-syntax-entry (+ start i) "_" jinx--syntax-table))))) + +(my-use-package consult-jinx (not *is-windows*) + :straight + (consult-jinx :type git + :repo "https://git.trogloxene.org/consult-jinx.git")) ;; terminal emulator -(use-package ghostel +(my-use-package ghostel :hook (eshell-load . ghostel-eshell-visual-command-mode) (ghostel-mode . (lambda () (cns-mode -1))) @@ -49,7 +48,7 @@ Like normal Emacs `C-k'. Kill to end of line and put content in kill-ring." ghostel-ssh-install-terminfo t) (defalias 'eshell/v 'eshell/ghostel)) -(use-package consult-ghostel +(my-use-package consult-ghostel :straight (consult-ghostel :type git :files @@ -58,15 +57,13 @@ Like normal Emacs `C-k'. Kill to end of line and put content in kill-ring." :repo "dakra/ghostel")) ;; eshell-syntax-highlighting -(use-package eshell-syntax-highlighting +(my-use-package eshell-syntax-highlighting :hook (eshell-mode . eshell-syntax-highlighting-global-mode) (eshell-mode . (lambda () (setenv "TERM" "xterm-256color")))) ;; workspace -(use-package perspective - :custom - (persp-mode-prefix-key (kbd "C-c p")) +(my-use-package perspective :hook (after-init . persp-mode) :config @@ -142,6 +139,7 @@ With a prefix ARG create a new *scratch* buffer." (dolist (buf buffers) (persp-set-buffer buf)))) + (setopt persp-mode-prefix-key (kbd "C-c p")) (setq persp-switch-to-buffer-behavior 'switch persp-sort 'oldest) (with-eval-after-load 'consult @@ -155,7 +153,7 @@ With a prefix ARG create a new *scratch* buffer." (setq persp-initial-frame-name "main")) ;; magit -(use-package magit +(my-use-package magit :commands my-magit-toggle-parent-section :config (defun my-magit-toggle-parent-section () @@ -169,7 +167,7 @@ With a prefix ARG create a new *scratch* buffer." (setq magit-diff-refine-hunk 'all))) ;; ediff -(use-package ediff +(my-use-package ediff :straight nil :hook ((ediff-prepare-buffer . outline-show-all) (ediff-quit . winner-undo)) @@ -178,14 +176,14 @@ With a prefix ARG create a new *scratch* buffer." ediff-split-window-function 'split-window-horizontally)) ;; diff-hl -(use-package diff-hl +(my-use-package diff-hl :hook (diff-hl-mode . diff-hl-margin-mode) (diff-hl-mode . global-diff-hl-show-hunk-mouse-mode) (diff-hl-mode . diff-hl-flydiff-mode)) ;; vc -(use-package vc +(my-use-package vc :straight nil :commands vc-create-repo :config @@ -215,7 +213,7 @@ against its previous revision." (rev vc-buffer-revision)) (vc-print-log-internal vc-annotate-backend file rev t 1))))) -(use-package consult-vc +(my-use-package consult-vc :straight (consult-vc :type git :repo "https://git.trogloxene.org/consult-vc.git") @@ -224,7 +222,7 @@ against its previous revision." consult-vc-annotate-revision-narrow-key-backward ?\[)) ;; project -(use-package project +(my-use-package project :straight nil :config (setq project-switch-commands (assq-delete-all 'project-vc-dir project-switch-commands)) @@ -238,13 +236,13 @@ against its previous revision." (project-ibuffer "Ibuffer" ?i) (pilish "Pi" ?a)))))) -(use-package project-ibuffer +(my-use-package project-ibuffer :straight (project-ibuffer :type git :repo "https://git.trogloxene.org/project-ibuffer.git")) ;; emms -(use-package emms +(my-use-package emms :commands (emms-playlist-mode-switch-buffer) :config @@ -254,10 +252,10 @@ against its previous revision." (emms-history-load)) ;; tokei -(use-package tokei) +(my-use-package tokei) ;; helpful -(use-package helpful +(my-use-package helpful :straight (helpful :fork (:type git :repo "https://git.trogloxene.org/helpful.git")) :bind @@ -298,27 +296,26 @@ against its previous revision." (helpful-update)))))))) ;; typing game -(use-package typit) +(my-use-package typit) ;; z-machine interpreter -(use-package malyon +(my-use-package malyon :straight (malyon :fork (:host github :repo "cjennings/malyon"))) ;; guix -(if *is-linux* - (use-package guix)) +(my-use-package guix *is-linux*) ;; process manager -(use-package proced +(my-use-package proced :straight nil - :custom - (proced-auto-update-flag (if *is-windows* nil t)) - (proced-goal-attribute nil) - (proced-show-remote-processes t) - (proced-enable-color-flag t) - (proced-format 'custom) :config + (setopt proced-auto-update-flag (if *is-windows* nil t) + proced-goal-attribute nil + proced-show-remote-processes t + proced-enable-color-flag t + proced-format 'custom) + (add-to-list 'proced-format-alist (if *is-mac* @@ -335,18 +332,17 @@ Prefix ARG controls sort order, see `proced-sort-interactive'." (general-def proced-mode-map "s r" #'proced-sort-rss)) ;; syncthing -(use-package syncthing +(my-use-package syncthing :hook (syncthing-mode . enable-truncate-lines)) ;; pinentry -(if *is-linux* - (use-package pinentry - :hook - (after-init . pinentry-start))) +(my-use-package pinentry *is-linux* + :hook + (after-init . pinentry-start)) ;; pass -(use-package pass +(my-use-package pass :config (defvar my-pass-meta-fields '("url" "username" "email") "List of pass metadata fields for completion.") @@ -392,7 +388,7 @@ Prefix ARG controls sort order, see `proced-sort-interactive'." "e" #'my-pass-copy-email)) ;; hyperbole -(use-package hyperbole +(my-use-package hyperbole :straight (hyperbole :type git :host github :repo "rswgnu/hyperbole") :defer 5 :delight @@ -400,13 +396,12 @@ Prefix ARG controls sort order, see `proced-sort-interactive'." (hyperbole-mode nil hyperbole) :bind (("C-h h" . hyperbole)) - :custom - (hsys-org-enable-smart-keys :buttons) :config + (setq hsys-org-enable-smart-keys :buttons) (hyperbole-mode 1)) ;; elfeed -(use-package elfeed +(my-use-package elfeed :config (defun my-elfeed-search-preview-other-window () "Preview currently selected elfeed entry in another window." @@ -421,10 +416,10 @@ Prefix ARG controls sort order, see `proced-sort-interactive'." (setq-default elfeed-search-filter "")) ;; posframe -(use-package posframe) +(my-use-package posframe) ;; translator -(use-package gt +(my-use-package gt :bind (([remap gt-buffer-render--keyboard-quit] . keyboard-quit)) :config @@ -435,7 +430,7 @@ Prefix ARG controls sort order, see `proced-sort-interactive'." :render (gt-posframe-pin-render)))) ;; thesaurus -(use-package synosaurus +(my-use-package synosaurus :autoload my-synosaurus-lookup :config (defun my-synosaurus-lookup (arg) diff --git a/lisp/init-prog.el b/lisp/init-prog.el @@ -32,7 +32,7 @@ (when (boundp 'eval-expression-minibuffer-setup-hook) (add-hook 'eval-expression-minibuffer-setup-hook #'eldoc-mode)) -(use-package ielm +(my-use-package ielm :straight nil :commands my-switch-to-ielm my-repl-switch-back :config @@ -58,13 +58,13 @@ (error "No original buffer")))) ;; hideshow -(use-package hideshow +(my-use-package hideshow :straight nil :hook (prog-mode . hs-minor-mode)) ;; xref -(use-package xref +(my-use-package xref :straight nil :autoload xref-show-definitions-completing-read :init @@ -75,33 +75,33 @@ xref-show-xrefs-function #'xref-show-definitions-completing-read)) ;; eglot -(use-package eglot +(my-use-package eglot :config (setq eglot-send-changes-idle-time 0.25)) ;; syntax checking -(use-package flycheck) +(my-use-package flycheck) -(use-package flycheck-guile +(my-use-package flycheck-guile :hook (scheme-mode . (lambda () (require 'flycheck-guile)))) -(use-package consult-flycheck) +(my-use-package consult-flycheck) ;; scheme -(use-package geiser +(my-use-package geiser :config (setq geiser-default-implementation 'guile)) -(use-package geiser-guile) +(my-use-package geiser-guile) ;; common-lisp -(use-package sly +(my-use-package sly :config (setq sly-lisp-implementations nil)) ;; markdown -(use-package markdown-mode +(my-use-package markdown-mode :hook (markdown-mode . visual-line-mode) :config @@ -118,10 +118,10 @@ (setq markdown-command "multimarkdown" markdown-fontify-code-blocks-natively t)) -(use-package edit-indirect) +(my-use-package edit-indirect) ;; caddy -(use-package caddyfile-mode +(my-use-package caddyfile-mode :mode "Caddyfile\\'" "caddy\\.conf\\'") ;; some modes diff --git a/lisp/init-segmentation.el b/lisp/init-segmentation.el @@ -5,7 +5,9 @@ ;;; Code: ;; emacs-chinese-word-segmentation -(use-package cns +(my-use-package cns + (or (file-exists-p "h:/emacs/emacs-chinese-word-segmentation/") + (file-exists-p "~/emacs-stuff/emacs-chinese-word-segmentation/")) :straight nil :hook (after-init . require-cns) diff --git a/lisp/init-ui.el b/lisp/init-ui.el @@ -11,7 +11,7 @@ (setq custom-safe-themes t) ;; solarized -(use-package solarized-theme +(my-use-package solarized-theme :straight (solarized-emacs :fork @@ -28,7 +28,7 @@ ;; color picker ;; from zHaOdANiuu's ElegantEmacs -(use-package color-picker +(my-use-package color-picker :straight (:type git :host github :repo "zHaOdANiuu/color-picker.el") :commands color-picker my-pick-color :config @@ -46,7 +46,7 @@ (delete-region (region-beginning) (region-end))) (insert color))))))) -(use-package colorful-mode +(my-use-package colorful-mode :hook (prog-mode . colorful-mode) :commands my-colorful-color-picker :config @@ -113,7 +113,7 @@ from `readable-foreground-color'." (overlay-put ov 'face nil))))) ;; line numbers -(use-package display-line-numbers +(my-use-package display-line-numbers :straight nil :hook ((prog-mode @@ -126,7 +126,7 @@ from `readable-foreground-color'." display-line-numbers-width-start 4)) ;; whitespace -(use-package whitespace +(my-use-package whitespace :straight nil :config (defun my-show-trailing-whitespace () @@ -137,7 +137,7 @@ from `readable-foreground-color'." (add-hook hook 'my-show-trailing-whitespace))) ;; resize margins -(use-package olivetti +(my-use-package olivetti :delight :hook (text-mode . olivetti-mode) @@ -146,34 +146,32 @@ from `readable-foreground-color'." (setq olivetti-body-width 85)) ;; a simple mode-line for mobile device -(if *is-android* - (use-package simple-modeline - :hook - (after-init . simple-modeline-mode))) +(my-use-package simple-modeline *is-android* + :hook + (after-init . simple-modeline-mode)) ;; highlight current line -(use-package hl-line +(my-use-package hl-line :straight nil :hook (after-init . global-hl-line-mode)) ;; display time in mode line -(unless *is-android* - (use-package time - :straight nil - :hook - (persp-mode . display-time-mode) - :config - (setq display-time-default-load-average nil - display-time-string-forms - '((propertize - (concat - (propertize (format-time-string " %I:%M") 'face 'display-time-date-and-time) - (propertize (format-time-string "-%p") 'face 'font-lock-comment-face)) - 'help-echo (format-time-string "%A, %B %d, %Y")))))) +(my-use-package time (not *is-android*) + :straight nil + :hook + (persp-mode . display-time-mode) + :config + (setq display-time-default-load-average nil + display-time-string-forms + '((propertize + (concat + (propertize (format-time-string " %I:%M") 'face 'display-time-date-and-time) + (propertize (format-time-string "-%p") 'face 'font-lock-comment-face)) + 'help-echo (format-time-string "%A, %B %d, %Y"))))) ;; easier to setup fonts -(use-package cnfonts +(my-use-package cnfonts :hook (after-init . cnfonts-mode) :init diff --git a/lisp/init-window.el b/lisp/init-window.el @@ -4,12 +4,12 @@ ;;; Code: -(use-package window +(my-use-package window :straight nil :config (setq switch-to-buffer-obey-display-actions t)) -(use-package popper +(my-use-package popper :defines popper-echo-dispatch-actions :commands @@ -143,7 +143,7 @@ (advice-add #'keyboard-quit :before #'popper-close-window-hack))) ;; windmove -(use-package windmove +(my-use-package windmove :straight nil :hook (after-init . windmove-swap-states-default-keybindings))