From 8247f19b07019a59b3f02524ab8394b2b3c90077 Mon Sep 17 00:00:00 2001 From: Cytrogen Date: Wed, 11 Mar 2026 19:22:56 -0400 Subject: [PATCH] =?UTF-8?q?feat(keybindings):=20=E6=B7=BB=E5=8A=A0=2070+?= =?UTF-8?q?=20=E5=85=A8=E5=B1=80=E5=BF=AB=E6=8D=B7=E9=94=AE=E7=BB=91?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修正 Copyright 年份为 2026,添加 purcell 署名 - 搜索与导航:consult-line/ripgrep/find/outline (C-c s 前缀) - 上下文操作:embark-act (C-.) / embark-dwim (C-;) - 快速跳转:avy-goto-char-timer (M-j) 等 (C-c j 前缀) - 多光标编辑:mc/mark-next/prev/all (C-c n 前缀) - 符号高亮:symbol-overlay-put (M-i) - 移动/复制行:move-dup (M-S-↑/↓, C-c p 前缀) - 博客工作流:完善 C-c b 前缀(refile/batch/gemini/webmention) - 日历:C-c g 可视化日历,C-c G 强制同步 - 终端:C-c t 启动 eat - 词典:C-c k/K sdcv,C-c d/D GoldenDict - 代码折叠:C-c z/Z origami - 硬核学习模式:禁用方向键/Delete/鼠标,显示原生键位提示 --- config/keybindings.el | 116 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 2 deletions(-) diff --git a/config/keybindings.el b/config/keybindings.el index 5670aaee3e45b8b7357d9fa4f8decbe5704338b3..63c495eafbbac9731016a1f7606ddbcc980e3aca 100644 --- a/config/keybindings.el +++ b/config/keybindings.el @@ -1,6 +1,9 @@ ;;; keybindings.el --- Global keybindings and shortcuts -*- lexical-binding: t -*- -;; Copyright (C) 2024 Cytrogen +;; Copyright (C) 2026 Cytrogen + +;; Many package selections and configurations adapted from +;; Steve Purcell's emacs.d: https://github.com/purcell/emacs.d ;; This file contains: ;; - Global key bindings @@ -27,6 +30,8 @@ (global-set-key (kbd "C-c m") 'mastodon) (global-set-key (kbd "C-c f") 'elfeed) ; RSS feeds (global-set-key (kbd "C-c e") 'mu4e) ; Email +(global-set-key (kbd "C-c E") 'elpher) ; Gemini/Gopher browser +(global-set-key (kbd "C-c l") 'my/opds-browse) ; OPDS library ;; File and Navigation Shortcuts ;; File operations and navigation @@ -36,14 +41,121 @@ ;; Custom Function Bindings ;; Shortcuts for custom utility functions +;; 搜索与导航 (Consult) +(global-set-key (kbd "C-c s s") 'consult-line) +(global-set-key (kbd "C-c s g") 'consult-ripgrep) +(global-set-key (kbd "C-c s f") 'consult-find) +(global-set-key (kbd "C-c s o") 'consult-outline) +(global-set-key (kbd "C-c s m") 'consult-mark) +(global-set-key (kbd "C-c s b") 'consult-bookmark) +(global-set-key (kbd "M-s l") 'consult-line) +(global-set-key (kbd "M-s r") 'consult-ripgrep) + +;; 上下文操作 (Embark) +(global-set-key (kbd "C-.") 'embark-act) +(global-set-key (kbd "C-;") 'embark-dwim) + +;; 跳转 (Avy) +(global-set-key (kbd "C-c j j") 'avy-goto-char-2) +(global-set-key (kbd "C-c j l") 'avy-goto-line) +(global-set-key (kbd "C-c j w") 'avy-goto-word-1) +(global-set-key (kbd "M-j") 'avy-goto-char-timer) + +;; 多光标 (Multiple Cursors) +(global-set-key (kbd "C-c n n") 'mc/mark-next-like-this) +(global-set-key (kbd "C-c n p") 'mc/mark-previous-like-this) +(global-set-key (kbd "C-c n a") 'mc/mark-all-like-this) +(global-set-key (kbd "C-c n l") 'mc/edit-lines) + +;; 符号高亮 (Symbol Overlay) +(global-set-key (kbd "M-i") 'symbol-overlay-put) + +;; 移动/复制行 (Move-dup) +(global-set-key (kbd "C-c p d") 'move-dup-duplicate-down) +(global-set-key (kbd "C-c p u") 'move-dup-duplicate-up) +(global-set-key (kbd "M-S-") 'move-dup-move-lines-up) +(global-set-key (kbd "M-S-") 'move-dup-move-lines-down) + ;; Blog Workflow Shortcuts (global-set-key (kbd "C-c b c") 'my/blog-create-monthly) (global-set-key (kbd "C-c b o") 'my/blog-open-current-monthly) +(global-set-key (kbd "C-c b r") 'my/blog-refile-to-monthly) (global-set-key (kbd "C-c b e") 'my/blog-export-monthly) (global-set-key (kbd "C-c b m") 'my/blog-export-monthly) ; alias (global-set-key (kbd "C-c b p") 'my/blog-export-post) (global-set-key (kbd "C-c b n") 'my/blog-create-post-from-entry) -(global-set-key (kbd "C-c b i") 'my/blog-insert-image) +(global-set-key (kbd "C-c b i") 'my/blog-batch-refile-inbox) +(global-set-key (kbd "C-c b I") 'my/blog-insert-image) +(global-set-key (kbd "C-c b u") 'my/blog-update-monthly-posts) +(global-set-key (kbd "C-c b g") 'my/blog-export-post-gemini) +(global-set-key (kbd "C-c b G") 'my/blog-gemini-generate-index) +;; Webmention +(global-set-key (kbd "C-c b w") 'webmention-discover) ; 发现目标 + staging buffer +(global-set-key (kbd "C-c b W") 'webmention-send-url) ; 直接发送(source → target) +(global-set-key (kbd "C-c b h") 'webmention-show-history) ; 查看发送历史 + +;; Calendar Shortcuts +(global-set-key (kbd "C-c g") 'my/calendar-open) ; 可视化日历 +(global-set-key (kbd "C-c G") 'my/calendar-sync) ; 强制同步 + +;; 终端 (Eat) +(global-set-key (kbd "C-c t") 'eat) + +;; 词典查询 (sdcv) +(global-set-key (kbd "C-c k") 'sdcv-search-pointer+) ; 光标处快速查词(浮动提示) +(global-set-key (kbd "C-c K") 'sdcv-search-pointer) ; 光标处详细查词(buffer) +(global-set-key (kbd "C-c C-k") 'sdcv-search-input+) ; 手动输入查词(浮动提示) + +;; 词典查询 (GoldenDict) +(global-set-key (kbd "C-c d") 'my/goldendict-search-at-point) ; GoldenDict 查光标处单词 +(global-set-key (kbd "C-c D") 'my/goldendict-search-input) ; GoldenDict 手动输入查词 + +;; 代码折叠 (Origami) +(global-set-key (kbd "C-c z") 'origami-toggle-node) +(global-set-key (kbd "C-c Z") 'origami-toggle-all-nodes) + +;;; ============================================================ +;;; 硬核学习模式 - 强制学习 Emacs 原生键位 +;;; ============================================================ + +;; 禁用方向键,显示 Emacs 等效键位提示 +(defun my/arrow-key-reminder () + "提醒使用 Emacs 原生移动键。" + (interactive) + (message "使用 Emacs 键位: C-p(上) C-n(下) C-b(左) C-f(右)")) + +(global-set-key (kbd "") 'my/arrow-key-reminder) +(global-set-key (kbd "") 'my/arrow-key-reminder) +(global-set-key (kbd "") 'my/arrow-key-reminder) +(global-set-key (kbd "") 'my/arrow-key-reminder) + +;; 禁用 Delete 键,显示提示 +(defun my/delete-key-reminder () + "提醒使用 Emacs 原生删除键。" + (interactive) + (message "使用 Emacs 键位: C-d(删字符) M-d(删单词) C-k(删到行尾)")) + +(global-set-key (kbd "") 'my/delete-key-reminder) + +;; 禁用鼠标点击 +(dolist (key '([mouse-1] [mouse-2] [mouse-3] + [down-mouse-1] [down-mouse-2] [down-mouse-3] + [drag-mouse-1] [drag-mouse-2] [drag-mouse-3] + [double-mouse-1] [double-mouse-2] [double-mouse-3] + [triple-mouse-1] [triple-mouse-2] [triple-mouse-3])) + (global-unset-key key)) + +;; 禁用鼠标滚轮(强制使用 C-v / M-v) +(global-unset-key (kbd "")) +(global-unset-key (kbd "")) + +;; 移动键位速查表 +(defun my/show-movement-cheatsheet () + "显示 Emacs 键位速查表。" + (interactive) + (message "移动: C-f/b/n/p | 词: M-f/b | 行首尾: C-a/e | 页: C-v/M-v | 删除: C-d/M-d/C-k")) + +(global-set-key (kbd "C-c h m") 'my/show-movement-cheatsheet) (provide 'keybindings) ;;; keybindings.el ends here \ No newline at end of file