refactor(config): Clean up and reorganize Emacs configuration

Remove unused packages (EMMS, jinx, god-mode), simplify terminal
setup with ido instead of vertico/orderless, and reorganize
keybindings. Add new packages (debase, discomfort, git-timemachine,
edit-indirect) and improve EXWM, dired, and theme
configurations. Move restart-fcitx5 to kbd-func and update Linux
PATH for Guix.
This commit is contained in:
2026-05-30 22:59:25 +08:00
parent 42c3e3600c
commit ccd5c085f8
19 changed files with 143 additions and 226 deletions

View File

@@ -17,6 +17,4 @@
(setq frame-background-mode 'dark)
(setq package-enable-at-startup nil)
;;; early-init.el ends here

View File

@@ -19,7 +19,6 @@
(require 'init-startup)
(require 'init-elpa)
(require 'init-package)
(require 'init-emms)
(require 'init-org)
(require 'init-prog)
(require 'init-completion)

View File

@@ -1,4 +1,4 @@
;;; init-jinx.el --- Jinx configuration with consult-jinx -*- lexical-binding: t -*-
;;; consult-jinx.el --- Jinx configuration with consult-jinx -*- lexical-binding: t -*-
;;; Commentary:
;; Jinx spell-checker configuration with consult-jinx menu
@@ -76,6 +76,6 @@
:lookup #'consult--lookup-candidate
:state (consult--jump-state)))
(provide 'init-jinx)
(provide 'consult-jinx)
;;; init-jinx.el ends here
;;; consult-jinx.el ends here

View File

@@ -17,7 +17,8 @@
dired-recursive-deletes 'always
dired-recursive-copies 'always
dired-mouse-drag-files t
mouse-drag-and-drop-region-cross-program t)
mouse-drag-and-drop-region-cross-program t
dired-compress-file-default-suffix ".zip")
(put 'dired-find-alternate-file 'disabled nil))
;; dirvish

View File

@@ -1,104 +0,0 @@
;;; init-emms.el --- emms -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(use-package emms
:init
;; 设置音乐文件默认目录
(when *is-windows*
(setq emms-source-file-default-directory "F:/luping26-1-11/"))
:config
;; --- 基础设置 ---
(require 'emms-setup)
(emms-all) ; 加载所有稳定功能
;; 使用简单模式的 mpv 播放器
;; 移除默认的 emms-player-mpv
(require 'emms-player-simple)
;; 定义简单的 mpv 播放器
(define-emms-simple-player mpv-simple '(file url streamlist playlist)
(concat "\\.\\("
(mapconcat 'identity
'("mp3" "mp4" "avi" "mkv" "flv" "mov" "wmv" "webm"
"ogg" "ogv" "oga" "ogx"
"flac" "wav" "aac" "m4a" "wma"
"mpg" "mpeg" "mpe" "mpv"
"3gp" "3g2"
"m3u" "pls")
"\\|")
"\\)\\'\\|http[s]?://")
"mpv"
"--force-window=immediate"
"--keep-open=yes"
"--fs=no"
"--quiet")
;; 设置播放器列表
(setq emms-player-list '(emms-player-mpv-simple
emms-player-vlc
emms-player-mplayer))
(setq emms-playlist-default-playlist-name "*EMMS Playlist*")
(setq emms-playlist-buffer-name "*EMMS Playlist*")
;; 使用更快的文件查找方法(windows上需要使用internal)
;; (setq emms-source-file-directory-tree-function 'emms-source-file-directory-tree-find)
(setq emms-source-file-directory-tree-function 'emms-source-file-directory-tree-internal)
;; 使用原生 Elisp 元数据读取器
(setq emms-info-functions '(emms-info-native))
;; 异步读取元数据
(setq emms-info-asynchronously t)
;; 使用更详细的曲目描述
(setq emms-track-description-function #'emms-info-track-description)
;; 模式行设置
(require 'emms-mode-line)
(emms-mode-line-mode 1)
(emms-mode-line-blank) ; 初始为空
;; 自定义模式行格式
(setq emms-mode-line-format " [%s] ")
(setq emms-mode-line-length-limit 60)
;; 播放时间显示
(require 'emms-playing-time)
(emms-playing-time-mode 1)
;; 添加(playlist中的)快捷键
(define-key emms-playlist-mode-map (kbd "SPC") 'emms-pause)
(define-key emms-playlist-mode-map (kbd "N") 'emms-next)
(define-key emms-playlist-mode-map (kbd "P") 'emms-previous)
(define-key emms-playlist-mode-map (kbd "R") 'emms-random)
(define-key emms-playlist-mode-map (kbd "/") 'emms-playlist-limit)
;; 启用播放列表排序
(require 'emms-playlist-sort)
(define-key emms-playlist-mode-map (kbd "S s") 'emms-playlist-sort-map)
;; 启动后自动恢复播放列表
;; (add-hook 'after-init-hook 'emms-history-load)
;; 显示加载完成消息
(message "EMMS loaded")
;; 关闭自动连播
(add-hook 'emms-playlist-mode-hook
(lambda ()
(setq emms-single-track t))))
(defun my-emms-play-directory (dir)
"Play all files in directory.."
(interactive "Dchoose a directory: ")
(emms-play-directory-tree dir)
(message "playing: %s" dir))
(provide 'init-emms)
;;; init-emms.el ends here

View File

@@ -15,15 +15,6 @@
(let ((display-buffer-alist
'((".*" . (display-buffer-no-window . nil)))))
(async-shell-command command))))
(defun restart-fcitx5 ()
"Kill and restart fcitx5, to fix random issues in exwm."
(interactive)
(if (zerop (shell-command "pgrep fcitx5"))
(progn
(eshell-command "pkill fcitx5")
(eshell-command "fcitx5 -d"))
(eshell-command "fcitx5 -d")))
(defun my--exwm-switch-to-workspace (delta)
(let ((target
@@ -113,7 +104,6 @@
(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)
@@ -121,15 +111,14 @@
(exwm-wm-mode))
(use-package desktop-environment
:after exwm
:init
(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")
@@ -152,7 +141,20 @@
(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)))))))
(append consult-buffer-sources '(xdg-launcher-consult-source))))))
(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")))
(provide 'init-exwm)

View File

@@ -108,11 +108,6 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog
(interactive)
(align-regexp (region-beginning) (region-end) "\\(\\s-*\\)::" 1 1 nil))
(defun switch-to-emms-playlist()
"Switch to emms playlist."
(interactive)
(switch-to-buffer "*EMMS Playlist*"))
(defun my/dired-next-line()
"Move to forward line in dired buffer"
(interactive)
@@ -188,7 +183,16 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog
(unless (zerop (shell-command "pgrep -x mihomo"))
(start-process-shell-command "mihomo" nil "mihomo -d ~/.config/mihomo/"))
(start-process-shell-command "xrandr-refresh" nil "xrandr --output DP-4 --mode 2560x1440 --rate 165.00")
(start-process-shell-command "xinput" nil "xinput set-prop 12 'libinput Accel Speed' -0.45")))
(start-process-shell-command "xinput" nil "xinput set-prop 12 'libinput Accel Speed' -0.45"))
(defun restart-fcitx5 ()
"Kill and restart fcitx5, to fix random issues in exwm."
(interactive)
(if (zerop (shell-command "pgrep fcitx5"))
(progn
(eshell-command "pkill fcitx5")
(eshell-command "fcitx5 -d"))
(eshell-command "fcitx5 -d"))))
(provide 'init-kbd-func)

View File

@@ -53,7 +53,7 @@
:prefix "C-c f"
"r" 'consult-recent-file
"f" 'consult-fd
"g" 'consult-ripgrep-project
"g" 'consult-ripgrep
"e" 'consult-flycheck
"l" 'consult-locate
"h" 'consult-fd-home
@@ -67,7 +67,7 @@
;; t for modes toggle
(general-def
:prefix "C-c t"
"f" 'global-flycheck-mode
"f" 'flycheck-mode
"j" 'my/jinx-smart-toggle
"g" 'gptel-mode)
@@ -102,17 +102,22 @@
"n" 'emms-next
"p" 'emms-previous
"b" 'emms-browser
"s" 'emms-start
"q" 'emms-stop
"P" 'emms-pause
"S" 'emms-toggle-single-track
"l" 'switch-to-emms-playlist
"d" 'my-emms-play-directory)
"l" 'emms-playlist-mode-switch-buffer
"d" 'emms-play-directory)
;; d for dired
(general-def
:prefix "C-c d"
"a" 'dirvish-quick-access
"s" 'dirvish-side
"h" 'dirvish-history-menu)
"h" 'dirvish-history-menu
"f" 'dirvish-fd
"F" 'dirvish-fd-switches-menu
"t" 'trashed)
;; scratch buffer
(if *is-mac*
@@ -186,6 +191,11 @@
(general-def minibuffer-local-map
"C-c C-e" 'embark-export)
;; completion
(general-def completion-list-mode-map
"M-n" 'minibuffer-next-completion
"M-p" 'minibuffer-previous-completion)
;; markdown
(general-def markdown-mode-map
"M-p" nil
@@ -198,7 +208,7 @@
"C-c t l" 'org-toggle-link-display
"M-{" 'org-previous-visible-heading
"M-}" 'org-next-visible-heading
"C-," 'duplicate-and-move-to-next-line
"C-," 'crux-duplicate-current-line-or-region
"C-c o l" 'denote-link
"C-c o L" 'denote-org-link-to-heading
"C-c o b" 'denote-backlinks
@@ -227,7 +237,8 @@
;; emms
(general-def emms-playlist-mode-map
"<prior>" 'emms-previous
"<next>" 'emms-next)
"<next>" 'emms-next
"C-c C-s" 'emms-history-save)
;; perspective
(general-def persp-mode-map
@@ -235,9 +246,14 @@
"C-c p d" 'persp-kill
"C-x M-b" 'persp-ibuffer)
;; visual-line
(general-def visual-line-mode-map
"C-k" 'kill-visual-line)
;; info
(general-def Info-mode-map
"M-n" 'forward-paragraph)
;; discomfort
(general-def discomfort-mode-map
"p" 'previous-line
"P" 'discomfort-poweroff)
;; global map with C-c prefix
(general-def
@@ -253,7 +269,6 @@
"k" 'comment-line
"K" 'comment-kill
"E" 'eshell
"C-t" 'trashed
"C-s" 'consult-focus-lines)
;; global map
@@ -323,6 +338,8 @@
"C-x r b" 'consult-bookmark
"C-x p b" 'consult-project-buffer
"C-x p E" 'eat-project
"C-x p r" 'consult-ripgrep-project
"C-x p R" 'project-query-replace-regexp
"C-;" 'embark-act)
(when *is-android*

View File

@@ -53,6 +53,8 @@
;; org-babel scheme
(use-package ob-scheme
:demand t
:after org
:straight nil
:config
(add-to-list 'org-babel-load-languages '(scheme . t))

View File

@@ -224,20 +224,32 @@ targets."
(mode . sh-mode)
(mode . lua-mode)
(mode . bat-mode)))
("Config" (or
(mode . conf-mode)
(mode . conf-desktop-mode)
(mode . conf-toml-mode)))
("Elisp" (mode . emacs-lisp-mode))
("Scheme" (or
(mode . scheme-mode)
(name . "^*Geiser")))
(mode . scheme-mode)))
("Geiser" (or
(name . "^Geiser")
(mode . geiser-repl-mode)
(mode . geiser-debug-mode)
(mode . geiser-messages-mode)
(mode . geiser-debug-mode)
(mode . geiser-doc-mode)
(mode . geiser-autodoc-mode)))
("gptel" (or
(name . "^\\*gptel")))
("Common-lisp" (or
(mode . common-lisp-mode)
(mode . lisp-mode)
(mode . sly-mrepl-mode)))
(mode . lisp-mode)))
("Sly" (or
(mode . lisp-data-mode)
(mode . sly-db-mode)
(name . "\\*sly-compilation\\*")))
(mode . sly-mrepl-mode)
(name . "\\*sly-compilation\\*")
(name . "^\\*img-cache\\*")))
("Text" (or
(mode . org-mode)
(mode . markdown-mode)
@@ -245,10 +257,13 @@ targets."
("Emacs" (or
(name . "^\\*Help\\*$")
(name . "^\\*Custom.*")
(name . "^\\*info\\*$")
(name . "^\\*EMMS Playlist\\*")
(name . "^\\*Messages\\*$")
(name . "*Chinese-word-segmentation*")
(name . "^*Buffer List*")))
(name . "^*Buffer List*")
(name . "\\*discomfort\\*")))
("Info" (or
(name . "^\\*info")))
("Magit" (or
(mode . magit-blame-mode)
(mode . magit-cherry-mode)
@@ -304,8 +319,12 @@ targets."
(let ((start (car range))
(end (cdr range)))
(dotimes (i (- end start))
(modify-syntax-entry (+ start i) "_" jinx--syntax-table)))))
(require 'init-jinx)))
(modify-syntax-entry (+ start i) "_" jinx--syntax-table))))))
(use-package consult-jinx
:after jinx
:demand t
:straight nil))
;; eat终端
(use-package eat
@@ -398,12 +417,25 @@ targets."
:config
(setq magit-bind-magit-project-status nil))
;; git-timemachine
(use-package git-timemachine)
;; ediff
(use-package ediff
:config
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
(setq ediff-split-window-function 'split-window-horizontally))
;; emms
(use-package emms
:commands
(emms-playlist-mode-switch-buffer)
:config
(emms-all)
(setq emms-player-list '(emms-player-mpv)
emms-info-functions '(emms-info-native))
(emms-history-load))
(provide 'init-package)
;;; init-package.el ends here

View File

@@ -49,6 +49,8 @@
(setq markdown-command "multimarkdown"
markdown-fontify-code-blocks-natively t))
(use-package edit-indirect)
;; html
(use-package htmlize)

View File

@@ -44,7 +44,10 @@
(setenv "PATH" (concat (expand-file-name "H/appppppppppp/scoop/apps/") ";" (getenv "PATH"))))
(*is-mac*
(add-to-list 'exec-path (expand-file-name "/opt/homebrew/bin/"))
(setenv "PATH" (concat (expand-file-name "/opt/homebrew/bin/") ":" (getenv "PATH")))))
(setenv "PATH" (concat (expand-file-name "/opt/homebrew/bin/") ":" (getenv "PATH"))))
(*is-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")))))
;; 当文件被外部修改时自动刷新
(global-auto-revert-mode 1)

View File

@@ -9,31 +9,11 @@
(interactive)
(find-file "~/.emacs.d/init.el"))
(defun duplicate-and-move-to-next-line()
"Duplicate current line and move to next line."
(interactive)
(progn
(duplicate-line)
(next-line)))
;; scratch buffer
(if *is-mac*
(general-def "C-c <f12>" 'scratch-buffer)
(general-def "C-c <delete>" 'scratch-buffer))
;; god-mode
(general-def god-local-mode-map
"i" 'god-mode-all
"<escape>" 'god-mode-all
"[" 'backward-paragraph
"]" 'forward-paragraph
"." 'repeat
"y" 'yank
"C-c C-<f12>" 'scratch-buffer
"z" 'avy-goto-char
"'" 'avy-goto-word-1
"<f2>" 'open-init-file)
;; global map with C-c prefix
(general-def
:prefix "C-c"
@@ -45,23 +25,18 @@
;; global map
(general-def
;; god-mode
"<escape>" 'god-mode-all
"M-i" 'god-mode-all
;; buffer, file, and window
"<f2>" 'open-init-file
"M-[" 'previous-buffer
"M-]" 'next-buffer
"C-x C-b" 'ibuffer-other-window
"C-x K" 'crux-kill-other-buffers
"C-x C-b" 'ibuffer-other-window
;; edit
"M-c" 'capitalize-dwim
"M-u" 'upcase-dwim
"M-l" 'downcase-dwim
"C-," 'duplicate-and-move-to-next-line
"C-," 'crux-duplicate-current-line-or-region
"C-k" 'crux-smart-kill-line
"C-<backspace>" 'crux-kill-line-backwards
"C-a" 'crux-move-beginning-of-line
@@ -70,10 +45,12 @@
"C-c C-DEL" 'hungry-delete-forward
"M-P" 'drag-stuff-up
"M-N" 'drag-stuff-down
"C-M-@" 'er/mark-symbol
"M-@" 'er/mark-word
;; undo
"C-/" 'undo-fu-only-undo
"C-?" 'undo-fu-only-redo
"C-/" 'undo
"C-M-_" 'undo-redo
;; navigate
"M-p" 'backward-paragraph

View File

@@ -4,7 +4,7 @@
;;; Code:
;; 安装crux增强快捷键快捷键配置在init-kbd.el中
;; 安装crux
(use-package crux)
;; 安装hungry-delete
@@ -13,8 +13,12 @@
;; 安装drag-stuff拖动字符
(use-package drag-stuff)
;; expand region
(use-package expand-region)
;; expand-region,快速展开选中
(use-package expand-region
:commands
(er/mark-symbol er/mark-word)
:config
(setq expand-region-smart-cursor t))
;; 启用savehist保存命令顺序
(use-package savehist
@@ -32,49 +36,17 @@
(use-package saveplace
:init (save-place-mode))
;; undo增强
(use-package undo-fu)
;; vertico
(use-package vertico
:init (vertico-mode t))
;; 安装orderless用于模糊搜索
(use-package orderless
:custom (completion-styles '(orderless basic)))
;; (use-package corfu-terminal
;; :init (corfu-terminal-mode))
;; scheme
(use-package geiser
;; ido补全
(use-package ido
:init
(ido-mode)
(ido-everywhere)
:config
(with-eval-after-load 'geiser
(setq geiser-default-implementation 'guile)))
(use-package geiser-guile)
(define-key ido-common-completion-map (kbd "SPC") 'ido-restrict-to-matches))
;; general
(use-package general)
;; god-mode模态编辑
(use-package god-mode
:config
(setq god-mode-enable-function-key-translation nil)
(custom-set-faces
'(god-mode-lighter ((t (:inherit straight-process-error)))))
(defun my-sync-line-numbers-with-god-mode ()
(let ((desired (if (bound-and-true-p god-local-mode)
'relative
t)))
(unless (or (eq display-line-numbers desired) (bound-and-true-p olivetti-mode))
(setq display-line-numbers desired))))
(add-hook 'post-command-hook #'my-sync-line-numbers-with-god-mode)
(setq god-exempt-major-modes
(delete-dups (append '(diff-mode exwm-mode) god-exempt-major-modes))))
(provide 'init-terminal-package)
;;; init-terminal-package.el ends here

View File

@@ -4,6 +4,8 @@
;;; Code:
(global-display-line-numbers-mode 1)
(defconst *is-mac* (eq system-type 'darwin))
(defconst *is-linux* (eq system-type 'gnu/linux))
(defconst *is-windows* (or (eq system-type 'ms-dos)
@@ -73,6 +75,10 @@
'ripgrep)
(t 'grep)))
(setq word-wrap-by-category t)
(setq kill-whole-line t)
(provide 'init-terminal-startup)
;;; init-terminal-statup.el ends here

View File

@@ -34,11 +34,12 @@
"\\*Flutter\\*"
"\\*Ibuffer\\*"
"Buffers\\*$"
"\\*Geiser Debug\\*"
"^\\*Geiser"
"\\*gptel-Kimi-Code\\*"
"^\\*sly"
"\\*gptel-agent:.*\\*"
"^magit"
"\\*discomfort\\*"
bookmark-bmenu-mode
lsp-bridge-ref-mode
comint-mode
@@ -77,7 +78,7 @@
"^\\*elfeed-entry\\*$"
"^\\*macro expansion\\**"
"\\*Agenda Commands\\*" "\\*Org Select\\*" "\\*Capture\\*" "^CAPTURE-.*\\.org*" "^CAPTURE-"
"\\*Agenda Commands\\*" "\\*Org Select\\*" "\\*Capture\\*" "^CAPTURE-.*\\.org*" "^CAPTURE-" "\\*Org Note\\*"
"\\*Gofmt Errors\\*$" "\\*Go Test\\*$" godoc-mode
"\\*docker-containers\\*" "\\*docker-images\\*" "\\*docker-networks\\*" "\\*docker-volumes\\*"
"\\*prolog\\*" inferior-python-mode inf-ruby-mode swift-repl-mode

View File

@@ -18,6 +18,7 @@
my-base16-dark-core-palette
'((custom-theme-set-faces
theme-name
`(italic ((,class (:slant italic))))
`(org-level-1 ((,class (:foreground ,orange :height 1.0 :weight normal))))
`(org-level-2 ((,class (:foreground ,blue :height 1.0 :weight normal))))
`(org-level-3 ((,class (:foreground ,green :height 1.0 :weight normal))))
@@ -81,7 +82,9 @@
`(transient-key-stack ((,class (:foreground ,magenta :inherit transient-key))))
`(transient-key-recurse ((,class (:foreground ,blue :inherit transient-key))))
`(transient-key-noop ((,class (:foreground ,base01 :inherit transient-key))))
`(keycast-key ((,class (:foreground ,green :weight bold)))))))
`(keycast-key ((,class (:foreground ,green :weight bold))))
`(emms-playlist-track-face ((,class (:foreground ,cyan))))
`(emms-playlist-selected-face ((,class (:foreground ,blue :weight bold)))))))
(provide-theme 'my-base16-dark)

View File

@@ -81,7 +81,9 @@
`(transient-key-stack ((,class (:foreground ,magenta :inherit transient-key))))
`(transient-key-recurse ((,class (:foreground ,blue :inherit transient-key))))
`(transient-key-noop ((,class (:foreground ,base01 :inherit transient-key))))
`(keycast-key ((,class (:foreground ,green :weight bold)))))))
`(keycast-key ((,class (:foreground ,green :weight bold))))
`(emms-playlist-track-face ((,class (:foreground ,cyan))))
`(emms-playlist-selected-face ((,class (:foreground ,blue :weight bold)))))))
(provide-theme 'my-base16-light)

View File

@@ -18,8 +18,8 @@
"#3A9C36")) ; green: 绿色
(defvar my-base16-light-core-palette
'("#062624" ; darkest-base: 最深背景
"#E3FFE6" ; brightest-base: 最亮前景
'("#051E23" ; darkest-base: 最深背景
"#FCFFDE" ; brightest-base: 最亮前景
"#A87C04" ; yellow: 黄色
"#C24713" ; orange: 橙色
"#CE2825" ; red: 红色