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