[PATCH 6/7] emacs: Use unified error handling in search
Austin Clements
amdragon at MIT.EDU
Sat Dec 15 11:52:51 PST 2012
On Sat, 15 Dec 2012, Mark Walters <markwalters1009 at gmail.com> wrote:
> On Sat, 15 Dec 2012, Austin Clements <amdragon at MIT.EDU> wrote:
>> 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 | 13 +++++++++++++
>> emacs/notmuch.el | 13 ++++++++-----
>> test/emacs-large-search-buffer | 2 +-
>> 3 files changed, 22 insertions(+), 6 deletions(-)
>>
>> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
>> index 9222de8..cf61635 100644
>> --- a/emacs/notmuch-lib.el
>> +++ b/emacs/notmuch-lib.el
>> @@ -332,6 +332,19 @@ the user dismisses it."
>> (goto-char (point-min))))
>> (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.
>>
>> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
>> index e25b54e..c20de13 100644
>> --- a/emacs/notmuch.el
>> +++ b/emacs/notmuch.el
>> @@ -637,6 +637,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
>> @@ -647,17 +648,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 err
>> + (notmuch-check-async-exit-status proc msg)
>> + ;; Suppress the error signal since strange
>> + ;; things happen if a sentinel signals.
>> + (error (throw 'return nil)))
>
> A total triviality (mostly just to check that I am understanding these
> parts): is the "err" after the condition-case used/needed?
It's not used or needed. Syntactically you need something there, of
course, so I changed it to nil as Tomi suggested, which causes
condition-case to simply not bind the error value to anything.
> Best wishes
>
> Mark
>> (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"))
>> diff --git a/test/emacs-large-search-buffer b/test/emacs-large-search-buffer
>> index 678328d..9dcbef5 100755
>> --- a/test/emacs-large-search-buffer
>> +++ b/test/emacs-large-search-buffer
>> @@ -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
>>
>> --
>> 1.7.10.4
More information about the notmuch
mailing list