branch: elpa/flymake-collection commit ca7c840855b2c0410fc716b19ee38b94b77fee5e Author: Mohsin Kaleem <mohk...@kisara.moe> Commit: Mohsin Kaleem <mohk...@kisara.moe>
hook: Allow configuring the same checkers for multiple modes --- src/flymake-collection-hook.el | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/flymake-collection-hook.el b/src/flymake-collection-hook.el index d96374b2c3..e269340c30 100644 --- a/src/flymake-collection-hook.el +++ b/src/flymake-collection-hook.el @@ -78,7 +78,10 @@ (nxml-mode flymake-collection-xmllint)) "Configuration mapping major-modes to `flymake' backends." :type '(alist - :key-type (symbol :tag "Mode") + :key-type + (choice + (symbol :tag "Mode") + (repeat (symbol :tag "Mode"))) :value-type (repeat :tag "Backends" @@ -101,7 +104,18 @@ (defun flymake-collection-hook--configured-checkers-for-mode (mode) "Return all checkers configured for MODE in `flymake-collection-config'." - (alist-get mode flymake-collection-config)) + (cl-dolist (it flymake-collection-config) + (let ((it-mode (car it)) + (it-conf (cdr it))) + (cond ((symbolp it-mode) + (when (equal it-mode mode) + (cl-return it-conf))) + ((consp it) + (when (member mode it-mode) + (cl-return it-conf))) + (t + (user-error "Unknown hook predicate=%s in `flymake-collection-config'" + it)))))) (defun flymake-collection-hook--resolve-configured-checkers (checkers) "Resolve all the checkers in CHECKERS.