简体   繁体   中英

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 emit Cx e .

Is it possible to evaluate the entire buffer as a single elisp program without a need to position cursor?

M-x eval-buffer

Alt + x ,然后键入'eval-buffer'或只键入其中的一部分并选项卡以自动完成。

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 Cx E .

(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)))

Cc Cl to load the entire file at once.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM