Emacs 自定义 Key Bindings 完整说明
1. 说明
本文整理了仓库配置中找到的自定义按键绑定,并按功能分类。快捷键名称使用英文 Key Bindings;说明文字为中文。
配置文件链接指向本机目录 =~/.emacs.d/=。请在 Emacs 中打开本文档,再点击链接跳转到对应的本地配置文件和行号。
导出为 HTML 时,本地文件链接不会成为可点击链接;HTML 中只显示配置文件名称和行号。
2. 基本导航与 Emacs 操作
2.1. Home — Jump to Buffer Start
调用函数:=beginning-of-buffer=
作用:
- 将光标移动到当前缓冲区的最开头。
配置文件:
pengshao-key-building.el 第 9 行2.2. End — Jump to Buffer End
调用函数:=end-of-buffer=
作用:
- 将光标移动到当前缓冲区的最结尾。
配置文件:
pengshao-key-building.el 第 11 行2.3. C-prior — Switch to Previous Buffer
调用函数:=previous-buffer=
作用:
- 在已打开的缓冲区之间切换到前一个缓冲区。
配置文件:
init.el 第 139 行2.4. C-next — Switch to Next Buffer
调用函数:=next-buffer=
作用:
- 在已打开的缓冲区之间切换到下一个缓冲区。
配置文件:
init.el 第 140 行2.5. C-c m h — Open Recent Files
调用函数:=recentf-open-files=
作用:
- 显示最近访问过的文件列表,方便重新打开历史文件。
- Recentf 功能通过
recentf-mode启用。
配置文件:
pengshao-default.el 第 48—49 行2.6. F1 — Open Emacs Info
调用函数:=info=
作用:
- 打开 Emacs Info 帮助文档,可浏览 Emacs、Elisp 和已安装文档的说明。
配置文件:
pengshao-key-building.el 第 19 行2.7. F2 — Undo
调用函数:=undo=
作用:
- 撤销最近一次编辑操作。可以重复调用以撤销更多修改。
配置文件:
pengshao-key-building.el 第 22 行2.8. F3 — Open Emacs Init File
调用函数:=open-init-file=
作用:
- 打开 =~/.emacs.d/init.el=,方便查看或编辑主配置文件。
函数定义:
init.el 第 9—11 行快捷键设置:
pengshao-key-building.el 第 28 行2.9. F4 — Kill Current Buffer
调用函数:=kill-buffer=
作用:
- 关闭当前缓冲区。
- 如果文件有未保存的修改,Emacs 会询问是否保存。
配置文件:
pengshao-key-building.el 第 33 行2.10. F6 — Open Dired
调用函数:=dired=
作用:
- 打开 Emacs 的目录浏览和文件管理界面。
- 可浏览目录、打开文件,以及执行文件操作。
配置文件:
pengshao-key-building.el 第 41 行2.11. F7 — Open Shell
调用函数:=shell=
作用:
- 在 Emacs 缓冲区中启动 Shell,方便在 Emacs 内运行系统命令。
配置文件:
pengshao-key-building.el 第 44 行2.12. F8 — List Bookmarks
调用函数:=list-bookmarks=
作用:
- 显示已保存的书签,可选择书签跳转到相应文件或位置。
配置文件:
pengshao-key-building.el 第 47 行2.13. F9 — Set Bookmark
调用函数:=bookmark-set=
作用:
- 将当前文件位置保存为书签,之后可通过书签列表跳回。
配置文件:
pengshao-key-building.el 第 50 行2.14. F10 — Toggle Menu Bar
调用函数:=menu-bar-mode=
作用:
- 显示或隐藏 Emacs 顶部菜单栏。
配置文件:
pengshao-key-building.el 第 56 行3. Theme Settings
3.1. F5 — Toggle Ef Themes
调用函数:=ef-themes-toggle=
作用:
- 在配置的两个 Ef 主题之间切换。
- 代码实际设置的主题为
ef-deuteranopia-light和 =ef-cyprus=。
配置文件:
pengshao-ef-themes.el 第 21—40 行3.2. C-c t s — Select Ef Theme
调用函数:=ef-themes-select=
作用:
- 打开交互式主题选择界面,可选择其他 Ef 主题。
配置文件:
pengshao-ef-themes.el 第 37—40 行3.3. C-c t r — Customize Themes
调用函数:=customize-themes=
作用:
- 打开 Emacs 的主题定制界面。
注意:
- 配置中有一行将此按键绑定到 =ef-themes-load-random=,但该行已注释。
- 当前生效的绑定是 =customize-themes=。
配置文件:
pengshao-ef-themes.el 第 37—41 行4. Clipboard and Kill Ring
4.1. C-c y — Browse Kill Ring
调用函数:=browse-kill-ring=
作用:
- 打开 Kill Ring 历史列表。
- 可浏览之前剪切或复制的文本,并选择内容插入到原缓冲区。
快捷键定义:
init.el 第 74—76 行Kill Ring 窗口按键定义:
browse-kill-ring.el 第 688—710 行4.2. M-w — Copy Region or Current Line
原始函数:=kill-ring-save=
作用:
- 有选区时复制选中的文本。
- 没有选区时,通过 advice 改为复制光标所在的整行。
附加配置:
- =kill-do-not-save-duplicates=:不保存重复内容。
- =kill-ring-max=:将 Kill Ring 最大数量设为 200。
- =mouse-yank-at-point=:设置中键粘贴到光标位置。
配置文件:
pengshao-copy-cut-paste-killring.el 第 6—24 行5. Org Mode and Publishing
5.1. C-c l — Store Org Link
调用函数:=org-store-link=
作用:
- 保存当前文件、标题或位置的 Org 链接。
- 之后可在其他 Org 文档中插入该链接。
配置文件:
init.el 第 80—85 行5.2. C-c c — Start Org Capture
调用函数:=org-capture=
作用:
- 根据模板快速记录待办事项、网页链接、文章摘录或个人陈述。
模板配置:
pengshao-org-mode.el 第 35—53 行快捷键配置:
init.el 第 80—85 行注意:
- Capture 启动后选择的
t=、=w=、=a=、=s是模板标记,不是单独注册的全局按键。
5.3. C-c a — Open Org Agenda
调用函数:=org-agenda=
作用:
- 打开 Org 日程和任务汇总视图。
- 当前 Agenda 文件设置为 =~/public_note/idear/list-list.org=。
Agenda 文件配置:
pengshao-org-mode.el 第 26—30 行快捷键配置:
init.el 第 80—85 行5.4. C-c p — Publish Org Project
调用函数:=org-publish=
作用:
- 根据发布项目配置生成 HTML 并发布静态资源。
- 当前配置包括
psnote-org=、=psnote-static和组合项目 =psnote=。
配置文件:
pengshao-org-publish.el 第 7—58 行6. Date and Progress Insertion
6.1. C-c m t — Insert Active Timestamp
调用函数:=my-insert-time=
作用:
- 打开日期和时间选择界面。
- 插入包含日期、英文星期和 24 小时制时间的活时间戳。
- 格式示例:==。
配置文件:
pengshao-insert-date.el 第 10—18 行6.2. C-c m d — Insert Date and Day of Year
调用函数:=my-insert-date=
作用:
- 选择日期并插入活日期。
- 同时附加该日期是一年中的第几天。
- 格式示例:=-318。
配置文件:
pengshao-insert-date.el 第 20—31 行6.3. C-c m m — Insert Year and Month
调用函数:=my-insert-month=
作用:
- 选择日期并插入年份和英文月份全称。
- 格式示例:=<2026-November>=。
配置文件:
pengshao-insert-date.el 第 33—41 行6.4. C-c m y — Insert Year Progress Bar
调用函数:=insert-day-progress=
辅助函数:=make-progress=
作用:
- 根据当前日期计算今年已经过去的比例。
- 插入宽度为 30 格的进度条和百分比。
配置文件:
pengshao-insert-date.el 第 44—63 行7. Weather, Chinese Calendar, and Moon Phase
7.1. C-c m w — Insert Weather Information
调用函数:=insert-weather2=
作用:
- 调用
wttr.in查询颜庄地区天气。 - 插入天气、温度、风速、降水和月相等信息。
配置文件:
pengshao-openweather.el 第 13—18 行7.2. C-c m o — Insert Moon Phase Information
调用函数:=insert-pyphoon=
作用:
- 激活配置中的 Python 虚拟环境并运行 =pyphoon=。
- 将命令输出插入当前缓冲区。
配置文件:
pengshao-openweather.el 第 22—27 行7.3. C-c m n — Insert Chinese Lunar Date
调用函数:=insert-nongli=
作用:
- 执行 =~/.emacs.d/loadfile/nongli.sh=。
- 将脚本输出插入光标位置。
函数与快捷键配置:
pengshao-openweather.el 第 30—34 行调用脚本:
nongli.sh7.4. C-c m j — Insert Simplified Lunar Date
调用函数:=insert-nonglijian=
作用:
- 执行 =~/.emacs.d/loadfile/nonglijian.sh=。
- 将脚本输出插入光标位置。
函数与快捷键配置:
pengshao-openweather.el 第 36—40 行调用脚本:
nonglijian.sh7.5. C-c m c — Insert Moon Phase Org Drawer
调用函数:=insert-moon-today-drawer-with-pyphoon=
作用:
- 仅在
org-mode中生效。 - 插入
:MOON-TODAY:标记。 - 调用
insert-pyphoon插入月相内容。 - 最后插入
:END:标记。
配置文件:
pengshao-openweather.el 第 43—54 行7.6. C-c m s — Insert Scratch Content Drawer
调用函数:=insert-scratch-content-drawer=
作用:
- 仅在
org-mode中生效。 - 读取
*scratch*缓冲区的全部内容。 - 将内容放入
:SCRATCH:和:END:之间的 Org Drawer。
配置文件:
pengshao-openweather.el 第 57—77 行8. File Tree and Completion
8.1. C-c t t — Open Treemacs
调用函数:=treemacs=
作用:
- 打开或切换 Treemacs 文件树界面。
- 通过树形视图浏览和打开项目文件。
配置文件:
pengshao-treemacs.el 第 8—12 行8.2. C-c t 1 — Select Treemacs Window
调用函数:=treemacs-select-window=
作用:
- 将焦点切换到 Treemacs 文件树窗口。
配置文件:
pengshao-treemacs.el 第 11—12 行8.3. C-c q — Manually Trigger Company Completion
调用函数:=company-complete=
作用:
- 手动显示当前上下文可用的 Company 补全候选项。
- 此按键绑定在
company-mode-map中,Company 启用时生效。
配置文件:
pengshao-Company.el 第 8—18 行9. English Vocabulary and Phrase Learning
9.1. C-c m e — Translate and Save a Word
调用函数:=pengshao-english-add-word=
作用:
- 提示输入一个英文单词。
- 调用
sdcv查询释义。 - 将单词、释义和添加日期写入 =~/personal_note/pengshao-english.org=。
- 自动设置 VOCAB 标签、次日安排和七天后的截止日期。
快捷键定义:
pengshao-translate.el 第 75—77 行函数定义:
pengshao-translate.el 第 23—44 行9.2. C-c m l — Translate and Save a Phrase
调用函数:=pengshao-english-add-phrase=
作用:
- 提示输入英文短语。
- 将短语拆分成单词,并逐词调用
sdcv查询释义。 - 将短语、单词释义、添加日期和复习安排写入词汇文件。
- 自动设置 PHRASE 标签、次日安排和七天后的截止日期。
快捷键定义:
pengshao-translate.el 第 75—77 行函数定义:
pengshao-translate.el 第 46—71 行10. Kill Ring Window Key Bindings
以下按键只在 browse-kill-ring 窗口中有效。先按 C-c y 打开 Kill Ring 列表,再使用这些按键。
10.1. q / C-g — Quit Kill Ring
调用函数:=browse-kill-ring-quit=
作用:
- 退出 Kill Ring 浏览界面。
- 根据配置恢复或关闭相应窗口。
10.2. n / p — Move Between Entries
调用函数:=browse-kill-ring-forward= / browse-kill-ring-previous
作用:
- 在 Kill Ring 历史条目之间向前或向后移动。
10.3. y / i — Insert Selected Entry
调用函数:=browse-kill-ring-insert=
作用:
- 将当前选中的 Kill Ring 条目插入原缓冲区。
10.4. RET — Insert Entry and Quit
调用函数:=browse-kill-ring-insert-and-quit=
作用:
- 插入当前条目,然后退出 Kill Ring 窗口。
10.5. u / M-RET — Insert, Promote, and Quit
调用函数:=browse-kill-ring-insert-move-and-quit=
作用:
- 插入当前条目。
- 将该条目移动到 Kill Ring 历史列表前端。
- 然后退出窗口。
10.6. o — Insert and Promote Entry
调用函数:=browse-kill-ring-insert-and-move=
作用:
- 插入当前条目,并将其移动到 Kill Ring 历史列表前端。
10.7. x — Insert and Delete Entry
调用函数:=browse-kill-ring-insert-and-delete=
作用:
- 插入当前条目,然后从 Kill Ring 历史中删除它。
10.8. b — Prepend Entry to Buffer
调用函数:=browse-kill-ring-prepend-insert=
作用:
- 将当前条目插入原缓冲区开头。
10.9. a — Append Entry to Buffer
调用函数:=browse-kill-ring-append-insert=
作用:
- 将当前条目追加到原缓冲区末尾。
10.10. d — Delete Entry
调用函数:=browse-kill-ring-delete=
作用:
- 从 Kill Ring 历史中删除当前选中的条目。
10.11. s / r — Search Entries
调用函数:
browse-kill-ring-search-forwardbrowse-kill-ring-search-backward
作用:
- 输入正则表达式,在 Kill Ring 条目中向前或向后搜索。
10.12. l — Filter Entries by Regular Expression
调用函数:=browse-kill-ring-occur=
作用:
- 输入正则表达式,只显示符合条件的 Kill Ring 条目。
10.13. g — Refresh Kill Ring List
调用函数:=browse-kill-ring-update=
作用:
- 根据当前 Kill Ring 内容重新生成列表。
10.14. e — Edit Selected Entry
调用函数:=browse-kill-ring-edit=
作用:
- 在编辑缓冲区中修改当前 Kill Ring 条目。
编辑模式按键:
- =C-c C-c=:保存编辑并提交修改。
- =C-c C-k=:取消编辑。
- =C-g=:取消编辑。
10.15. U — Undo in Original Buffer
调用函数:=browse-kill-ring-undo-other-window=
作用:
- 对 Kill Ring 浏览窗口关联的原缓冲区执行撤销。
10.16. ? / h — Describe Kill Ring Mode
调用函数:=describe-mode=
作用:
- 显示当前 Kill Ring 浏览模式和按键帮助。
浏览器模式按键定义:
browse-kill-ring.el 第 688—710 行编辑模式按键定义:
browse-kill-ring.el 第 733—745 行11. Disabled or Commented Key Bindings
以下配置已注释,不属于当前生效的按键绑定。
11.1. F3 — Redo
- 绑定到
redo的代码已注释。
配置位置:
pengshao-key-building.el 第 24—25 行11.2. F5 — Speedbar
- Speedbar 绑定已注释。
- 当前
F5由主题配置绑定到 =ef-themes-toggle=。
配置位置:
pengshao-key-building.el 第 35—38 行11.3. C-c s / C-c x — Speedbar Open and Close
- 打开和关闭 Speedbar 的绑定已注释。
配置位置:
pengshao-key-building.el 第 35—38 行11.4. F9 — GNUS
- 绑定到
gnus的代码已注释。 - 当前
F9绑定到 =bookmark-set=。
配置位置:
pengshao-key-building.el 第 52—53 行11.5. F11 / F12 — Compile, Todo, or GDB
F11绑定到compile的代码已注释。F12绑定到todo-show或gdb的代码已注释。
配置位置:
pengshao-key-building.el 第 58—61 行11.6. C-c b — Org Iswitchb
- 绑定到
org-iswitchb的代码已注释。
配置位置:
init.el 第 86—87 行12. Main Configuration Files
主配置文件:
init.el主要快捷键配置模块:
pengshao-default.el pengshao-ef-themes.el pengshao-key-building.el pengshao-org-mode.el pengshao-org-publish.el pengshao-insert-date.el pengshao-openweather.el pengshao-treemacs.el pengshao-Company.el pengshao-translate.el pengshao-copy-cut-paste-killring.el browse-kill-ring.el