我经常定义一个特定的键盘宏,所以我认为如果每次加载 Emacs 时它都自动可用,可能会很方便。
我该怎么做?
手册中的保存键盘宏部分怎么样?
C-x C-k n
Give a command name (for the duration of the Emacs session) to the most recently defined keyboard macro (kmacro-name-last-macro).
C-x C-k b
Bind the most recently defined keyboard macro to a key sequence (for the duration of the session) (kmacro-bind-to-key).
M-x insert-kbd-macro
Insert in the buffer a keyboard macro's definition, as Lisp code.
这很大程度上与已接受的答案重复,但我强烈推荐这篇掌握 Emacs 文章。
如果您知道适当格式的按键序列,则可以直接使用
defalias
和 kmacro
- 例如,要执行 C-c a a
,只需将其放入您的初始化文件中:
(defalias 'start-org-agenda
(kmacro "C-c a a") "Start the org-mode agenda for the current day.")