[PATCH 4/4] emacs: Add pseudo tag to match all messages that have no tags
Jani Nikula
jani at nikula.org
Tue Jun 28 00:31:32 PDT 2011
Add a pseudo tag that matches all the messages that have no tags. Add new
customization option notmuch-tags-nomatch to enable and name the pseudo
tag.
---
emacs/notmuch-hello.el | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index b9c9b01..1770f60 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -53,6 +53,12 @@
string)
:group 'notmuch)
+(defcustom notmuch-tags-nomatch nil
+ "Name of the pseudo tag to match messages that have no tags."
+ :type '(choice (const :tag "Off" nil)
+ string)
+ :group 'notmuch)
+
(defvar notmuch-hello-indent 4
"How much to indent non-headers.")
@@ -352,7 +358,7 @@ Complete list of currently available key bindings:
(defun notmuch-hello-generate-tag-alist ()
"Return an alist from tags to queries to display in the all-tags section."
- (notmuch-remove-if-not
+ (let ((tag-alist (notmuch-remove-if-not
#'cdr
(mapcar (lambda (tag)
(cons tag
@@ -367,7 +373,15 @@ Complete list of currently available key bindings:
(notmuch-remove-if-not
(lambda (tag)
(not (member tag notmuch-hello-hide-tags)))
- (process-lines notmuch-command "search-tags")))))
+ (process-lines notmuch-command "search-tags"))))))
+ (when notmuch-tags-nomatch
+ (let ((no-tag-search
+ (cons notmuch-tags-nomatch
+ (mapconcat (lambda (arg) (concat "(not (" (cdr arg) "))")) tag-alist " and "))))
+ (if (> (string-to-number (notmuch-saved-search-count (cdr no-tag-search))) 0)
+ ;; Append the no-match search.
+ (add-to-list 'tag-alist no-tag-search t))))
+ tag-alist))
(defun notmuch-hello-saved-alist ()
(if notmuch-saved-searches
--
1.7.1
More information about the notmuch
mailing list