Is it possible to evaluate entire buffer in Emacs?
Currently, in order to evaluate elist in Emacs, I need to position the cursor on the last parenthesis and em开发者_StackOverflow中文版it C-x e
.
Is it possible to evaluate the entire buffer as a single elisp program without a need to position cursor?
M-x eval-buffer
or Alt+x and then type 'eval-buffer' or just type part of it and tab to autocomplete.
I placed this in my .emacs
!
It allows you to eval a region if there is one or the entire buffer.
I bound it to C-xE.
(defun eval-region-or-buffer ()
(interactive)
(let ((debug-on-error t))
(cond
(mark-active
(call-interactively 'eval-region)
(message "Region evaluated!")
(setq deactivate-mark t))
(t
(eval-buffer)
(message "Buffer evaluated!")))))
(add-hook 'emacs-lisp-mode-hook
(lambda ()
(local-set-key (kbd "C-x E") 'eval-region-or-buffer)))
C-c C-l
to load the entire file at once.
精彩评论