lang/emacs-lisp: refactor eval handler

pp-eval-expression does much of what +emacs-lisp-eval used to do.
This commit is contained in:
Henrik Lissner 2019-10-17 02:40:10 -04:00
parent 8407af98fd
commit 2485cac2e0
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -8,31 +8,16 @@
"Evaluate a region and print it to the echo area (if one line long), otherwise "Evaluate a region and print it to the echo area (if one line long), otherwise
to a pop up buffer." to a pop up buffer."
(require 'pp) (require 'pp)
(let ((result (let ((debug-on-error t)
(let ((debug-on-error t) (buffer-file-name (buffer-file-name (buffer-base-buffer)))
(doom--current-module (ignore-errors (doom-module-from-path buffer-file-name)))) (doom--current-module (ignore-errors (doom-module-from-path buffer-file-name)))
(eval (read (temp-buffer-show-hook
(concat "(progn " (cons (if (fboundp '+word-wrap-mode)
(buffer-substring-no-properties beg end) '+word-wrap-mode
"\n)")) 'visual-line-mode)
t))) temp-buffer-show-hook)))
(buf (get-buffer-create "*doom eval*")) (pp-eval-expression
(inhibit-read-only t)) (read (buffer-substring-no-properties beg end)))))
(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))))))
(defvar +emacs-lisp--face nil) (defvar +emacs-lisp--face nil)
;;;###autoload ;;;###autoload