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 479F6431FD7 for ; Sat, 15 Dec 2012 12:04:37 -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 IWYJEpgXhICr for ; Sat, 15 Dec 2012 12:04:35 -0800 (PST) Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU [18.7.68.36]) by olra.theworths.org (Postfix) with ESMTP id 0A0F4431FBC for ; Sat, 15 Dec 2012 12:04:34 -0800 (PST) X-AuditID: 12074424-b7fe06d0000008f0-e7-50ccd7d2e158 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP id F0.64.02288.2D7DCC05; Sat, 15 Dec 2012 15:04:34 -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 qBFK4WeL022934; Sat, 15 Dec 2012 15:04:32 -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 qBFK4TMT025686 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 15 Dec 2012 15:04:31 -0500 (EST) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1TjxyG-0007se-Py; Sat, 15 Dec 2012 15:04:28 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v2 6/7] emacs: Use unified error handling in search Date: Sat, 15 Dec 2012 15:04:19 -0500 Message-Id: <1355601860-30121-7-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355601860-30121-1-git-send-email-amdragon@mit.edu> References: <1355601860-30121-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsUixCmqrXvp+pkAg5kbFC1Wz+WxuH5zJrPF m5XzWB2YPXbOusvucfjrQhaPZ6tuMQcwR3HZpKTmZJalFunbJXBlrP/KV/BesmLNjXnsDYzH RboYOTgkBEwkuj9odjFyApliEhfurWfrYuTiEBLYxyixcPNeKGcDo8T3T4eZIZxHTBI7dl1j hXDmMkqceH6RDaSfTUBDYtv+5YwgtoiAtMTOu7NZQWxmgTiJLVP+g8WFBZwlXr9oA4uzCKhK LFrQxQJi8wo4SLxYt5AN4g5Fie5nE8BsTgFHiYmTdzGB2EJANbcXzGGawMi/gJFhFaNsSm6V bm5iZk5xarJucXJiXl5qka65Xm5miV5qSukmRlBosbuo7GBsPqR0iFGAg1GJh3dHxOkAIdbE suLK3EOMkhxMSqK8GZfPBAjxJeWnVGYkFmfEF5XmpBYfYpTgYFYS4U2aD5TjTUmsrEotyodJ SXOwKInzXk+56S8kkJ5YkpqdmlqQWgSTleHgUJLgnXoNqFGwKDU9tSItM6cEIc3EwQkynAdo eDdIDW9xQWJucWY6RP4Uo6KUOO9CkIQASCKjNA+uFxb7rxjFgV4R5t0CUsUDTBtw3a+ABjMB DV5uAza4JBEhJdXAaKQcz/1xr2CsRk/pxs1veHTYauz3+Bnfagn7HKp1IojtRRvj3nD9c7pC ugfOSfxKna77YsF38zL73Vvnck3IljAx33so69iq7LwNna+rJna++7d8/pHtnQ0dPxPtOzaw HIp4/GNi3pbzLR8rr/19uuN7R7Wn0K55M/+9m2GfmKNS9nzWiWSFnUosxRmJhlrMRcWJAFZq EKDYAgAA Cc: tomi.ollila@iki.fi 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 20:04:38 -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 7f7022a..8f84087 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -334,6 +334,19 @@ the user dismisses it." (insert "\n")))) (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 9da8df4..b0fd387 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -638,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 @@ -648,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")) 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