【发布时间】:2014-07-05 07:38:14
【问题描述】:
我已经在 Windows 7 下安装了 Emacs,并希望在我的日常工作中使用它。不幸的是,Emacs 世界和其他文本编辑器世界完全不同,我在键盘上每按三个键序列就卡住了 - 它正在做一些我不希望它会做的事情。
我想发出一个紧急命令 - 当我按 ESC ESC ESC 时,它停止执行所有操作,从 minibuffer 退出,停止输入命令,取消突出显示正则表达式等。它已经做了我想要的,除了它杀死缓冲区,布局我的工作空间。所以我修改了simple.el文件中的keyboard-escape-quit函数(通过C-h 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))))
我已经字节编译并加载了这个文件,它工作正常。但我不知道为什么它在启动时没有加载。
【问题讨论】:
-
我是新手,但你能把这段代码放在你的
.emacs或.emacs.d/init.el中,从而覆盖之前的定义吗? (Windows,它可能是c:\Users\<user-name>\AppData\Roaming\_emacs。)我尽量不要依赖编辑源文件,因为那样你可能会在某些时候担心它。 (重新安装、故障排除、在与支持人员互动时检查前沿。) -
据我所知,现在所有用户自定义都是通过 .emacs.d 目录中的 init.el 完成的。安全的方法是添加新功能,将新键绑定到它们或重新绑定现有的。
-
@user2244092 我认为您至少应该浏览一下Emacs manual。它彻底解释了 Emacs 的所有概念,包括 Customization 和 Init File。
标签: emacs