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.
(insert "\n"))))
(pop-to-buffer buf)))
(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.
(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.
(exit-status (process-exit-status proc))
(never-found-target-thread nil))
(when (memq status '(exit signal))
(exit-status (process-exit-status proc))
(never-found-target-thread nil))
(when (memq status '(exit signal))
(kill-buffer (process-get proc 'parse-buf))
(if (buffer-live-p buffer)
(with-current-buffer buffer
(kill-buffer (process-get proc 'parse-buf))
(if (buffer-live-p buffer)
(with-current-buffer buffer
(if (eq status 'signal)
(insert "Incomplete search results (search process was killed).\n"))
(when (eq status 'exit)
(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))
(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"))
(defcustom notmuch-search-line-faces '(("unread" :weight bold)
("flagged" :foreground "blue"))
cat <<EOF >EXPECTED
Error: Unexpected output from notmuch search:
Unrecognized option: --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)
EOF
test_expect_equal_file OUTPUT EXPECTED
EOF
test_expect_equal_file OUTPUT EXPECTED