lang/emacs-lisp: refactor eval handler
pp-eval-expression does much of what +emacs-lisp-eval used to do.
This commit is contained in:
parent
8407af98fd
commit
2485cac2e0
1 changed files with 10 additions and 25 deletions
|
@ -8,31 +8,16 @@
|
|||
"Evaluate a region and print it to the echo area (if one line long), otherwise
|
||||
to a pop up buffer."
|
||||
(require 'pp)
|
||||
(let ((result
|
||||
(let ((debug-on-error t)
|
||||
(doom--current-module (ignore-errors (doom-module-from-path buffer-file-name))))
|
||||
(eval (read
|
||||
(concat "(progn "
|
||||
(buffer-substring-no-properties beg end)
|
||||
"\n)"))
|
||||
t)))
|
||||
(buf (get-buffer-create "*doom eval*"))
|
||||
(inhibit-read-only t))
|
||||
(with-current-buffer buf
|
||||
(read-only-mode +1)
|
||||
(erase-buffer)
|
||||
(setq-local scroll-margin 0)
|
||||
(let (emacs-lisp-mode-hook)
|
||||
(emacs-lisp-mode))
|
||||
(pp result buf)
|
||||
(let ((lines (count-lines (point-min) (point-max))))
|
||||
(if (> lines 1)
|
||||
(save-selected-window
|
||||
(pop-to-buffer buf)
|
||||
(with-current-buffer buf
|
||||
(goto-char (point-min))))
|
||||
(message "%s" (buffer-substring (point-min) (point-max)))
|
||||
(kill-buffer buf))))))
|
||||
(buffer-file-name (buffer-file-name (buffer-base-buffer)))
|
||||
(doom--current-module (ignore-errors (doom-module-from-path buffer-file-name)))
|
||||
(temp-buffer-show-hook
|
||||
(cons (if (fboundp '+word-wrap-mode)
|
||||
'+word-wrap-mode
|
||||
'visual-line-mode)
|
||||
temp-buffer-show-hook)))
|
||||
(pp-eval-expression
|
||||
(read (buffer-substring-no-properties beg end)))))
|
||||
|
||||
(defvar +emacs-lisp--face nil)
|
||||
;;;###autoload
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue