Re: [PATCH 6/7] emacs: Use unified error handling in search
authorAustin Clements <amdragon@MIT.EDU>
Sat, 15 Dec 2012 19:52:51 +0000 (14:52 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:19 +0000 (09:52 -0800)
57/653c96e76380df1425b0f8170d4f7a136c416b [new file with mode: 0644]

diff --git a/57/653c96e76380df1425b0f8170d4f7a136c416b b/57/653c96e76380df1425b0f8170d4f7a136c416b
new file mode 100644 (file)
index 0000000..7f66cdc
--- /dev/null
@@ -0,0 +1,175 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 92384431FBC\r
+       for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 11:52:54 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 6HQ8kLnDd7K5 for <notmuch@notmuchmail.org>;\r
+       Sat, 15 Dec 2012 11:52:54 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU\r
+       [18.9.25.12])\r
+       by olra.theworths.org (Postfix) with ESMTP id 8AF47431FB6\r
+       for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 11:52:53 -0800 (PST)\r
+X-AuditID: 1209190c-b7f886d000000936-b3-50ccd514e927\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+       by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 64.5D.02358.415DCC05; Sat, 15 Dec 2012 14:52:52 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id qBFJqqXL011960; \r
+       Sat, 15 Dec 2012 14:52:52 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qBFJqp52023171\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+       Sat, 15 Dec 2012 14:52:52 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1Tjxn1-0003Fn-2L; Sat, 15 Dec 2012 14:52:51 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 6/7] emacs: Use unified error handling in search\r
+In-Reply-To: <8738z7hd6x.fsf@qmul.ac.uk>\r
+References: <1355548513-10085-1-git-send-email-amdragon@mit.edu>\r
+       <1355548513-10085-7-git-send-email-amdragon@mit.edu>\r
+       <8738z7hd6x.fsf@qmul.ac.uk>\r
+User-Agent: Notmuch/0.14+184~gc26cc51 (http://notmuchmail.org) Emacs/23.4.1\r
+       (i486-pc-linux-gnu)\r
+Date: Sat, 15 Dec 2012 14:52:51 -0500\r
+Message-ID: <871uerxfcc.fsf@awakening.csail.mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsUixG6nrity9UyAwarVlhar5/JYXL85k9mB\r
+       yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyjj8fBdLwUv5itt/FrA2ME6Q7GLk5JAQMJF4\r
+       8WsXC4QtJnHh3nq2LkYuDiGBfYwSZ1cvZIVwNjBK7FzwkBHCucgkseDFHSYIZwmjxOu329lB\r
+       +tkENCS27V/OCGKLCLhKPP32mRnEFhZwkbiysR8szglUc+HbQWaI5omMEv86jgIt5OAQFYiX\r
+       OLvUBKSGRUBV4sm6OUwgNi/QfXO7VzFC2IISJ2c+AbuVWUBL4sa/l0wTGAVmIUnNQpJawMi0\r
+       ilE2JbdKNzcxM6c4NVm3ODkxLy+1SNdQLzezRC81pXQTIygkOSV5djC+Oah0iFGAg1GJh3dH\r
+       xOkAIdbEsuLK3EOMkhxMSqK8GZfPBAjxJeWnVGYkFmfEF5XmpBYfYpTgYFYS4U2aD5TjTUms\r
+       rEotyodJSXOwKInzXk656S8kkJ5YkpqdmlqQWgSTleHgUJLgdbgC1ChYlJqeWpGWmVOCkGbi\r
+       4AQZzgM03BSkhre4IDG3ODMdIn+KUVFKnFcAJCEAksgozYPrhaWMV4ziQK8I8yqCVPEA0w1c\r
+       9yugwUxAg5fbgA0uSURISTUw1nV8Oyz4+fvz+247bvK/DlVZ9991GkvMIoOU+V6flzG27Xua\r
+       ptN3Koi3cNc61i6Fy1f12eYZivSZLpnVHfn2w/p1fM3rz7e6FScUpzDLy39MdJle3FPN8NPE\r
+       N8kk2cR2Wdcpe6UFJcoVmSmHksXmechejPf9tDFDzX5N6ibbkK1xlky9LT5KLMUZiYZazEXF\r
+       iQAfg6oT9AIAAA==\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 15 Dec 2012 19:52:54 -0000\r
+\r
+On Sat, 15 Dec 2012, Mark Walters <markwalters1009@gmail.com> wrote:\r
+> On Sat, 15 Dec 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
+>> This slightly changes the output of an existing test since we now\r
+>> report non-zero exits with a pop-up buffer instead of at the end of\r
+>> the search results.\r
+>> ---\r
+>>  emacs/notmuch-lib.el           |   13 +++++++++++++\r
+>>  emacs/notmuch.el               |   13 ++++++++-----\r
+>>  test/emacs-large-search-buffer |    2 +-\r
+>>  3 files changed, 22 insertions(+), 6 deletions(-)\r
+>>\r
+>> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+>> index 9222de8..cf61635 100644\r
+>> --- a/emacs/notmuch-lib.el\r
+>> +++ b/emacs/notmuch-lib.el\r
+>> @@ -332,6 +332,19 @@ the user dismisses it."\r
+>>     (goto-char (point-min))))\r
+>>      (pop-to-buffer buf)))\r
+>>  \r
+>> +(defun notmuch-check-async-exit-status (proc msg)\r
+>> +  "If PROC exited abnormally, pop up an error buffer and signal an error.\r
+>> +\r
+>> +This is a wrapper around `notmuch-check-exit-status' for\r
+>> +asynchronous process sentinels.  PROC and MSG must be the\r
+>> +arguments passed to the sentinel."\r
+>> +  (let ((exit-status\r
+>> +    (case (process-status proc)\r
+>> +      ((exit) (process-exit-status proc))\r
+>> +      ((signal) msg))))\r
+>> +    (when exit-status\r
+>> +      (notmuch-check-exit-status exit-status (process-command proc)))))\r
+>> +\r
+>>  (defun notmuch-check-exit-status (exit-status command &optional output err-file)\r
+>>    "If EXIT-STATUS is non-zero, pop up an error buffer and signal an error.\r
+>>  \r
+>> diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+>> index e25b54e..c20de13 100644\r
+>> --- a/emacs/notmuch.el\r
+>> +++ b/emacs/notmuch.el\r
+>> @@ -637,6 +637,7 @@ of the result."\r
+>>     (exit-status (process-exit-status proc))\r
+>>     (never-found-target-thread nil))\r
+>>      (when (memq status '(exit signal))\r
+>> +      (catch 'return\r
+>>     (kill-buffer (process-get proc 'parse-buf))\r
+>>     (if (buffer-live-p buffer)\r
+>>         (with-current-buffer buffer\r
+>> @@ -647,17 +648,19 @@ of the result."\r
+>>               (if (eq status 'signal)\r
+>>                   (insert "Incomplete search results (search process was killed).\n"))\r
+>>               (when (eq status 'exit)\r
+>> -               (insert "End of search results.")\r
+>> -               (unless (= exit-status 0)\r
+>> -                 (insert (format " (process returned %d)" exit-status)))\r
+>> -               (insert "\n")\r
+>> +               (insert "End of search results.\n")\r
+>> +               (condition-case err\r
+>> +                   (notmuch-check-async-exit-status proc msg)\r
+>> +                 ;; Suppress the error signal since strange\r
+>> +                 ;; things happen if a sentinel signals.\r
+>> +                 (error (throw 'return nil)))\r
+>\r
+> A total triviality (mostly just to check that I am understanding these\r
+> parts): is the "err" after the condition-case used/needed?\r
+\r
+It's not used or needed.  Syntactically you need something there, of\r
+course, so I changed it to nil as Tomi suggested, which causes\r
+condition-case to simply not bind the error value to anything.\r
+\r
+> Best wishes\r
+>\r
+> Mark\r
+>>                 (if (and atbob\r
+>>                          (not (string= notmuch-search-target-thread "found")))\r
+>>                     (set 'never-found-target-thread t)))))\r
+>>           (when (and never-found-target-thread\r
+>>                    notmuch-search-target-line)\r
+>>               (goto-char (point-min))\r
+>> -             (forward-line (1- notmuch-search-target-line))))))))\r
+>> +             (forward-line (1- notmuch-search-target-line)))))))))\r
+>>  \r
+>>  (defcustom notmuch-search-line-faces '(("unread" :weight bold)\r
+>>                                    ("flagged" :foreground "blue"))\r
+>> diff --git a/test/emacs-large-search-buffer b/test/emacs-large-search-buffer\r
+>> index 678328d..9dcbef5 100755\r
+>> --- a/test/emacs-large-search-buffer\r
+>> +++ b/test/emacs-large-search-buffer\r
+>> @@ -36,7 +36,7 @@ test_emacs '(notmuch-search "--this-option-does-not-exist")\r
+>>  cat <<EOF >EXPECTED\r
+>>  Error: Unexpected output from notmuch search:\r
+>>  Unrecognized option: --this-option-does-not-exist\r
+>> -End of search results. (process returned 1)\r
+>> +End of search results.\r
+>>  EOF\r
+>>  test_expect_equal_file OUTPUT EXPECTED\r
+>>  \r
+>> -- \r
+>> 1.7.10.4\r