如何让Emacs重新加载我在.emacs中更新的所有定义而不重新启动Emacs?


当前回答

这里有一个快速和简单的方法来快速测试您的配置。您还可以在特定的lisp末尾使用C-x C-e来单独执行某些函数。

C-x C-e runs the command eval-last-sexp (found in global-map), which is an interactive compiled Lisp function. It is bound to C-x C-e. (eval-last-sexp EVAL-LAST-SEXP-ARG-INTERNAL) Evaluate sexp before point; print value in the echo area. Interactively, with prefix argument, print output into current buffer. Normally, this function truncates long output according to the value of the variables ‘eval-expression-print-length’ and ‘eval-expression-print-level’. With a prefix argument of zero, however, there is no such truncation. Such a prefix argument also causes integers to be printed in several additional formats (octal, hexadecimal, and character). If ‘eval-expression-debug-on-error’ is non-nil, which is the default, this command arranges for all errors to enter the debugger.

其他回答

您可以使用命令load-file (M-x load-file,然后按Return两次以接受默认文件名,即当前正在编辑的文件)。

你也可以把这个点移动到任何性别p的末尾,然后按C-x, C-e来执行那个性别p。如果您只是更改一两行,通常不需要重新加载整个文件。

下面就应该做到了…

M-x load-file

我目前使用的是Ubuntu 15.04 (Vivid Vervet);我喜欢为它定义一个键。

[M-insert]在我的键盘上翻译成Alt + Ins。

把这个放在你的emacs文件中:

(global-set-key [M-insert] '(lambda() (interactive) (load-file "~/.emacs")))
M-x load-file
~/.emacs
C-x C-e ;; current line
M-x eval-region ;; region
M-x eval-buffer ;; whole buffer
M-x load-file ~/.emacs.d/init.el