~cytrogen/.emacs.d

ref: 8247f19b07019a59b3f02524ab8394b2b3c90077 .emacs.d/config/keybindings.el -rw-r--r-- 6.2 KiB
8247f19b — Cytrogen feat(keybindings): 添加 70+ 全局快捷键绑定 a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
;;; keybindings.el --- Global keybindings and shortcuts -*- lexical-binding: t -*-

;; 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
;; - Function key mappings
;; - Custom shortcuts

;;; Commentary:

;; Centralized location for all global keybindings to make them easy
;; to find, modify, and avoid conflicts.

;;; Code:

;; Org-mode Keybindings
;; Core Org workflow shortcuts
(global-set-key (kbd "C-c c") 'org-capture)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c C-w") 'org-refile)
(global-set-key (kbd "C-c w") 'my/quick-refile)
(global-set-key (kbd "C-c o") 'my/open-org-file)

;; Application Shortcuts
;; Quick access to frequently used functions
(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
(global-set-key (kbd "C-c i") 'my/open-init-file)
(global-set-key (kbd "C-c r") 'my/reload-init-file)

;; 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-<up>") 'move-dup-move-lines-up)
(global-set-key (kbd "M-S-<down>") '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-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 "<up>") 'my/arrow-key-reminder)
(global-set-key (kbd "<down>") 'my/arrow-key-reminder)
(global-set-key (kbd "<left>") 'my/arrow-key-reminder)
(global-set-key (kbd "<right>") 'my/arrow-key-reminder)

;; 禁用 Delete 键,显示提示
(defun my/delete-key-reminder ()
  "提醒使用 Emacs 原生删除键。"
  (interactive)
  (message "使用 Emacs 键位: C-d(删字符) M-d(删单词) C-k(删到行尾)"))

(global-set-key (kbd "<delete>") '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 "<wheel-up>"))
(global-unset-key (kbd "<wheel-down>"))

;; 移动键位速查表
(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