[WIP2 10/12] emacs: convert notmuch-search to format-version 3

David Bremner david at tethera.net
Sun Apr 5 15:59:12 PDT 2015


XXX this checks every result to see if it is metadata. This might or
    might not be innefficient

XXX This ignores the actual metadata from the query. Should it do
    something useful?
---
 emacs/notmuch-query.el |  5 +++++
 emacs/notmuch.el       | 15 ++++++++-------
 test/T310-emacs.sh     |  2 +-
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el
index d1daffc..bfef22c 100644
--- a/emacs/notmuch-query.el
+++ b/emacs/notmuch-query.el
@@ -34,6 +34,11 @@ is a possibly empty forest of replies.
     (setq args (append args search-terms))
     (apply #'notmuch-call-notmuch-sexp args)))
 
+
+(defun notmuch-query-metadata-p (result)
+  "Determine if the result is a \"metadata\" object (format-version 3)"
+  (plist-get result :query_type))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Mapping functions across collections of messages.
 
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index ab00454..87caee4 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -793,12 +793,13 @@ non-authors is found, assume that all of the authors match."
 
 This is only called when a result is first inserted so it also
 sets the :orig-tag property."
-  (let ((new-result (plist-put result :orig-tags (plist-get result :tags)))
-	(pos (point-max)))
-    (notmuch-search-show-result new-result pos)
-    (when (string= (plist-get result :thread) notmuch-search-target-thread)
-      (setq notmuch-search-target-thread "found")
-      (goto-char pos))))
+  (unless (notmuch-query-metadata-p result)
+    (let ((new-result (plist-put result :orig-tags (plist-get result :tags)))
+	  (pos (point-max)))
+      (notmuch-search-show-result new-result pos)
+      (when (string= (plist-get result :thread) notmuch-search-target-thread)
+	(setq notmuch-search-target-thread "found")
+	(goto-char pos)))))
 
 (defun notmuch-search-process-filter (proc string)
   "Process and filter the output of \"notmuch search\""
@@ -935,7 +936,7 @@ the configured default sort order."
       (save-excursion
 	(let ((proc (notmuch-start-notmuch
 		     "notmuch-search" buffer #'notmuch-search-process-sentinel
-		     "search" "--format=sexp" "--format-version=2"
+		     "search" "--format=sexp" "--format-version=3"
 		     (if oldest-first
 			 "--sort=oldest-first"
 		       "--sort=newest-first")
diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index d72799b..f460923 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -897,7 +897,7 @@ YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)
 === ERROR ===
 [XXX]
 YYY/notmuch_fail exited with status 1
-command: YYY/notmuch_fail search --format\=sexp --format-version\=2 --sort\=newest-first tag\:inbox
+command: YYY/notmuch_fail search --format\=sexp --format-version\=3 --sort\=newest-first tag\:inbox
 exit status: 1"
 
 test_begin_subtest "Search handles subprocess warnings"
-- 
2.1.4



More information about the notmuch mailing list