[英]How can I load changes of .el file at startup in Emacs?
I have installed Emacs under Windows 7 and want to use it in my everyday work. 我已经在Windows 7下安装了Emacs,并希望在日常工作中使用它。 Unfortunately Emacs world and other text editors world are completely different and I am getting stuck on every third sequence of keys pressed on keyboard - it's doing something that I don't expect it would do.
不幸的是,Emacs世界和其他文本编辑器世界完全不同,我在键盘上按的每三个按键序列上都陷入了困境–它在做我没想到会做的事情。
I want to make a panic command - when I press ESC ESC ESC it stops doing everything, quitting from minibuffer, stops entering command, unhighlight regexps, etc. It already does what I want, except it killing buffers, the layout of my workspace. 我想发出一个紧急命令-当我按ESC ESC ESC时,它停止执行所有操作,从小型缓冲区中退出,停止输入命令,取消突出显示正则表达式等。它已经可以执行我想要的操作,除了杀死缓冲区,工作区的布局。 So I modified
keyboard-escape-quit
function in simple.el file (found it by Ch k 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))))
I have byte-compiled and loaded this file and it works ok. 我已经字节编译并加载了此文件,它工作正常。 But I can't figure out why it is not loading at startup.
但是我不知道为什么它不能在启动时加载。
You cannot modify some special built-in libraries, including simple.el
. 您不能修改某些特殊的内置库,包括
simple.el
。 Emacs never actually loads these special libraries from their source or byte code files. Emacs实际上从未从它们的源代码或字节代码文件中加载这些特殊的库。 Their byte code is directly included in the Emacs executable at build time, by a process called “dumping”.
它们的字节码在构建时通过称为“转储”的过程直接包含在Emacs可执行文件中。 Emacs loads these libraries from its own binary.
Emacs从自己的二进制文件加载这些库。
Generally, should not modify any built-in libraries anyway. 通常,无论如何都不应修改任何内置库。 Your risk breakage, and your customizations are lost when you update Emacs.
当您更新Emacs时,您的风险破坏和自定义设置将丢失。
Instead, do what you are supposed to do: Add custom functions to your init.el
. 而是执行您应该做的事情:将自定义函数添加到
init.el
。
Hence, instead of modifying the built-in keyboard-escape-quit
, create your own function, eg my-emergency-quit
, in your init.el
, and bind it to a global key, eg Cc q
, with 因此,不用修改内置的
keyboard-escape-quit
, init.el
在init.el
创建您自己的函数(例如my-emergency-quit
,然后使用它将其绑定到全局键(例如Cc q
)。
(global-set-key (kbd "C-c q") #'my-emergency-quit)
Some final words of advice: I do not think that such a panic command does any good. 最后一些建议:我认为这样的紧急命令没有任何用处。 The first rule of Emacs is: Don't panic.
Emacs的第一条规则是:不要惊慌。 If you are stuck, don't try to quit and kill everything.
如果您陷入困境,请不要尝试退出并杀死一切。 Rather, try to find out why you are stuck, and how to get “un-stuck” by normal means.
相反,尝试找出为什么会被卡住,以及如何通过常规方式“摆脱”卡住。 You'll learn Emacs better this way, imho.
这样,您将更好地学习Emacs,恕我直言。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.