commit cc135cb062f82c5fb5b8991e79f86c13f4b941d8
parent 1e191e039883bc920726249823fe6535b9171319
Author: andsy10 <andsy1016@gmail.com>
Date: Wed, 14 Oct 2026 02:40:35 +0800
Optimize configuration
Diffstat:
14 files changed, 70 insertions(+), 48 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -8,5 +8,4 @@
!.gitignore
-/lisp/init-proxy.el
/lisp/init-local.el
diff --git a/early-init.el b/early-init.el
@@ -4,7 +4,6 @@
;;; Code:
-;; from centaur emacs
(if noninteractive
(setq gc-cons-threshold #x8000000
gc-cons-percentage 1.0)
@@ -20,6 +19,7 @@
(when (file-exists-p benchmark-init-dir)
(add-to-list 'load-path benchmark-init-dir)
(require 'benchmark-init)
+ (setq benchmark-init/backtrace-node-types '(require load))
(benchmark-init/activate)))
(setq package-enable-at-startup nil)
diff --git a/init.el b/init.el
@@ -1,7 +1,9 @@
;;; init.el --- init.el -*- lexical-binding: t -*-
;;; Commentary:
+
;; trogloxene's Emacs
+;; https://trogloxene.org
;;; Code:
diff --git a/lisp/init-base.el b/lisp/init-base.el
@@ -64,8 +64,7 @@
:hook
(after-init . savehist-mode)
:init
- (setq enable-recursive-minibuffers t
- history-length 50
+ (setq history-length 50
savehist-additional-variables '(mark-ring
global-mark-ring
search-ring
@@ -126,15 +125,18 @@
(mode . sh-mode)
(mode . bat-mode)))
("Config" (or
+ (name . "\\.\\(toml\\|ya?ml\\|ini\\|cfg\\|conf\\|gitignore\\)$")
(mode . conf-mode)
(mode . conf-desktop-mode)
(mode . conf-toml-mode)
(mode . conf-xdefaults-mode)
(mode . conf-javaprop-mode)
- (mode . conf-unix-mode)
- (mode . toml-ts-mode)
- (mode . yaml-ts-mode)
- (mode . json-ts-mode)))
+ (mode . conf-unix-mode)))
+ ("Web" (or (name . "\\.\\(html?\\|xml\\|css\\|s[ac]ss\\|less\\|jsx?\\|tsx?\\|json\\|md\\)$")))
+ ("LSP" (or (name . "\\*EGLOT")
+ (name . "\\*Flycheck")
+ (derived-mode . eglot--managed-mode)))
+ ("C/C++" (name . "\\.\\(c\\|cpp\\|cc\\|h\\|hpp\\|cppm\\|ixx\\)$"))
("Elisp" (or (mode . emacs-lisp-mode)
(filename . ".\\.eld")))
("Emacs" (or (mode . emacs-lisp-compilation-mode)
@@ -182,6 +184,7 @@
(mode . magit-refs-mode)
(mode . vc-annotate-mode)
(name . "^\\*vc")))
+ ("Assets" (or (name . "\\.\\(png\\|jpe?g\\|svg\\|webp\\|bpm\\|ppm\\|mp[34]\\|mov\\|avi\\|obj\\)$")))
("Directories" (or
(mode . dired-mode)
(name . "^*dirvish")
@@ -195,6 +198,7 @@
(name . "\\*elfeed-")))
("AI" (or
(predicate (lambda () (memq 'gptel-mode local-minor-modes)))
+ (name . "^\\*gptel-")
(name . "^\\*pilish")))
("Calc" (or
(mode . calc-mode)
@@ -316,7 +320,13 @@
;; isearch
(my-use-package isearch
:straight nil
- :init
+ :hook
+ (isearch-mode-end . my-goto-match-beginning)
+ :config
+ (defun my-goto-match-beginning ()
+ (when (and isearch-forward (not isearch-mode-end-hook-quit))
+ (goto-char isearch-other-end)))
+
;; move lazy count numbers to mode-line
(setq isearch-lazy-count t
lazy-count-prefix-format nil)
diff --git a/lisp/init-completion.el b/lisp/init-completion.el
@@ -13,7 +13,8 @@
;; minibuffer completion
(my-use-package vertico
:hook
- (after-init . vertico-mode))
+ (after-init . vertico-mode)
+ (vertico-mode . vertico-mouse-mode))
;; orderless completion
(my-use-package orderless
@@ -104,6 +105,7 @@ With prefix ARG, search for all agenda headings."
(advice-add #'register-preview :override #'consult-register-window)
(with-eval-after-load 'consult-register
+ ;; the default setting can't handle deleted buffers
(cl-defmethod consult-register--describe ((val (head buffer)))
"Describe buffer register VAL."
(let* ((buf (cdr val))
@@ -131,12 +133,14 @@ With prefix ARG, search for all agenda headings."
"\\*Chinese-word-segmentation\\*"
"\\*gptel-reasoning\\*"
"\\*gptel-log\\*"
+ "\\*gptel-contex\\t*"
"\\*pilish-input:"
"\\*pilish-sessions:"
"\\*pilish-tree:"
"\\*Synonyms List\\*"
"\\*Wordnet\\*"
- "*Async-native-compile-log*")
+ "*Async-native-compile-log*"
+ "^\\*EGLOT")
:test 'equal)))
;; right-click
diff --git a/lisp/init-custom.el b/lisp/init-custom.el
@@ -29,7 +29,7 @@
(defcustom my-blog-directory
(if *is-windows* "h:/emacs/blog/posts/" "~/org/blog/posts/")
- "My blog directory"
+ "My blog directory."
:type 'string
:group 'trogloxene)
@@ -46,10 +46,11 @@
:type 'string
:group 'trogloxene))
-(defcustom my-frame-parameter 'fullscreen
+(defcustom my-frame-parameter nil
"Frame parameter on startup."
- :type '(choice (const :tag "Fullscreen" fullscreen)
- (const :tag "Maximized" maximized))
+ :type '(choice (const :tag "nil" nil)
+ (const :tag "Maximized" maximized)
+ (const :tag "Fullscreen" fullscreen))
:group 'trogloxene)
(defcustom my-cns-dir
diff --git a/lisp/init-exwm.el b/lisp/init-exwm.el
@@ -90,7 +90,7 @@
?\M-]
?\s-[
?\s-]
- ?\s-
+ ?\s- ;don't delete the whitespace
XF86AudioLowerVolume
XF86AudioRaiseVolume
XF86AudioMute
diff --git a/lisp/init-gptel.el b/lisp/init-gptel.el
@@ -18,7 +18,7 @@
:name "read_buffer" ; javascript-style snake_case name
:function (lambda (buffer) ; the function that will run
(unless (buffer-live-p (get-buffer buffer))
- (error "error: buffer %s is not live." buffer))
+ (error "Error: buffer %s is not live" buffer))
(with-current-buffer buffer
(buffer-substring-no-properties (point-min) (point-max))))
:description "return the contents of an emacs buffer"
diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el
@@ -60,9 +60,10 @@
"<mouse-2>" #'xref-find-definitions-at-mouse
"C-M-;" #'avy-goto-char
"C-M-'" #'avy-goto-word-1
- "M-g g" #'avy-goto-line
+ "M-g M-g" #'avy-goto-line
+ "M-g g" #'consult-goto-line
"C-c s" #'consult-line
- "M-g M-g" #'consult-goto-line
+ "C-c S" #'consult-line-multi
"M-g i" #'consult-imenu
"M-g I" #'consult-imenu-multi
"M-g M-i" #'consult-imenu
@@ -73,11 +74,13 @@
"C-M-<down>" #'shrink-window
"C-M-<up>" #'enlarge-window
"M-`" #'popper-toggle
+ "C-M--" #'popper-toggle-type
"C-M-=" #'my-popper-toggle-type-delete-other-window
"M-o" #'other-window
"M-O" #'other-window-backward
;; other
+ "C-h h" #'hyperbole
"C-x r b" #'consult-bookmark
"C-;" #'embark-act
"M-s M-b" #'eww-list-bookmarks
@@ -141,7 +144,8 @@
"TAB" #'my-elfeed-search-preview-other-window)
;; emacs-lisp-mode
-(general-def emacs-lisp-mode-map "C-c C-z" #'my-switch-to-ielm)
+(general-def emacs-lisp-mode-map
+ "C-c C-z" #'my-switch-to-ielm)
;; embark
(general-def embark-file-map
@@ -208,11 +212,15 @@
"C-c C-s" #'my-gptel-save-session
"C-c C-k" #'gptel-abort)
+;; help
+(general-def (help-mode-map helpful-mode-map)
+ "p" #'previous-line
+ "n" #'next-line)
+
;; hs-hide-mode
(general-def hs-minor-mode-map
"C-c h" #'hs-toggle-hiding
- "C-c H" #'hs-hide-all
- "C-c S" #'hs-show-all)
+ "C-c H" #'hs-toggle-all)
;; ibuffer
(general-def ibuffer-mode-map
@@ -229,7 +237,8 @@
"M-n" #'forward-paragraph)
;; lisp-interaction-mode
-(general-def lisp-interaction-mode-map "C-c C-z" #'my-switch-to-ielm)
+(general-def lisp-interaction-mode-map
+ "C-c C-z" #'my-switch-to-ielm)
;; magit
(general-def (magit-mode-map tokei-mode-map)
@@ -405,12 +414,11 @@
"s" #'my-consult-org-agenda
"C" #'calendar
"c" #'org-capture
- "d" #'denote
- "D" #'denote-date
+ "n" #'denote
+ "N" #'denote-date
"r" #'denote-rename-file-identifier
"b" #'my-denote-find-backlink-with-location
"R" #'denote-rename-file
- "m" #'my-denote-open-metanote
"q" #'org-ql-search)
;; p for project
@@ -446,7 +454,7 @@
"g" #'gptel-mode
"h" #'global-diff-hl-mode
"k" #'keycast-header-line-mode
- "t" #'vcursor-use-vcursor-map)
+ "v" #'vcursor-use-vcursor-map)
;; u for ui
(general-def
diff --git a/lisp/init-package.el b/lisp/init-package.el
@@ -51,10 +51,9 @@ Like normal Emacs `C-k'. Kill to end of line and put content in kill-ring."
(my-use-package consult-ghostel
:straight
(consult-ghostel :type git
- :files
- ("extensions/consult-ghostel/")
:host github
- :repo "dakra/ghostel"))
+ :repo "dakra/ghostel"
+ :files ("extensions/consult-ghostel/")))
;; shell
(my-use-package shell
@@ -86,7 +85,7 @@ Like normal Emacs `C-k'. Kill to end of line and put content in kill-ring."
(eshell-mode . (lambda () (setenv "TERM" "xterm-256color"))))
;; environment sync
-(my-use-package exec-path-from-shell
+(my-use-package exec-path-from-shell (not *is-windows*)
:hook
(after-init . exec-path-from-shell-initialize))
diff --git a/lisp/init-prog.el b/lisp/init-prog.el
@@ -86,7 +86,14 @@
(setq eglot-send-changes-idle-time 0.25))
;; syntax checking
-(my-use-package flycheck)
+(my-use-package flycheck
+ :hook
+ (prog-mode . flycheck-mode)
+ :config
+ (global-flycheck-eglot-mode)
+ :bind
+ (:map flycheck-command-map
+ ("a" . flycheck-annotate-mode)))
(my-use-package flycheck-guile
:hook
diff --git a/lisp/init-startup.el b/lisp/init-startup.el
@@ -19,7 +19,8 @@
(setq system-time-locale "C")
;; fullscreen
-(set-frame-parameter nil 'fullscreen my-frame-parameter)
+(add-hook 'emacs-startup-hook
+ (lambda () (set-frame-parameter nil 'fullscreen my-frame-parameter)))
;; set lisp files directory
(setq user-lisp-directory (concat user-emacs-directory "lisp/"))
@@ -80,6 +81,8 @@
(put 'narrow-to-region 'disabled nil)
(put 'scroll-left 'disabled nil)
+(setq enable-recursive-minibuffers t)
+
;; modifier keys on mac
(when *is-emacs-mac-port*
(setq mac-command-modifier 'meta)
diff --git a/lisp/init-terminal.el b/lisp/init-terminal.el
@@ -37,17 +37,6 @@
(setq ring-bell-function 'ignore)
-(cond
- ((or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
- (add-to-list 'exec-path (expand-file-name "H/appppppppppp/scoop/apps/"))
- (setenv "PATH" (concat (expand-file-name "H/appppppppppp/scoop/apps/") ";" (getenv "PATH"))))
- ((eq system-type 'darwin)
- (add-to-list 'exec-path (expand-file-name "/opt/homebrew/bin/"))
- (setenv "PATH" (concat (expand-file-name "/opt/homebrew/bin/") ":" (getenv "PATH"))))
- ((eq system-type 'gnu/linux)
- (add-to-list 'exec-path (expand-file-name "~/.guix-home/profile/bin/"))
- (setenv "PATH" (concat (expand-file-name "~/.guix-home/profile/bin/") ":" (getenv "PATH")))))
-
(delete-selection-mode 1)
(setq initial-scratch-message
@@ -115,9 +104,6 @@
;; display column number in mode line
(column-number-mode 1)
-;; highlight current line
-(global-hl-line-mode 1)
-
;; mouse support
(xterm-mouse-mode 1)
@@ -183,7 +169,8 @@
`(diff-refine-removed ((t (:foreground "#e7917f" :background "#5c3225"))))
`(xref-file-header ((t (:foreground ,my-base01))))
`(xref-line-number ((t (:foreground ,my-green))))
- `(match ((t (:foreground ,my-base1 :background ,my-base02 :weight bold))))))
+ `(match ((t (:foreground ,my-base1 :background ,my-base02 :weight bold)))))
+ (global-hl-line-mode 1))
(defun my-open-init-file()
"Open user's init.el file."
diff --git a/lisp/my-theme.el b/lisp/my-theme.el
@@ -34,6 +34,8 @@
`(trailing-whitespace ((,class (:foreground ,orange-lc :inverse-video t))))
+ `(vcursor ((,class (:foreground ,cyan :underline t :inverse-video t))))
+
`(outline-1 ((,class (:foreground ,orange :height 1.0 :weight normal))))
`(outline-2 ((,class (:foreground ,blue :height 1.0 :weight normal))))
`(outline-3 ((,class (:foreground ,green :height 1.0 :weight normal))))