]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Use unified error handling in search
authorAustin Clements <amdragon@MIT.EDU>
Sat, 15 Dec 2012 20:04:19 +0000 (15:04 -0500)
committerDavid Bremner <bremner@debian.org>
Sun, 16 Dec 2012 21:17:41 +0000 (17:17 -0400)
This slightly changes the output of an existing test since we now
report non-zero exits with a pop-up buffer instead of at the end of
the search results.

emacs/notmuch-lib.el
emacs/notmuch.el
test/emacs-large-search-buffer

index dd2c78baeca928b1b8e239e1e2484d4068de49ac..8e754edf435501c45d45d6e9f44d2cb805baa114 100644 (file)
@@ -334,6 +334,19 @@ the user dismisses it."
          (insert "\n"))))
     (pop-to-buffer buf)))
 
+(defun notmuch-check-async-exit-status (proc msg)
+  "If PROC exited abnormally, pop up an error buffer and signal an error.
+
+This is a wrapper around `notmuch-check-exit-status' for
+asynchronous process sentinels.  PROC and MSG must be the
+arguments passed to the sentinel."
+  (let ((exit-status
+        (case (process-status proc)
+          ((exit) (process-exit-status proc))
+          ((signal) msg))))
+    (when exit-status
+      (notmuch-check-exit-status exit-status (process-command proc)))))
+
 (defun notmuch-check-exit-status (exit-status command &optional output err-file)
   "If EXIT-STATUS is non-zero, pop up an error buffer and signal an error.
 
index 9da8df4d377f31fb5b125a6a3de0774b417ed85e..b0fd387ec0107b92c1b9642ad8e5268ec64d22f5 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,19 @@ 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")
+                   (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"))
index 678328d0ced8ac59974003eeea95e263d44c0ef5..9dcbef5e652d054531c75fe3d2a88bfb00d03d97 100755 (executable)
@@ -36,7 +36,7 @@ test_emacs '(notmuch-search "--this-option-does-not-exist")
 cat <<EOF >EXPECTED
 Error: Unexpected output from notmuch search:
 Unrecognized option: --this-option-does-not-exist
-End of search results. (process returned 1)
+End of search results.
 EOF
 test_expect_equal_file OUTPUT EXPECTED