Refactor doom:eval-region
This commit is contained in:
parent
f58df5f061
commit
238bfc3712
1 changed files with 17 additions and 15 deletions
|
@ -48,21 +48,23 @@ elisp buffer). Otherwise forward the region to Quickrun."
|
|||
(interactive "<r>")
|
||||
(cond ((eq major-mode 'emacs-lisp-mode)
|
||||
(require 'pp)
|
||||
(let* ((pp-escape-newlines nil)
|
||||
(out (pp-to-string (eval (read (buffer-substring-no-properties beg end)))))
|
||||
(lines (length (s-lines out))))
|
||||
(if (< lines 5)
|
||||
(princ out t)
|
||||
(let ((result (eval (read (buffer-substring-no-properties beg end))))
|
||||
lines)
|
||||
(let ((buf (get-buffer-create "*eval*")))
|
||||
(with-current-buffer buf
|
||||
(read-only-mode -1)
|
||||
(setq-local scroll-margin 0)
|
||||
(emacs-lisp-mode)
|
||||
(erase-buffer)
|
||||
(insert out)
|
||||
(prin1 result buf)
|
||||
(emacs-lisp-mode)
|
||||
(pp-buffer)
|
||||
(read-only-mode 1)
|
||||
(goto-char (point-min)))
|
||||
(pop-to-buffer buf)))))
|
||||
(setq lines (count-lines (point-min) (point-max)))
|
||||
(goto-char (point-min))
|
||||
(when (< lines 5)
|
||||
(message "%s" (buffer-substring (point-min) (point-max)))))
|
||||
(unless (< lines 5)
|
||||
(doom/popup-buffer buf)))))
|
||||
(t (quickrun-region beg end))))
|
||||
|
||||
;;;###autoload (autoload 'doom:eval-region-and-replace "defuns-quickrun" nil t)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue