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:
parent
73d975de6c
commit
2da7c7b168
1 changed files with 19 additions and 16 deletions
|
@ -37,8 +37,10 @@ recognized:
|
||||||
"Alist mapping major modes to interactive runner functions.")
|
"Alist mapping major modes to interactive runner functions.")
|
||||||
|
|
||||||
;;;###autodef
|
;;;###autodef
|
||||||
(defun set-eval-handler! (mode command)
|
(defun set-eval-handler! (modes command)
|
||||||
"Define a code evaluator for major mode MODE with `quickrun'.
|
"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
|
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'.
|
COMMAND is a string key for an entry in `quickrun-file-alist'.
|
||||||
|
@ -50,17 +52,18 @@ recognized:
|
||||||
4. If MODE is not a string and COMMANd is a symbol, add it to
|
4. If MODE is not a string and COMMANd is a symbol, add it to
|
||||||
`+eval-runners', which is used by `+eval/region'."
|
`+eval-runners', which is used by `+eval/region'."
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
(cond ((symbolp command)
|
(dolist (mode (doom-enlist modes))
|
||||||
(push (cons mode command) +eval-runners))
|
(cond ((symbolp command)
|
||||||
((stringp command)
|
(push (cons mode command) +eval-runners))
|
||||||
(after! quickrun
|
((stringp command)
|
||||||
(push (cons mode command)
|
(after! quickrun
|
||||||
(if (stringp mode)
|
(push (cons mode command)
|
||||||
quickrun-file-alist
|
(if (stringp mode)
|
||||||
quickrun--major-mode-alist))))
|
quickrun-file-alist
|
||||||
((listp command)
|
quickrun--major-mode-alist))))
|
||||||
(after! quickrun
|
((listp command)
|
||||||
(quickrun-add-command
|
(after! quickrun
|
||||||
(or (cdr (assq mode quickrun--major-mode-alist))
|
(quickrun-add-command
|
||||||
(string-remove-suffix "-mode" (symbol-name mode)))
|
(or (cdr (assq mode quickrun--major-mode-alist))
|
||||||
command :mode mode)))))
|
(string-remove-suffix "-mode" (symbol-name mode)))
|
||||||
|
command :mode mode))))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue