[英]How can I load changes of .el file at startup in Emacs?
我已经在Windows 7下安装了Emacs,并希望在日常工作中使用它。 不幸的是,Emacs世界和其他文本编辑器世界完全不同,我在键盘上按的每三个按键序列上都陷入了困境–它在做我没想到会做的事情。
我想发出一个紧急命令-当我按ESC ESC ESC时,它停止执行所有操作,从小型缓冲区中退出,停止输入命令,取消突出显示正则表达式等。它已经可以执行我想要的操作,除了杀死缓冲区,工作区的布局。 所以我在simple.el文件中修改了keyboard-escape-quit
功能(由Ch k ESC ESC ESC找到)
(defun keyboard-escape-quit ()
"Exit the current \"mode\" (in a generalized sense of the word).
This command can exit an interactive command such as `query-replace',
can clear out a prefix argument or a region,
can get out of the minibuffer or other recursive edit,
cancel the use of the current buffer (for special-purpose buffers),
or go back to just one window (by deleting all but the selected window)."
(interactive)
; Stop highlighting regexp
(unhighlight-regexp)
(cond ((eq last-command 'mode-exited) nil)
((region-active-p)
(deactivate-mark))
((> (minibuffer-depth) 0)
(abort-recursive-edit))
(current-prefix-arg
nil)
((> (recursion-depth) 0)
(exit-recursive-edit))
(buffer-quit-function
(funcall buffer-quit-function))
;((not (one-window-p t))
; (delete-other-windows))
((string-match "^ \\*" (buffer-name (current-buffer)))
(bury-buffer))))
我已经字节编译并加载了此文件,它工作正常。 但是我不知道为什么它不能在启动时加载。
您不能修改某些特殊的内置库,包括simple.el
。 Emacs实际上从未从它们的源代码或字节代码文件中加载这些特殊的库。 它们的字节码在构建时通过称为“转储”的过程直接包含在Emacs可执行文件中。 Emacs从自己的二进制文件加载这些库。
通常,无论如何都不应修改任何内置库。 当您更新Emacs时,您的风险破坏和自定义设置将丢失。
而是执行您应该做的事情:将自定义函数添加到init.el
。
因此,不用修改内置的keyboard-escape-quit
, init.el
在init.el
创建您自己的函数(例如my-emergency-quit
,然后使用它将其绑定到全局键(例如Cc q
)。
(global-set-key (kbd "C-c q") #'my-emergency-quit)
最后一些建议:我认为这样的紧急命令没有任何用处。 Emacs的第一条规则是:不要惊慌。 如果您陷入困境,请不要尝试退出并杀死一切。 相反,尝试找出为什么会被卡住,以及如何通过常规方式“摆脱”卡住。 这样,您将更好地学习Emacs,恕我直言。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.