Add a pseudo saved search that matches all the mail that no other saved
search matches. Add new customization option notmuch-saved-searches-nomatch
to enable and name the pseudo saved search.
---
 emacs/notmuch-hello.el |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 84bce3a..b9c9b01 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -47,6 +47,12 @@
   :type 'boolean
   :group 'notmuch)
 
+(defcustom notmuch-saved-searches-nomatch nil
+  "Name of the pseudo saved search that no other saved search matches."
+  :type '(choice (const :tag "Off" nil)
+                string)
+  :group 'notmuch)
+
 (defvar notmuch-hello-indent 4
   "How much to indent non-headers.")
 
@@ -363,6 +369,22 @@ Complete list of currently available key bindings:
              (not (member tag notmuch-hello-hide-tags)))
            (process-lines notmuch-command "search-tags")))))
 
+(defun notmuch-hello-saved-alist ()
+  (if notmuch-saved-searches
+      (let ((saved-alist notmuch-saved-searches))
+       (when notmuch-saved-searches-nomatch
+         ;; Append the no-match search.
+         (add-to-list 'saved-alist
+                      (cons notmuch-saved-searches-nomatch
+                            (mapconcat (lambda (arg) (concat "(not (" (cdr 
arg) "))")) notmuch-saved-searches " and ")) t))
+       ;; Filter out empty saved searches if required.
+       (if notmuch-show-empty-saved-searches
+           saved-alist
+         (loop for elem in saved-alist
+               if (> (string-to-number (notmuch-saved-search-count (cdr 
elem))) 0)
+               collect elem)))
+    notmuch-saved-searches))
+
 ;;;###autoload
 (defun notmuch-hello (&optional no-display)
   "Run notmuch and display saved searches, known tags, etc."
@@ -433,13 +455,7 @@ Complete list of currently available key bindings:
 
     (let ((found-target-pos nil)
          (final-target-pos nil))
-      (let* ((saved-alist
-             ;; Filter out empty saved searches if required.
-             (if notmuch-show-empty-saved-searches
-                 notmuch-saved-searches
-               (loop for elem in notmuch-saved-searches
-                     if (> (string-to-number (notmuch-saved-search-count (cdr 
elem))) 0)
-                     collect elem)))
+      (let* ((saved-alist (notmuch-hello-saved-alist))
             (saved-widest (notmuch-hello-longest-label saved-alist))
             (alltags-alist (if notmuch-show-all-tags-list 
(notmuch-hello-generate-tag-alist)))
             (alltags-widest (notmuch-hello-longest-label alltags-alist))
-- 
1.7.1

_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to