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>")
|
(interactive "<r>")
|
||||||
(cond ((eq major-mode 'emacs-lisp-mode)
|
(cond ((eq major-mode 'emacs-lisp-mode)
|
||||||
(require 'pp)
|
(require 'pp)
|
||||||
(let* ((pp-escape-newlines nil)
|
(let ((result (eval (read (buffer-substring-no-properties beg end))))
|
||||||
(out (pp-to-string (eval (read (buffer-substring-no-properties beg end)))))
|
lines)
|
||||||
(lines (length (s-lines out))))
|
(let ((buf (get-buffer-create "*eval*")))
|
||||||
(if (< lines 5)
|
(with-current-buffer buf
|
||||||
(princ out t)
|
(read-only-mode -1)
|
||||||
(let ((buf (get-buffer-create "*eval*")))
|
(setq-local scroll-margin 0)
|
||||||
(with-current-buffer buf
|
(erase-buffer)
|
||||||
(read-only-mode -1)
|
(prin1 result buf)
|
||||||
(setq-local scroll-margin 0)
|
(emacs-lisp-mode)
|
||||||
(emacs-lisp-mode)
|
(pp-buffer)
|
||||||
(erase-buffer)
|
(read-only-mode 1)
|
||||||
(insert out)
|
(setq lines (count-lines (point-min) (point-max)))
|
||||||
(read-only-mode 1)
|
(goto-char (point-min))
|
||||||
(goto-char (point-min)))
|
(when (< lines 5)
|
||||||
(pop-to-buffer buf)))))
|
(message "%s" (buffer-substring (point-min) (point-max)))))
|
||||||
|
(unless (< lines 5)
|
||||||
|
(doom/popup-buffer buf)))))
|
||||||
(t (quickrun-region beg end))))
|
(t (quickrun-region beg end))))
|
||||||
|
|
||||||
;;;###autoload (autoload 'doom:eval-region-and-replace "defuns-quickrun" nil t)
|
;;;###autoload (autoload 'doom:eval-region-and-replace "defuns-quickrun" nil t)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue