branch: externals/notmuch-indicator
commit f043b8a1e8f46f70285cf0d63d3299d71f0b4d15
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
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."