[PATCH v2 4/7] emacs: make emacs tagging use the stdin query functionality

markwalters1009 markwalters1009 at gmail.com
Sat Nov 24 05:20:53 PST 2012


From: Mark Walters <markwalters1009 at gmail.com>

In preparation for the use of large queries in some cases make tagging
from emacs use the new query on stdin functionality. Currently uses
this for all tagging (as I could not see a reason not to).
---
 emacs/notmuch-tag.el |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 4fce3a9..4634b0d 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -59,9 +59,10 @@ the messages that were tagged"
       (setq search-terms (list "*")))
   (split-string
    (with-output-to-string
-     (with-current-buffer standard-output
-       (apply 'call-process notmuch-command nil t
-	      nil "search" "--output=tags" "--exclude=false" search-terms)))
+     (with-temp-buffer
+       (insert (mapconcat 'identity search-terms " "))
+       (apply 'call-process-region (point-min) (point-max) notmuch-command nil
+	      standard-output nil "search" "--output=tags" "--exclude=false" (list "-"))))
    "\n+" t))
 
 (defun notmuch-select-tag-with-completion (prompt &rest search-terms)
@@ -134,8 +135,11 @@ notmuch-after-tag-hook will be run."
 	tag-changes)
   (unless (null tag-changes)
     (run-hooks 'notmuch-before-tag-hook)
-    (apply 'notmuch-call-notmuch-process "tag"
-	   (append tag-changes (list "--" query)))
+    (with-temp-buffer
+      (insert query)
+      (apply 'notmuch-call-notmuch-process-region
+	     (point-min) (point-max)
+	     "tag" (append tag-changes (list "--" "-"))))
     (run-hooks 'notmuch-after-tag-hook))
   ;; in all cases we return tag-changes as a list
   tag-changes)
-- 
1.7.9.1



More information about the notmuch mailing list