]> git.eshelyaron.com Git - emacs.git/commitdiff
Count Flymake diagnostics in modeline by severity, not type
authorJoão Távora <joaotavora@gmail.com>
Sat, 9 Jan 2021 18:49:49 +0000 (18:49 +0000)
committerJoão Távora <joaotavora@gmail.com>
Sat, 9 Jan 2021 18:50:19 +0000 (18:50 +0000)
Originally reported in https://github.com/joaotavora/eglot/issues/588
by Pankaj Jangid.

* lisp/progmodes/flymake.el (flymake--mode-line-counter): Count
diagnostics by severity level, not by type.
(Version): Bump to 1.1.1

lisp/progmodes/flymake.el

index fddc13f56b1159731b7954a3257dbe6446bbd128..460af718aadfcc3ec3bbd61866fda384cfd6eaf9 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; Author: Pavel Kobyakov <pk_at_work@yahoo.com>
 ;; Maintainer: João Távora <joaotavora@gmail.com>
-;; Version: 1.1.0
+;; Version: 1.1.1
 ;; Keywords: c languages tools
 ;; Package-Requires: ((emacs "26.1") (eldoc "1.1.0"))
 
@@ -1283,6 +1283,8 @@ correctly.")
   (when (flymake-running-backends) flymake-mode-line-counter-format))
 
 (defun flymake--mode-line-counter (type &optional no-space)
+  "Compute number of diagnostics in buffer with TYPE's severity.
+TYPE is usually keyword `:error', `:warning' or `:note'."
   (let ((count 0)
         (face (flymake--lookup-type-property type
                                              'mode-line-face
@@ -1290,7 +1292,8 @@ correctly.")
     (maphash (lambda
                (_b state)
                (dolist (d (flymake--backend-state-diags state))
-                 (when (eq type (flymake--diag-type d))
+                 (when (= (flymake--severity type)
+                          (flymake--severity (flymake--diag-type d)))
                    (cl-incf count))))
              flymake--backend-state)
     (when (or (cl-plusp count)