branch: elpa/flymake-collection
commit 6c1d9de2ad4da11963bfadff2fb9989b27e2ca01
Author: Mohsin Kaleem <mohk...@kisara.moe>
Commit: Mohsin Kaleem <mohk...@kisara.moe>

    flymake-commands: Fix change checker for multi-mode config entries
---
 src/flymake-collection-commands.el |  7 ++++--
 src/flymake-collection-hook.el     | 50 +++++++++-----------------------------
 2 files changed, 17 insertions(+), 40 deletions(-)

diff --git a/src/flymake-collection-commands.el 
b/src/flymake-collection-commands.el
index 1c600154dc..a5a4067f9b 100644
--- a/src/flymake-collection-commands.el
+++ b/src/flymake-collection-commands.el
@@ -30,6 +30,8 @@
 (require 'flymake)
 (require 'flymake-collection-hook)
 
+(eval-when-compile (require 'subr-x))
+
 (defun flymake-collection-change-checker--cands (all-modes)
   "Candidates for `flymake-collection-change-checker'.
 With ALL-MODES fetch all registered flymake checkers even when
@@ -39,7 +41,8 @@ they aren't associated with the current mode."
      (cl-loop for (mode . checkers) in
               (if all-modes
                   flymake-collection-hook-config
-                (list (assoc major-mode flymake-collection-hook-config)))
+                (list (cons major-mode (flymake-collection-hook--checkers 
major-mode))))
+              do (setq mode (ensure-list mode))
               append
               (cl-loop for it in checkers
                        with checker = nil
@@ -60,7 +63,7 @@ See `flymake-collection-change-checker--cands' for a 
description of ALL-MODES."
          (group-function (lambda (cand transform)
                            (if transform
                                cand
-                             (symbol-name (cadr (assoc cand cands))))))
+                             (string-join (mapcar #'symbol-name (cadr (assoc 
cand cands))) "/"))))
          (affix-function (lambda (cands-keys)
                            (cl-loop
                             for cand in cands-keys collect
diff --git a/src/flymake-collection-hook.el b/src/flymake-collection-hook.el
index 1a22b7fefc..deffe8202d 100644
--- a/src/flymake-collection-hook.el
+++ b/src/flymake-collection-hook.el
@@ -116,22 +116,6 @@
   :type 'boolean
   :group 'flymake-collection)
 
-(defun flymake-collection-hook--configured-checkers-for-mode (mode)
-  "Return all checkers configured for MODE in 
`flymake-collection-hook-config'."
-  (cl-dolist (it flymake-collection-hook-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-hook-config'"
-              it))))))
-
 (defun flymake-collection-hook--expand-configs (checkers)
   "Resolve all the checkers in CHECKERS.
 Resolving converts each checker in CHECKERS, which should be the value-type in
@@ -154,18 +138,18 @@ that are not true."
                                       :depth ,depth
                                       :disabled ,(or disabled
                                                      (and predicate
-                                                          (funcall 
predicate))))))
+                                                          (not (funcall 
predicate)))))))
        and if predicated-result
          collect predicated-result))
 
-(defun flymake-collection-hook--checkers ()
-  "Fetch config entries passing the predicate for the current buffer."
+(defun flymake-collection-hook--checkers (mode)
+  "Fetch config entries associated with MODE."
   (let (checkers
-        (modes (list major-mode)))
+        (modes (list mode)))
     (when flymake-collection-hook-inherit-config
-      (let ((mode major-mode))
-        (while (setq mode (get mode 'derived-mode-parent))
-          (push mode modes))))
+      (let ((mode-parent major-mode))
+        (while (setq mode-parent (get mode-parent 'derived-mode-parent))
+          (push mode-parent modes))))
 
     (dolist (it flymake-collection-hook-config)
       (when
@@ -174,25 +158,15 @@ that are not true."
             ((pred consp) (seq-intersection modes (car it)))
             (_
              (user-error "Unknown hook predicate=%s in 
`flymake-collection-hook-config'" it)))
-        (setq checkers (append checkers (cdr it)))))))
+        (setq checkers (append checkers (cdr it)))))
+
+    checkers))
 
 (defun flymake-collection-hook--checker-configs (mode)
   "Fetch the list of diagnostic functions for MODE as plists.
 The plists contains keys for :checker, :depth, :disabled."
-  (let (checkers
-        (modes (list mode)))
-    ;; Consider all the parent modes as well.
-    (when flymake-collection-hook-inherit-config
-      (while (setq mode (get mode 'derived-mode-parent))
-        (push mode modes)))
-    ;; For each mode populate the checkers alist with (checker . depth).
-    (dolist (mode modes)
-      (setq checkers (append
-                      checkers
-                      (flymake-collection-hook--expand-configs
-                       (flymake-collection-hook--configured-checkers-for-mode
-                        mode)))))
-    checkers))
+  (flymake-collection-hook--expand-configs
+   (flymake-collection-hook--checkers mode)))
 
 
 

Reply via email to