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 92384431FBC for ; Sat, 15 Dec 2012 11:52:54 -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 6HQ8kLnDd7K5 for ; Sat, 15 Dec 2012 11:52:54 -0800 (PST) Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU [18.9.25.12]) by olra.theworths.org (Postfix) with ESMTP id 8AF47431FB6 for ; Sat, 15 Dec 2012 11:52:53 -0800 (PST) X-AuditID: 1209190c-b7f886d000000936-b3-50ccd514e927 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP id 64.5D.02358.415DCC05; Sat, 15 Dec 2012 14:52:52 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id qBFJqqXL011960; Sat, 15 Dec 2012 14:52:52 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qBFJqp52023171 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Sat, 15 Dec 2012 14:52:52 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) (envelope-from ) id 1Tjxn1-0003Fn-2L; Sat, 15 Dec 2012 14:52:51 -0500 From: Austin Clements To: Mark Walters , notmuch@notmuchmail.org Subject: Re: [PATCH 6/7] emacs: Use unified error handling in search In-Reply-To: <8738z7hd6x.fsf@qmul.ac.uk> References: <1355548513-10085-1-git-send-email-amdragon@mit.edu> <1355548513-10085-7-git-send-email-amdragon@mit.edu> <8738z7hd6x.fsf@qmul.ac.uk> User-Agent: Notmuch/0.14+184~gc26cc51 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu) Date: Sat, 15 Dec 2012 14:52:51 -0500 Message-ID: <871uerxfcc.fsf@awakening.csail.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsUixG6nrity9UyAwarVlhar5/JYXL85k9mB yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyjj8fBdLwUv5itt/FrA2ME6Q7GLk5JAQMJF4 8WsXC4QtJnHh3nq2LkYuDiGBfYwSZ1cvZIVwNjBK7FzwkBHCucgkseDFHSYIZwmjxOu329lB +tkENCS27V/OCGKLCLhKPP32mRnEFhZwkbiysR8szglUc+HbQWaI5omMEv86jgIt5OAQFYiX OLvUBKSGRUBV4sm6OUwgNi/QfXO7VzFC2IISJ2c+AbuVWUBL4sa/l0wTGAVmIUnNQpJawMi0 ilE2JbdKNzcxM6c4NVm3ODkxLy+1SNdQLzezRC81pXQTIygkOSV5djC+Oah0iFGAg1GJh3dH xOkAIdbEsuLK3EOMkhxMSqK8GZfPBAjxJeWnVGYkFmfEF5XmpBYfYpTgYFYS4U2aD5TjTUms rEotyodJSXOwKInzXk656S8kkJ5YkpqdmlqQWgSTleHgUJLgdbgC1ChYlJqeWpGWmVOCkGbi 4AQZzgM03BSkhre4IDG3ODMdIn+KUVFKnFcAJCEAksgozYPrhaWMV4ziQK8I8yqCVPEA0w1c 9yugwUxAg5fbgA0uSURISTUw1nV8Oyz4+fvz+247bvK/DlVZ9991GkvMIoOU+V6flzG27Xua ptN3Koi3cNc61i6Fy1f12eYZivSZLpnVHfn2w/p1fM3rz7e6FScUpzDLy39MdJle3FPN8NPE N8kk2cR2Wdcpe6UFJcoVmSmHksXmechejPf9tDFDzX5N6ibbkK1xlky9LT5KLMUZiYZazEXF iQAfg6oT9AIAAA== 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 19:52:54 -0000 On Sat, 15 Dec 2012, Mark Walters wrote: > On Sat, 15 Dec 2012, Austin Clements 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 <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