X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch.el;h=b0fd387ec0107b92c1b9642ad8e5268ec64d22f5;hb=0df6dcfe7631b032e26c15ebb9627b3699200022;hp=f9454d8bd260ca575e82e8bd34b1e1b77eaac4aa;hpb=42391b405610f48d81a369e899d0be9c9b0ee969;p=notmuch diff --git a/emacs/notmuch.el b/emacs/notmuch.el index f9454d8b..b0fd387e 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -536,19 +536,13 @@ If BARE is set then do not prefix with \"thread:\"" (defun notmuch-call-notmuch-process (&rest args) "Synchronously invoke \"notmuch\" with the given list of arguments. -Output from the process will be presented to the user as an error -and will also appear in a buffer named \"*Notmuch errors*\"." - (let ((error-buffer (get-buffer-create "*Notmuch errors*"))) - (with-current-buffer error-buffer - (erase-buffer)) - (if (eq (apply 'call-process notmuch-command nil error-buffer nil args) 0) - (point) - (progn - (with-current-buffer error-buffer - (let ((beg (point-min)) - (end (- (point-max) 1))) - (error (buffer-substring beg end)) - )))))) +If notmuch exits with a non-zero status, output from the process +will appear in a buffer named \"*Notmuch errors*\" and an error +will be signaled." + (with-temp-buffer + (let ((status (apply #'call-process notmuch-command nil t nil args))) + (notmuch-check-exit-status status (cons notmuch-command args) + (buffer-string))))) (defun notmuch-search-set-tags (tags &optional pos) (let ((new-result (plist-put (notmuch-search-get-result pos) :tags tags))) @@ -644,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 @@ -654,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"))