[PATCH 6/6] emacs: make `notmuch-search-operate-all' operate on threads, not messages

Pieter Praet pieter at praet.org
Sun Jul 10 08:55:35 PDT 2011


In order to be consistent with `notmuch-search-{add,remove}-tag' ("+"/"-"),
`notmuch-search-operate-all' ("*") should operate on matching threads
instead of matching messages.

Signed-off-by: Pieter Praet <pieter at praet.org>
---
 emacs/notmuch.el |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f11ec24..07899b7 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -834,9 +834,9 @@ non-authors is found, assume that all of the authors match."
       (delete-process proc))))
 
 (defun notmuch-search-operate-all (action)
-  "Add/remove tags from all matching messages.
+  "Add/remove tags from all matching threads.
 
-This command adds or removes tags from all messages matching the
+This command adds or removes tags from all threads matching the
 current search terms. When called interactively, this command
 will prompt for tags to be added or removed. Tags prefixed with
 '+' will be added and tags prefixed with '-' will be removed.
@@ -845,7 +845,10 @@ Each character of the tag name may consist of alphanumeric
 characters as well as `_.+-'.
 "
   (interactive "sOperation (+add -drop): notmuch tag ")
-  (let ((action-split (split-string action " +")))
+  (let ((action-split (split-string action " +"))
+        (threads (mapconcat 'identity
+                           (notmuch-search-find-thread-id-region (point-min) (- (point-max) 2))
+                           " or ")))
     ;; Perform some validation
     (let ((words action-split))
       (when (null words) (error "No operation given"))
@@ -853,7 +856,7 @@ characters as well as `_.+-'.
 	(unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words))
 	  (error "Action must be of the form `+thistag -that_tag'"))
 	(setq words (cdr words))))
-    (apply 'notmuch-tag notmuch-search-query-string action-split)))
+    (apply 'notmuch-tag threads action-split)))
 
 (defun notmuch-search-buffer-title (query)
   "Returns the title for a buffer with notmuch search results."
-- 
1.7.5.4



More information about the notmuch mailing list