--- /dev/null
+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 13AA2431FC7\r
+ for <notmuch@notmuchmail.org>; Sat, 18 May 2013 00:14:58 -0700 (PDT)\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 RdZ3g9mhtsNV for <notmuch@notmuchmail.org>;\r
+ Sat, 18 May 2013 00:14:50 -0700 (PDT)\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 3A41B431FC2\r
+ for <notmuch@notmuchmail.org>; Sat, 18 May 2013 00:14:50 -0700 (PDT)\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 1UdbLk-00038P-Kn; Sat, 18 May 2013 08:14:45 +0100\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.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1UdbLi-0003cM-R8; Sat, 18 May 2013 08:14:40 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 3/5] emacs: Use async process helper for search\r
+In-Reply-To: <1368851472-5382-4-git-send-email-amdragon@mit.edu>\r
+References: <1368851472-5382-1-git-send-email-amdragon@mit.edu>\r
+ <1368851472-5382-4-git-send-email-amdragon@mit.edu>\r
+User-Agent: Notmuch/0.14+255~gff3cc55 (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sat, 18 May 2013 08:14:37 +0100\r
+Message-ID: <87d2sopxnm.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: f1931344fd78c5d3c2596f64ab6eb130 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -0.3\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 -0.3 points.\r
+ Summary of the scoring: \r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+ * -0.3 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, 18 May 2013 07:14:58 -0000\r
+\r
+\r
+I have only very briefly looked at this: it seems to not quite apply to\r
+master (one fix up see below)\r
+\r
+Also, as far as I can see condition-case-unless-debug (used in patch\r
+2/5) is emacs 24 only.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+On Sat, 18 May 2013, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> Previously, search started the async notmuch process directly. Now,\r
+> it uses `notmuch-start-notmuch'. This simplifies the process sentinel\r
+> a bit and means that we no longer have to worry about errors\r
+> interleaved with the JSON output.\r
+>\r
+> We also update the tests of Emacs error handling, since the error\r
+> output is now separated from the search results buffer.\r
+> ---\r
+> emacs/notmuch.el | 19 +++++--------------\r
+> test/emacs | 36 ++++++++++++++++++++++++++++++++----\r
+> 2 files changed, 37 insertions(+), 18 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+> index 4c1a6ca..b8d9c44 100644\r
+> --- a/emacs/notmuch.el\r
+> +++ b/emacs/notmuch.el\r
+> @@ -653,15 +653,8 @@ of the result."\r
+> ;; For version mismatch, there's no point in\r
+> ;; showing the search buffer\r
+> (when (or (= exit-status 20) (= exit-status 21))\r
+> - (kill-buffer))\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. Mimic\r
+> - ;; the top-level's handling of error messages.\r
+> - (error\r
+> - (message "%s" (error-message-string err))\r
+\r
+This line is \r
+ (message "%s" (second err))\r
+in master.\r
+\r
+\r
+> - (throw 'return nil)))\r
+> + (kill-buffer)\r
+> + (throw 'return nil))\r
+> (if (and atbob\r
+> (not (string= notmuch-search-target-thread "found")))\r
+> (set 'never-found-target-thread t)))))\r
+> @@ -938,10 +931,9 @@ Other optional parameters are used as follows:\r
+> (erase-buffer)\r
+> (goto-char (point-min))\r
+> (save-excursion\r
+> - (let ((proc (start-process\r
+> - "notmuch-search" buffer\r
+> - notmuch-command "search"\r
+> - "--format=json" "--format-version=1"\r
+> + (let ((proc (notmuch-start-notmuch\r
+> + "notmuch-search" buffer #'notmuch-search-process-sentinel\r
+> + "search" "--format=json" "--format-version=1"\r
+> (if oldest-first\r
+> "--sort=oldest-first"\r
+> "--sort=newest-first")\r
+> @@ -951,7 +943,6 @@ Other optional parameters are used as follows:\r
+> ;; should be called no matter how the process dies.\r
+> (parse-buf (generate-new-buffer " *notmuch search parse*")))\r
+> (process-put proc 'parse-buf parse-buf)\r
+> - (set-process-sentinel proc 'notmuch-search-process-sentinel)\r
+> (set-process-filter proc 'notmuch-search-process-filter)\r
+> (set-process-query-on-exit-flag proc nil))))\r
+> (run-hooks 'notmuch-search-hook)))\r
+> diff --git a/test/emacs b/test/emacs\r
+> index f033bdf..d38ae8c 100755\r
+> --- a/test/emacs\r
+> +++ b/test/emacs\r
+> @@ -853,11 +853,10 @@ test_expect_success "Rendering HTML mail with images" \\r
+> 'cat OUTPUT && grep -q smiley OUTPUT'\r
+> \r
+> \r
+> -test_begin_subtest "Search handles subprocess errors"\r
+> +test_begin_subtest "Search handles subprocess error exit codes"\r
+> cat > notmuch_fail <<EOF\r
+> #!/bin/sh\r
+> echo This is output\r
+> -echo This is an error >&2\r
+> exit 1\r
+> EOF\r
+> chmod a+x notmuch_fail\r
+> @@ -874,8 +873,6 @@ sed -i -e 's/^\[.*\]$/[XXX]/' ERROR\r
+> test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\\r
+> Error: Unexpected output from notmuch search:\r
+> This is output\r
+> -Error: Unexpected output from notmuch search:\r
+> -This is an error\r
+> End of search results.\r
+> ---\r
+> $PWD/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)\r
+> @@ -885,4 +882,35 @@ $PWD/notmuch_fail exited with status 1\r
+> command: $PWD/notmuch_fail search --format\=json --format-version\=1 --sort\=newest-first tag\:inbox\r
+> exit status: 1"\r
+> \r
+> +test_begin_subtest "Search handles subprocess warnings"\r
+> +cat > notmuch_fail <<EOF\r
+> +#!/bin/sh\r
+> +echo This is output\r
+> +echo This is a warning >&2\r
+> +echo This is another warning >&2\r
+> +exit 0\r
+> +EOF\r
+> +chmod a+x notmuch_fail\r
+> +test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))\r
+> + (with-current-buffer \"*Messages*\" (erase-buffer))\r
+> + (with-current-buffer \"*Notmuch errors*\" (erase-buffer))\r
+> + (notmuch-search \"tag:inbox\")\r
+> + (notmuch-test-wait)\r
+> + (with-current-buffer \"*Messages*\"\r
+> + (test-output \"MESSAGES\"))\r
+> + (with-current-buffer \"*Notmuch errors*\"\r
+> + (test-output \"ERROR\"))\r
+> + (test-output))"\r
+> +sed -i -e 's/^\[.*\]$/[XXX]/' ERROR\r
+> +test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\\r
+> +Error: Unexpected output from notmuch search:\r
+> +This is output\r
+> +End of search results.\r
+> +---\r
+> +This is a warning (see *Notmuch errors* for more details)\r
+> +---\r
+> +[XXX]\r
+> +This is a warning\r
+> +This is another warning"\r
+> +\r
+> test_done\r
+> -- \r
+> 1.7.10.4\r