feature/eval: :eval now accepts functions (refactor emacs-lisp eval fn)
This commit is contained in:
parent
d64ee3c2f6
commit
4aa1427811
4 changed files with 37 additions and 25 deletions
|
@ -4,7 +4,7 @@
|
|||
(defun +eval/buffer ()
|
||||
"Evaluate the whole buffer."
|
||||
(interactive)
|
||||
(cond ((eq major-mode 'emacs-lisp-mode)
|
||||
(cond ((assq major-mode +eval-runners-alist)
|
||||
(+eval/region (point-min) (point-max)))
|
||||
(t (quickrun))))
|
||||
|
||||
|
@ -14,28 +14,9 @@
|
|||
elisp buffer). Otherwise forward the region to Quickrun."
|
||||
(interactive "r")
|
||||
(let ((load-file-name buffer-file-name))
|
||||
(cond ((eq major-mode 'emacs-lisp-mode)
|
||||
(require 'pp)
|
||||
(let ((result (eval (read (buffer-substring-no-properties beg end))))
|
||||
lines)
|
||||
(let ((buf (get-buffer-create "*eval*")))
|
||||
(with-current-buffer buf
|
||||
;; FIXME messy!
|
||||
(read-only-mode -1)
|
||||
(setq-local scroll-margin 0)
|
||||
(erase-buffer)
|
||||
(emacs-lisp-mode)
|
||||
(prin1 result buf)
|
||||
(pp-buffer)
|
||||
(read-only-mode 1)
|
||||
(setq lines (count-lines (point-min) (point-max)))
|
||||
(goto-char (point-min))
|
||||
(when (< lines 5)
|
||||
(message "%s" (buffer-substring (point-min) (point-max)))
|
||||
(kill-buffer buf)))
|
||||
(unless (< lines 5)
|
||||
(doom-popup-buffer buf)))))
|
||||
(t (quickrun-region beg end)))))
|
||||
(if-let (runner (cdr (assq major-mode +eval-runners-alist)))
|
||||
(funcall runner beg end)
|
||||
(quickrun-region beg end))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +eval/region-and-replace (beg end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue