]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch.el
emacs: Use --format-version for search, show, and reply
[notmuch] / emacs / notmuch.el
index 9da8df4d377f31fb5b125a6a3de0774b417ed85e..63387a2dfe28c85fce445dc0a1f74d63498f3d0f 100644 (file)
@@ -638,6 +638,7 @@ of the result."
        (exit-status (process-exit-status proc))
        (never-found-target-thread nil))
     (when (memq status '(exit signal))
+      (catch 'return
        (kill-buffer (process-get proc 'parse-buf))
        (if (buffer-live-p buffer)
            (with-current-buffer buffer
@@ -648,17 +649,23 @@ of the result."
                  (if (eq status 'signal)
                      (insert "Incomplete search results (search process was killed).\n"))
                  (when (eq status 'exit)
-                   (insert "End of search results.")
-                   (unless (= exit-status 0)
-                     (insert (format " (process returned %d)" exit-status)))
-                   (insert "\n")
+                   (insert "End of search results.\n")
+                   ;; For version mismatch, there's no point in
+                   ;; showing the search buffer
+                   (when (or (= exit-status 20) (= exit-status 21))
+                     (kill-buffer))
+                   (condition-case nil
+                       (notmuch-check-async-exit-status proc msg)
+                     ;; Suppress the error signal since strange
+                     ;; things happen if a sentinel signals.
+                     (error (throw 'return nil)))
                    (if (and atbob
                             (not (string= notmuch-search-target-thread "found")))
                        (set 'never-found-target-thread t)))))
              (when (and never-found-target-thread
                       notmuch-search-target-line)
                  (goto-char (point-min))
-                 (forward-line (1- notmuch-search-target-line))))))))
+                 (forward-line (1- notmuch-search-target-line)))))))))
 
 (defcustom notmuch-search-line-faces '(("unread" :weight bold)
                                       ("flagged" :foreground "blue"))
@@ -932,7 +939,7 @@ Other optional parameters are used as follows:
        (let ((proc (start-process
                     "notmuch-search" buffer
                     notmuch-command "search"
-                    "--format=json"
+                    "--format=json" "--format-version=1"
                     (if oldest-first
                         "--sort=oldest-first"
                       "--sort=newest-first")