[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/notmuch-indicator e169f26958 19/36: Add notmuch-indicat
From: |
ELPA Syncer |
Subject: |
[elpa] externals/notmuch-indicator e169f26958 19/36: Add notmuch-indicator-hide-empty-counters user option |
Date: |
Wed, 21 Sep 2022 00:59:21 -0400 (EDT) |
branch: externals/notmuch-indicator
commit e169f2695832a30e0b63d765c9f89da04e66115c
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Add notmuch-indicator-hide-empty-counters user option
---
README.md | 3 +++
notmuch-indicator.el | 21 ++++++++++++++++-----
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 74516e0178..d58bd4b5a1 100644
--- a/README.md
+++ b/README.md
@@ -49,3 +49,6 @@ represents seconds.
The user option `notmuch-indicator-force-refresh-commands` accepts as
its value a list of symbols. Those are commands that will forcefully
update the indicator after they are invoked.
+
+The user option `notmuch-indicator-hide-empty-counters` hides zero
+counters from the indicator, when it is set to a non-nil value.
diff --git a/notmuch-indicator.el b/notmuch-indicator.el
index ab346c404d..db654ac391 100644
--- a/notmuch-indicator.el
+++ b/notmuch-indicator.el
@@ -71,6 +71,9 @@
;; The user option `notmuch-indicator-force-refresh-commands' accepts as
;; its value a list of symbols. Those are commands that will forcefully
;; update the indicator after they are invoked.
+;;
+;; The user option `notmuch-indicator-hide-empty-counters' hides zero
+;; counters from the indicator, when it is set to a non-nil value.
;;; Code:
@@ -108,6 +111,11 @@ These form a string like: @50 🤡10."
:type 'list ; TODO 2022-09-19: Use correct type
:group 'notmuch-indicator)
+(defcustom notmuch-indicator-hide-empty-counters nil
+ "When non-nil, hide output of searches that have zero results."
+ :type 'boolean
+ :group 'notmuch-indicator)
+
;; TODO 2022-09-19: If this changes, the `notmuch-indicator-mode' needs
;; to be restarted. We can add a custom setter here. Perhaps there is
;; also some elegant way to handle this when the variable is changed
@@ -130,15 +138,18 @@ option `notmuch-indicator-refresh-count'."
;;;; Helper functions and the minor-mode
+(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)
+ ""
+ (format "%s%s" (or (plist-get properties :label) "")
(replace-regexp-in-string "\n" " " count)))))
+
(defun notmuch-indicator--return-count ()
"Parse `notmuch-indicator-args' and format them as single string."
(mapconcat
(lambda (props)
- (format "%s%s" (or (plist-get props :label) "")
- (replace-regexp-in-string
- "\n" " "
- (shell-command-to-string
- (format "notmuch count %s" (plist-get props :terms))))))
+ (notmuch-indicator--format-output props))
notmuch-indicator-args
" "))
- [elpa] externals/notmuch-indicator 1ef5c043c6 01/36: Add prototype, (continued)
- [elpa] externals/notmuch-indicator 1ef5c043c6 01/36: Add prototype, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator dde1c6cb3d 03/36: Add TODO about not running many timers, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator 94e36aea91 06/36: Remove TODO about notmuch count --batch, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator 60ec338434 10/36: Fix typo in doc string, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator b749c09cb6 16/36: Hint at the notmuch-count(1) manual, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator 7d56164856 05/36: Add COPYING, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator 83e1bd3ceb 07/36: Tweak code to avoid multiple timers, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator b141304bcb 04/36: Add README, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator d24ae8718a 14/36: Add outline headings, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator f716f06aea 11/36: Use ":label" instead of ":specifier", ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator e169f26958 19/36: Add notmuch-indicator-hide-empty-counters user option,
ELPA Syncer <=
- [elpa] externals/notmuch-indicator b225981c47 20/36: Refine how spacing is done, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator 45120219c4 23/36: Tweak spacing in two defcustom, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator 55a759133d 02/36: Tweak notmuch-indicator-args, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator 9a536bf3be 08/36: Add :group to notmuch-indicator-refresh-count, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator 2b390022ad 09/36: BREAKING make notmuch-indicator-args use plists, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator d2edfafc38 15/36: Add user option to update indicator post-command, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator f043b8a1e8 22/36: Abstract notmuch-indicator--format-output, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator c9b7b8c229 26/36: The package is no longer a work-in-progress, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator 62ca2dd0bb 31/36: Refine notmuch-indicator-force-refresh-commands :type, ELPA Syncer, 2022/09/21
- [elpa] externals/notmuch-indicator 6f881fe3c2 32/36: Tweak THE most important part of the package, ELPA Syncer, 2022/09/21