mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-28 13:44:12 +01:00
emacs: Use unified error handling in search
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.
This commit is contained in:
parent
b3dc31f78d
commit
19e5b2d912
3 changed files with 22 additions and 6 deletions
|
@ -334,6 +334,19 @@ the user dismisses it."
|
||||||
(insert "\n"))))
|
(insert "\n"))))
|
||||||
(pop-to-buffer buf)))
|
(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)
|
(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.
|
"If EXIT-STATUS is non-zero, pop up an error buffer and signal an error.
|
||||||
|
|
||||||
|
|
|
@ -638,6 +638,7 @@ of the result."
|
||||||
(exit-status (process-exit-status proc))
|
(exit-status (process-exit-status proc))
|
||||||
(never-found-target-thread nil))
|
(never-found-target-thread nil))
|
||||||
(when (memq status '(exit signal))
|
(when (memq status '(exit signal))
|
||||||
|
(catch 'return
|
||||||
(kill-buffer (process-get proc 'parse-buf))
|
(kill-buffer (process-get proc 'parse-buf))
|
||||||
(if (buffer-live-p buffer)
|
(if (buffer-live-p buffer)
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
|
@ -648,17 +649,19 @@ of the result."
|
||||||
(if (eq status 'signal)
|
(if (eq status 'signal)
|
||||||
(insert "Incomplete search results (search process was killed).\n"))
|
(insert "Incomplete search results (search process was killed).\n"))
|
||||||
(when (eq status 'exit)
|
(when (eq status 'exit)
|
||||||
(insert "End of search results.")
|
(insert "End of search results.\n")
|
||||||
(unless (= exit-status 0)
|
(condition-case nil
|
||||||
(insert (format " (process returned %d)" exit-status)))
|
(notmuch-check-async-exit-status proc msg)
|
||||||
(insert "\n")
|
;; Suppress the error signal since strange
|
||||||
|
;; things happen if a sentinel signals.
|
||||||
|
(error (throw 'return nil)))
|
||||||
(if (and atbob
|
(if (and atbob
|
||||||
(not (string= notmuch-search-target-thread "found")))
|
(not (string= notmuch-search-target-thread "found")))
|
||||||
(set 'never-found-target-thread t)))))
|
(set 'never-found-target-thread t)))))
|
||||||
(when (and never-found-target-thread
|
(when (and never-found-target-thread
|
||||||
notmuch-search-target-line)
|
notmuch-search-target-line)
|
||||||
(goto-char (point-min))
|
(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)
|
(defcustom notmuch-search-line-faces '(("unread" :weight bold)
|
||||||
("flagged" :foreground "blue"))
|
("flagged" :foreground "blue"))
|
||||||
|
|
|
@ -36,7 +36,7 @@ test_emacs '(notmuch-search "--this-option-does-not-exist")
|
||||||
cat <<EOF >EXPECTED
|
cat <<EOF >EXPECTED
|
||||||
Error: Unexpected output from notmuch search:
|
Error: Unexpected output from notmuch search:
|
||||||
Unrecognized option: --this-option-does-not-exist
|
Unrecognized option: --this-option-does-not-exist
|
||||||
End of search results. (process returned 1)
|
End of search results.
|
||||||
EOF
|
EOF
|
||||||
test_expect_equal_file OUTPUT EXPECTED
|
test_expect_equal_file OUTPUT EXPECTED
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue