Re: [PATCH 6/7] emacs: Use unified error handling in search
authorMark Walters <markwalters1009@gmail.com>
Sat, 15 Dec 2012 09:33:42 +0000 (09:33 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:15 +0000 (09:52 -0800)
47/e8167e4ea458ea46dcf741a468a252cabac89d [new file with mode: 0644]

diff --git a/47/e8167e4ea458ea46dcf741a468a252cabac89d b/47/e8167e4ea458ea46dcf741a468a252cabac89d
new file mode 100644 (file)
index 0000000..7525028
--- /dev/null
@@ -0,0 +1,167 @@
+Return-Path: <m.walters@qmul.ac.uk>\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 80D9C431FC0\r
+       for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 01:33:43 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+       tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+       NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 HWGyivWwFFVF for <notmuch@notmuchmail.org>;\r
+       Sat, 15 Dec 2012 01:33:42 -0800 (PST)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id B42B9431FBF\r
+       for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 01:33:42 -0800 (PST)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+       by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1Tjo7p-0007I9-4L; Sat, 15 Dec 2012 09:33:41 +0000\r
+Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
+       by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1Tjo7o-0006bT-RC; Sat, 15 Dec 2012 09:33:41 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 6/7] emacs: Use unified error handling in search\r
+In-Reply-To: <1355548513-10085-7-git-send-email-amdragon@mit.edu>\r
+References: <1355548513-10085-1-git-send-email-amdragon@mit.edu>\r
+       <1355548513-10085-7-git-send-email-amdragon@mit.edu>\r
+User-Agent: Notmuch/0.14+155~g7edfdc3 (http://notmuchmail.org) Emacs/23.4.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Sat, 15 Dec 2012 09:33:42 +0000\r
+Message-ID: <8738z7hd6x.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 93.97.24.31\r
+X-QM-SPAM-Info: Sender has good ham record.  :)\r
+X-QM-Body-MD5: db77e9b5c352b29a515faba4176923d6 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.8\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+       determine if it is\r
+       spam. We require at least 5.0 points to mark a message as spam.\r
+       This message scored -1.8 points.\r
+       Summary of the scoring: \r
+       * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+       *      medium trust\r
+       *      [138.37.6.40 listed in list.dnswl.org]\r
+       * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+       provider *      (markwalters1009[at]gmail.com)\r
+       *  0.5 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\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 09:33:43 -0000\r
+\r
+\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
+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