Is it possible to evaluate entire buffer in Emacs?

后端 未结 2 1498
轮回少年
轮回少年 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: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)))
    

提交回复
热议问题