开发者

Is it possible to evaluate entire buffer in Emacs?

开发者 https://www.devze.com 2022-12-24 08:53 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消