emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/notmuch-indicator c3ab5056b7 1/4: Omit nil counters fro


From: ELPA Syncer
Subject: [elpa] externals/notmuch-indicator c3ab5056b7 1/4: Omit nil counters from concatenated indicator
Date: Tue, 1 Aug 2023 09:58:30 -0400 (EDT)

branch: externals/notmuch-indicator
commit c3ab5056b7230553df8c6468dc2388e5bbc3a612
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Omit nil counters from concatenated indicator
    
    This means that we return "A | C" instead of "A | | C", when the
    implied B indicator is nil.
---
 notmuch-indicator.el | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/notmuch-indicator.el b/notmuch-indicator.el
index 04788570f2..109af26157 100644
--- a/notmuch-indicator.el
+++ b/notmuch-indicator.el
@@ -187,23 +187,27 @@ option `notmuch-indicator-refresh-count'."
      'help-echo (format "mouse-1: Open notmuch search for `%s'" terms)
      'local-map map)))
 
-(defun notmuch-indicator--format-output (properties)
-  "Format PROPERTIES of `notmuch-indicator-args'."
-  (let ((count (notmuch-indicator--shell-command (plist-get properties 
:terms))))
-    (if (and (zerop (string-to-number count))
-             notmuch-indicator-hide-empty-counters)
-        ""
-      (notmuch-indicator--format-label
-       (plist-get properties :label)
-       count
-       (plist-get properties :face)
-       (plist-get properties :terms)))))
-
-(defun notmuch-indicator--return-count ()
+(defun notmuch-indicator--format-counter (count properties)
+  "Format counter with COUNT and PROPERTIES of `notmuch-indicator-args'."
+  (notmuch-indicator--format-label
+   (plist-get properties :label)
+   count
+   (plist-get properties :face)
+   (plist-get properties :terms)))
+
+(defun notmuch-indicator--get-counters ()
+  "Return `notmuch-indicator-args' per 
`notmuch-indicator-hide-empty-counters'."
+  (delq nil
+        (mapcar
+         (lambda (properties)
+           (let ((count (notmuch-indicator--shell-command (plist-get 
properties :terms))))
+             (unless (and (zerop (string-to-number count))
+                          notmuch-indicator-hide-empty-counters)
+               (notmuch-indicator--format-counter count properties))))
+         notmuch-indicator-args)))
+
   "Parse `notmuch-indicator-args' and format them as single string."
-  (mapconcat
-   #'notmuch-indicator--format-output
-   notmuch-indicator-args " "))
+  (mapconcat #'identity (notmuch-indicator--get-counters) " "))
 
 (defvar notmuch-indicator-string ""
   "String showing the `notmuch-indicator' state.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]