[PATCH v2 7/7] emacs: `notmuch-show-toggle-visibility-messages' with prefix arg filters by tag

Pieter Praet pieter at praet.org
Wed Feb 22 10:43:34 PST 2012


* emacs/notmuch-show.el (notmuch-show-toggle-visibility-messages):
  When provided with a prefix arg, prompt the user for a tag.
  Show all messages that have it and hide those that don't.
---
 emacs/notmuch-show.el |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 82d4265..b5e482b 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -38,6 +38,7 @@
 
 (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))
 (declare-function notmuch-fontify-headers "notmuch" nil)
+(declare-function notmuch-select-tag-with-completion "notmuch" (prompt &rest search-terms))
 (declare-function notmuch-read-tag-changes "notmuch" (&optional initial-input &rest search-terms))
 (declare-function notmuch-search-next-thread "notmuch" nil)
 (declare-function notmuch-search-show-thread "notmuch" nil)
@@ -1670,13 +1671,19 @@ (defun notmuch-show-toggle-visibility-message ()
 
 (defun notmuch-show-toggle-visibility-messages ()
   "Toggle the visibility of all messages in the current thread.
-If the current message is visible, hide all messages -- and vice versa."
+If the current message is visible, hide all messages -- and vice versa.
+
+With a prefix argument, prompt for a tag and only show messages which have it."
   (interactive)
-  (let ((visible-p (notmuch-show-message-visible-p)))
+  (let ((visible-p (notmuch-show-message-visible-p))
+	(filter (if current-prefix-arg
+		    (notmuch-select-tag-with-completion "Filter by tag: "))))
     (notmuch-show-mapc
      (lambda () (notmuch-show-message-visible
 		 (notmuch-show-get-message-properties)
-		 (not visible-p)))))
+		 (if current-prefix-arg
+		     (member filter (notmuch-show-get-tags))
+		   (not visible-p))))))
 
   ;; Put the current message properly into focus, but don't
   ;; obscure the presence of previous messages in the thread.
-- 
1.7.8.1



More information about the notmuch mailing list