tools/eval: make set-eval-handler! accept a list of modes

Fixes inline evaluation for emacs-lisp-mode due to 322bca7.
This commit is contained in:
Henrik Lissner 2019-12-20 02:34:29 -05:00
parent 73d975de6c
commit 2da7c7b168
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -37,8 +37,10 @@ recognized:
"Alist mapping major modes to interactive runner functions.")
;;;###autodef
(defun set-eval-handler! (mode command)
"Define a code evaluator for major mode MODE with `quickrun'.
(defun set-eval-handler! (modes command)
"Define a code evaluator for major mode MODES with `quickrun'.
MODES can be list of major mode symbols, or a single one.
1. If MODE is a string and COMMAND is the string, MODE is a file regexp and
COMMAND is a string key for an entry in `quickrun-file-alist'.
@ -50,6 +52,7 @@ recognized:
4. If MODE is not a string and COMMANd is a symbol, add it to
`+eval-runners', which is used by `+eval/region'."
(declare (indent defun))
(dolist (mode (doom-enlist modes))
(cond ((symbolp command)
(push (cons mode command) +eval-runners))
((stringp command)
@ -63,4 +66,4 @@ recognized:
(quickrun-add-command
(or (cdr (assq mode quickrun--major-mode-alist))
(string-remove-suffix "-mode" (symbol-name mode)))
command :mode mode)))))
command :mode mode))))))