]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Use unified error handling in notmuch-call-notmuch-process
authorAustin Clements <amdragon@MIT.EDU>
Sat, 15 Dec 2012 20:04:15 +0000 (15:04 -0500)
committerDavid Bremner <bremner@debian.org>
Sun, 16 Dec 2012 21:00:00 +0000 (17:00 -0400)
This makes notmuch-call-notmuch-process use the unified CLI error
handling, which basically refines the error handling this function
already did.

emacs/notmuch.el

index f9454d8bd260ca575e82e8bd34b1e1b77eaac4aa..9da8df4d377f31fb5b125a6a3de0774b417ed85e 100644 (file)
@@ -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)))