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

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

[elpa] externals/notmuch-indicator f043b8a1e8 22/36: Abstract notmuch-in


From: ELPA Syncer
Subject: [elpa] externals/notmuch-indicator f043b8a1e8 22/36: Abstract notmuch-indicator--format-output
Date: Wed, 21 Sep 2022 00:59:21 -0400 (EDT)

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

    Abstract notmuch-indicator--format-output
---
 notmuch-indicator.el | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/notmuch-indicator.el b/notmuch-indicator.el
index 89eb395967..f3404f05a8 100644
--- a/notmuch-indicator.el
+++ b/notmuch-indicator.el
@@ -138,12 +138,24 @@ option `notmuch-indicator-refresh-count'."
 
 ;;;; Helper functions and the minor-mode
 
+(defun notmuch-indicator--shell-command (terms)
+  "Run shell command for `notmuch-count(1)' with TERMS."
+  (replace-regexp-in-string
+   "\n" " "
+   (shell-command-to-string
+    (format "notmuch count %s" terms))))
+
+(defun notmuch-indicator--format-label (label count)
+  "Format LABEL and COUNT of `notmuch-indicator-args'."
+  (format "%s%s " (or label  "") count))
+
 (defun notmuch-indicator--format-output (properties)
   "Format PROPERTIES of `notmuch-indicator-args'."
-  (let ((count (shell-command-to-string (format "notmuch count %s" (plist-get 
properties :terms)))))
-    (if (and (zerop (string-to-number count)) 
notmuch-indicator-hide-empty-counters)
+  (let ((count (notmuch-indicator--shell-command (plist-get properties 
:terms))))
+    (if (and (zerop (string-to-number count))
+             notmuch-indicator-hide-empty-counters)
         ""
-      (format "%s%s " (or (plist-get properties :label)  "") 
(replace-regexp-in-string "\n" " " count)))))
+      (notmuch-indicator--format-label (plist-get properties :label) count))))
 
 (defun notmuch-indicator--return-count ()
   "Parse `notmuch-indicator-args' and format them as single string."



reply via email to

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