Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 91E8E431FC2 for ; Fri, 14 Dec 2012 21:15:30 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9i9+Zuy1QGFr for ; Fri, 14 Dec 2012 21:15:29 -0800 (PST) Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU [18.9.25.15]) by olra.theworths.org (Postfix) with ESMTP id 9C837431FC7 for ; Fri, 14 Dec 2012 21:15:28 -0800 (PST) X-AuditID: 1209190f-b7fec6d00000090d-3b-50cc076f383d Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP id 20.8B.02317.F670CC05; Sat, 15 Dec 2012 00:15:27 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id qBF5FQgg030061; Sat, 15 Dec 2012 00:15:26 -0500 Received: from drake.dyndns.org (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [209.6.116.242]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qBF5FOjT011448 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 15 Dec 2012 00:15:26 -0500 (EST) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1Tjk5s-0002kZ-Bi; Sat, 15 Dec 2012 00:15:24 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 6/7] emacs: Use unified error handling in search Date: Sat, 15 Dec 2012 00:15:12 -0500 Message-Id: <1355548513-10085-7-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355548513-10085-1-git-send-email-amdragon@mit.edu> References: <1355548513-10085-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsUixCmqrZvPfibA4OJ6HYvVc3ksrt+cyezA 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZTSc3c9Y8E2yYt3FS8wNjBdEuhg5OSQETCQO rrzKCGGLSVy4t56ti5GLQ0hgH6PE3OM7oZwNjBIrNp5hhnAeMUncPvMFypnLKPH8/TZmkH42 AQ2JbfuXg80SEZCW2Hl3NiuIzSzgKPF5/yI2EFtYwEHi8eIV7CA2i4CqxJEHT1lAbF6geO/z GewQdyhKdD+bAFbPCdS77OM5sBohoJqzr+6yTmDkX8DIsIpRNiW3Sjc3MTOnODVZtzg5MS8v tUjXRC83s0QvNaV0EyM4lCT5dzB+O6h0iFGAg1GJh3dHxOkAIdbEsuLK3EOMkhxMSqK8txjO BAjxJeWnVGYkFmfEF5XmpBYfYpTgYFYS4RXbAlTOm5JYWZValA+TkuZgURLnvZpy019IID2x JDU7NbUgtQgmK8PBoSTBy84GNFSwKDU9tSItM6cEIc3EwQkynAdoOBdIDW9xQWJucWY6RP4U o6KUOO8TVqCEAEgiozQPrhcW668YxYFeEeaVB2nnAaYJuO5XQIOZgAbHXToOMrgkESEl1cCY N0GBI+rLPudp23Ljr0UorDTLnRuqdbtu7evwhSGzls2VrelUEpe54Rb7OmH6uZXSypnCh97y c53dIsXqNc2u0NB5+Ye3vMrW7cqvJefw2kzOm90z/daxZ0L3LfPSbB/d/b3+oahhw/95V/8z cJQuTum+F3Jx/czNDt9/f5ulm/zz3qzqlODnSizFGYmGWsxFxYkA988Uh9ACAAA= X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Dec 2012 05:15:30 -0000 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))) (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 <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