Is it possible to evaluate entire buffer in Emacs?

后端 未结 2 1449
轮回少年
轮回少年 2021-02-07 13:51

Currently, in order to evaluate elist in Emacs, I need to position the cursor on the last parenthesis and emit C-x e.

Is it possible to evaluate the entire

相关标签:
2条回答
  • 2021-02-07 14:11
    M-x eval-buffer
    

    or Alt+x and then type 'eval-buffer' or just type part of it and tab to autocomplete.

    0 讨论(0)
  • 2021-02-07 14:12

    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)))
    
    0 讨论(0)
提交回复
热议问题