unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: call "notmuch tag" only once when archiving a thread
@ 2012-01-03 18:29 Jani Nikula
  2012-01-04 14:13 ` David Edmondson
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Jani Nikula @ 2012-01-03 18:29 UTC (permalink / raw)
  To: notmuch

Optimize thread archiving by combining all the -inbox tagging operations to
a single "notmuch tag" call. Also skip redisplay of tag changes in current
buffer, as it is immediately killed by the archiving functions.

For threads in the order of tens or a hundred inbox tagged messages, this
gives a noticeable speedup.

On the downside, IIRC Xapian does not perform very well if the query (in
this case a lot of message-ids OR'd together) is very big. It is unknown to
me at which point this approach would become slower than the original one
by one tagging approach, if ever.

Also, this introduces a limitation to the number of messages that can be
archived at the same time (through ARG_MAX limiting the command line). At
least on Linux this seems more like a theoretical limitation than a real
one.

Signed-off-by: Jani Nikula <jani@nikula.org>

---

On my Linux machines, 'getconf ARG_MAX' gives 2097152, leading me to
believe that notmuch-show would choke on the thread that would be limited
by this anyway...
---
 emacs/notmuch-show.el |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5502efd..b9ea839 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1414,11 +1414,28 @@ argument, hide all of the messages."
   (interactive)
   (backward-button 1))
 
+(defun notmuch-show-thread-remove-tag (&rest toremove)
+  "Remove TOREMOVE tags from the current set of messages.
+
+Note: This function does not call `notmuch-show-set-tags' on the
+messages to redisplay the changed tags. This is meant to be
+called by `notmuch-show-archive-thread-internal' which kills the
+buffer afterwards."
+  (goto-char (point-min))
+  (let ((message-ids))
+    (loop do
+	  (let* ((current-tags (notmuch-show-get-tags))
+		 (new-tags (notmuch-show-del-tags-worker current-tags toremove)))
+	    (unless (equal current-tags new-tags)
+	      (add-to-list 'message-ids (notmuch-show-get-message-id))))
+	  until (not (notmuch-show-goto-message-next)))
+    (when message-ids
+      (apply 'notmuch-tag (mapconcat 'identity message-ids " OR ")
+	     (mapcar (lambda (s) (concat "-" s)) toremove)))))
+
 (defun notmuch-show-archive-thread-internal (show-next)
   ;; Remove the tag from the current set of messages.
-  (goto-char (point-min))
-  (loop do (notmuch-show-remove-tag "inbox")
-	until (not (notmuch-show-goto-message-next)))
+  (notmuch-show-thread-remove-tag "inbox")
   ;; Move to the next item in the search results, if any.
   (let ((parent-buffer notmuch-show-parent-buffer))
     (notmuch-kill-this-buffer)
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2012-01-09 11:31 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-03 18:29 [PATCH] emacs: call "notmuch tag" only once when archiving a thread Jani Nikula
2012-01-04 14:13 ` David Edmondson
2012-01-04 14:35 ` Tomi Ollila
2012-01-05 20:10 ` Aaron Ecay
2012-01-05 20:32   ` Jani Nikula
2012-01-05 20:38     ` Jameson Graef Rollins
2012-01-05 20:58       ` Jani Nikula
2012-01-06 21:31         ` Tomi Ollila
2012-01-09  0:56     ` Aaron Ecay
2012-01-09  1:12       ` Austin Clements
2012-01-09  8:15         ` David Edmondson
2012-01-09  8:41         ` Jani Nikula
2012-01-09 10:38           ` Tomi Ollila
2012-01-09 10:46             ` David Edmondson
2012-01-09 11:31         ` Mark Walters

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).