--- /dev/null
+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 8E517429E26\r
+ for <notmuch@notmuchmail.org>; Fri, 31 May 2013 16:43:58 -0700 (PDT)\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 Wbx4rsonJMDj for <notmuch@notmuchmail.org>;\r
+ Fri, 31 May 2013 16:43:51 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu\r
+ [18.7.68.35])\r
+ by olra.theworths.org (Postfix) with ESMTP id 7F074431FBD\r
+ for <notmuch@notmuchmail.org>; Fri, 31 May 2013 16:43:51 -0700 (PDT)\r
+X-AuditID: 12074423-b7f826d000001438-ef-51a935b6424f\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+ by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id CE.9D.05176.6B539A15; Fri, 31 May 2013 19:43:50 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r4VNhnW0028142; \r
+ Fri, 31 May 2013 19:43:50 -0400\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.8/8.12.4) with ESMTP id r4VNhl5b005098\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Fri, 31 May 2013 19:43:49 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1UiYz5-0005Vr-FH; Fri, 31 May 2013 19:43:47 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2 0/5] Make Emacs search use sexp format\r
+In-Reply-To: <87y5aug4gi.fsf@qmul.ac.uk>\r
+References: <1369934016-22308-1-git-send-email-amdragon@mit.edu>\r
+ <87y5aug4gi.fsf@qmul.ac.uk>\r
+User-Agent: Notmuch/0.15.2+133~gf9ff9fd (http://notmuchmail.org) Emacs/23.4.1\r
+ (i486-pc-linux-gnu)\r
+Date: Fri, 31 May 2013 19:43:47 -0400\r
+Message-ID: <87wqqehg0c.fsf@awakening.csail.mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFvrEIsWRmVeSWpSXmKPExsUixCmqrbvNdGWgwY9DNhar5/JYXL85k9ni\r
+ zcp5rA7MHjtn3WX3OPx1IYvHs1W3mAOYo7hsUlJzMstSi/TtErgydt1cz1yw1aVi7o21jA2M\r
+ T0y7GDk5JARMJFrn7GSBsMUkLtxbz9bFyMUhJLCPUWLSrLmsIAkhgY2MEjs2BUIkTjNJzN+x\r
+ jBEisYRRYu5uXRCbTUBDYtv+5WBxEQFXiaffPjN3MXJwMANNbZ8XAhIWFrCVOP9tLxOIzQlU\r
+ vu/qQaj5MRITbm5nBykXFUiUWLA7BsRkEVCVWPOfHaSCF+jM9yveM0LYghInZz4BO5lZQEvi\r
+ xr+XTBMYBWchSc1CklrAyLSKUTYlt0o3NzEzpzg1Wbc4OTEvL7VI10wvN7NELzWldBMjKGjZ\r
+ XZR3MP45qHSIUYCDUYmHt2PVikAh1sSy4srcQ4ySHExKory5JisDhfiS8lMqMxKLM+KLSnNS\r
+ iw8xSnAwK4nw5s8BKudNSaysSi3Kh0lJc7AoifNeS7npLySQnliSmp2aWpBaBJOV4eBQkuDt\r
+ ABkqWJSanlqRlplTgpBm4uAEGc4DNPwhSA1vcUFibnFmOkT+FKOilDjvDZCEAEgiozQPrheW\r
+ VF4xigO9Isz7GKSKB5iQ4LpfAQ1mAhr8xHo5yOCSRISUVANjFhPfrhCDuDipv3wPfsTOeBRX\r
+ mf3gXdvTRnelBxOTnTi/1N2UuXT5yZc3s1nMlBKMV6fpnP1RHZopsiP40ZHcj56VOe9amY5/\r
+ so89O/vctrwnk75s291dlSF1VOzavt8q/68ozswPtYtRmc1v/VxFakopS9kKEbPf2Yc6fkZ7\r
+ LCyZwnk188wxJZbijERDLeai4kQATNEZEAUDAAA=\r
+Cc: tomi.ollila@iki.fi\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: Fri, 31 May 2013 23:43:58 -0000\r
+\r
+On Fri, 31 May 2013, Mark Walters <markwalters1009@gmail.com> wrote:\r
+> This version LGTM +1. I will let you and Tomi decide which shell magic\r
+> to go with.\r
+>\r
+> One very trivial comment on a comment below\r
+>\r
+> Best wishes\r
+>\r
+> Mark\r
+>\r
+> Austin Clements <amdragon@MIT.EDU> writes:\r
+>\r
+>> This is v2 of id:1368851472-5382-1-git-send-email-amdragon@mit.edu.\r
+>> The most substantial change from v1 is that the streaming S-expression\r
+>> parser now requires the caller to invoke it from the appropriate\r
+>> buffer and no longer attempts to track the buffer itself. For subtle\r
+>> reasons arising from per-window points, the only *correct* way to use\r
+>> the interface before required the caller to invoke it from the\r
+>> appropriate buffer anyway (or risk losing track of what had been\r
+>> parsed). The only place that currently invokes the streaming\r
+>> S-expression parser already satisfied this requirement.\r
+>>\r
+>> I decided *not* to use --stderr to redirect stderr. As discussed on\r
+>> IRC, --stderr causes serious problems for wrapper scripts, which\r
+>> either have to handle --stderr themselves or risk mixing their own\r
+>> stderr with stdout (e.g., errors from ssh) or, worse, redirecting\r
+>> notmuch's stderr to a (world-readable) file on a *remote* machine. I\r
+>> did fix the exec-path problem that Tomi pointed out, so\r
+>> notmuch-command will continue to be searched for in exec-path, like it\r
+>> currently is.\r
+>>\r
+>> The diff from v1 is below, with whitespace changes because of\r
+>> re-indentation in the S-expression parser.\r
+>>\r
+>> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+>> index a543471..180f63d 100644\r
+>> --- a/emacs/notmuch-lib.el\r
+>> +++ b/emacs/notmuch-lib.el\r
+>> @@ -493,10 +493,13 @@ status."\r
+>> (let* ((err-file (make-temp-file "nmerr"))\r
+>> ;; Use a pipe\r
+>> (process-connection-type nil)\r
+>> + ;; Find notmuch using Emacs' `exec-path'\r
+>> + (command (or (executable-find notmuch-command)\r
+>> + (error "command not found: %s" notmuch-command)))\r
+>> (proc (apply #'start-process name buffer\r
+>> "sh" "-c"\r
+>> "ERR=\"$1\"; shift; exec \"$0\" \"$@\" 2>\"$ERR\""\r
+>> - notmuch-command err-file args)))\r
+>> + command err-file args)))\r
+>> (process-put proc 'err-file err-file)\r
+>> (process-put proc 'sub-sentinel sentinel)\r
+>> (process-put proc 'real-command (cons notmuch-command args))\r
+>> @@ -507,7 +510,7 @@ status."\r
+>> (let ((err-file (process-get proc 'err-file))\r
+>> (sub-sentinel (process-get proc 'sub-sentinel))\r
+>> (real-command (process-get proc 'real-command)))\r
+>> - (condition-case-unless-debug err\r
+>> + (condition-case err\r
+>> (progn\r
+>> ;; Invoke the sub-sentinel, if any\r
+>> (when sub-sentinel\r
+>> @@ -530,7 +533,8 @@ status."\r
+>> (when warnings\r
+>> (notmuch-logged-error (car warnings) (cdr warnings)))))\r
+>> (error\r
+>> - ;; Don't signal an error from a sentinel\r
+>> + ;; Emacs behaves strangely if error an error escapes from a\r
+>> + ;; sentinel, so turns errors into messages.\r
+>\r
+> 2 typos: "error an error" and turns should be turn.\r
+\r
+Oof. I must have been sleepy when I wrote that. Fixed.\r
+\r
+>> (message "%s" (error-message-string err))))\r
+>> (ignore-errors (delete-file err-file))))\r
+>> \r
+>> diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el\r
+>> index 1b7cf64..d59c0e1 100644\r
+>> --- a/emacs/notmuch-parser.el\r
+>> +++ b/emacs/notmuch-parser.el\r
+>> @@ -21,8 +21,8 @@\r
+>> \r
+>> (require 'cl)\r
+>> \r
+>> -(defun notmuch-sexp-create-parser (buffer)\r
+>> - "Return a streaming S-expression parser that reads from BUFFER.\r
+>> +(defun notmuch-sexp-create-parser ()\r
+>> + "Return a new streaming S-expression parser.\r
+>> \r
+>> This parser is designed to incrementally read an S-expression\r
+>> whose structure is known to the caller. Like a typical\r
+>> @@ -33,12 +33,11 @@ input to be a list and descends into it, allowing its elements to\r
+>> be read one at a time or further descended into. Both functions\r
+>> can return 'retry to indicate that not enough input is available.\r
+>> \r
+>> -The parser always consumes input from BUFFER's point. Hence, the\r
+>> -caller is allowed to delete any data before point and may\r
+>> -resynchronize after an error by moving point."\r
+>> +The parser always consumes input from point in the current\r
+>> +buffer. Hence, the caller is allowed to delete any data before\r
+>> +point and may resynchronize after an error by moving point."\r
+>> \r
+>> (vector 'notmuch-sexp-parser\r
+>> - buffer\r
+>> ;; List depth\r
+>> 0\r
+>> ;; Partial parse position marker\r
+>> @@ -46,13 +45,12 @@ resynchronize after an error by moving point."\r
+>> ;; Partial parse state\r
+>> nil))\r
+>> \r
+>> -(defmacro notmuch-sexp--buffer (sp) `(aref ,sp 1))\r
+>> -(defmacro notmuch-sexp--depth (sp) `(aref ,sp 2))\r
+>> -(defmacro notmuch-sexp--partial-pos (sp) `(aref ,sp 3))\r
+>> -(defmacro notmuch-sexp--partial-state (sp) `(aref ,sp 4))\r
+>> +(defmacro notmuch-sexp--depth (sp) `(aref ,sp 1))\r
+>> +(defmacro notmuch-sexp--partial-pos (sp) `(aref ,sp 2))\r
+>> +(defmacro notmuch-sexp--partial-state (sp) `(aref ,sp 3))\r
+>> \r
+>> (defun notmuch-sexp-read (sp)\r
+>> - "Consume and return the value at point in SP's buffer.\r
+>> + "Consume and return the value at point in the current buffer.\r
+>> \r
+>> Returns 'retry if there is insufficient input to parse a complete\r
+>> value (though it may still move point over whitespace). If the\r
+>> @@ -61,14 +59,13 @@ list, this moves point just past the terminator and returns 'end.\r
+>> Otherwise, this moves point to just past the end of the value and\r
+>> returns the value."\r
+>> \r
+>> - (with-current-buffer (notmuch-sexp--buffer sp)\r
+>> (skip-chars-forward " \n\r\t")\r
+>> (cond ((eobp) 'retry)\r
+>> ((= (char-after) ?\))\r
+>> ;; We've reached the end of a list\r
+>> (if (= (notmuch-sexp--depth sp) 0)\r
+>> ;; .. but we weren't in a list. Let read signal the\r
+>> - ;; error.\r
+>> + ;; error to be consistent with all other code paths.\r
+>> (read (current-buffer))\r
+>> ;; Go up a level and return an end token\r
+>> (decf (notmuch-sexp--depth sp))\r
+>> @@ -124,7 +121,7 @@ returns the value."\r
+>> 'retry))\r
+>> (end-of-file\r
+>> (goto-char start)\r
+>> - 'retry)))))))\r
+>> + 'retry))))))\r
+>> \r
+>> (defun notmuch-sexp-begin-list (sp)\r
+>> "Parse the beginning of a list value and enter the list.\r
+>> @@ -136,7 +133,6 @@ returns t. Later calls to `notmuch-sexp-read' will return the\r
+>> elements inside the list. If the input in buffer is not the\r
+>> beginning of a list, throw invalid-read-syntax."\r
+>> \r
+>> - (with-current-buffer (notmuch-sexp--buffer sp)\r
+>> (skip-chars-forward " \n\r\t")\r
+>> (cond ((eobp) 'retry)\r
+>> ((= (char-after) ?\()\r
+>> @@ -146,7 +142,7 @@ beginning of a list, throw invalid-read-syntax."\r
+>> (t\r
+>> ;; Skip over the bad character like `read' does\r
+>> (forward-char)\r
+>> - (signal 'invalid-read-syntax (list (string (char-before))))))))\r
+>> + (signal 'invalid-read-syntax (list (string (char-before)))))))\r
+>> \r
+>> (defun notmuch-sexp-eof (sp)\r
+>> "Signal an error if there is more data in SP's buffer.\r
+>> @@ -154,10 +150,9 @@ beginning of a list, throw invalid-read-syntax."\r
+>> Moves point to the beginning of any trailing data or to the end\r
+>> of the buffer if there is only trailing whitespace."\r
+>> \r
+>> - (with-current-buffer (notmuch-sexp--buffer sp)\r
+>> (skip-chars-forward " \n\r\t")\r
+>> (unless (eobp)\r
+>> - (error "Trailing garbage following expression"))))\r
+>> + (error "Trailing garbage following expression")))\r
+>> \r
+>> (defvar notmuch-sexp--parser nil\r
+>> "The buffer-local notmuch-sexp-parser instance.\r
+>> @@ -170,7 +165,7 @@ Used by `notmuch-sexp-parse-partial-list'.")\r
+>> (defun notmuch-sexp-parse-partial-list (result-function result-buffer)\r
+>> "Incrementally parse an S-expression list from the current buffer.\r
+>> \r
+>> -This function consume an S-expression list from the current\r
+>> +This function consumes an S-expression list from the current\r
+>> buffer, applying RESULT-FUNCTION in RESULT-BUFFER to each\r
+>> complete value in the list. It operates incrementally and should\r
+>> be called whenever the input buffer has been extended with\r
+>> @@ -180,7 +175,7 @@ move point in the input buffer."\r
+>> ;; Set up the initial state\r
+>> (unless (local-variable-p 'notmuch-sexp--parser)\r
+>> (set (make-local-variable 'notmuch-sexp--parser)\r
+>> - (notmuch-sexp-create-parser (current-buffer)))\r
+>> + (notmuch-sexp-create-parser))\r
+>> (set (make-local-variable 'notmuch-sexp--state) 'begin))\r
+>> (let (done)\r
+>> (while (not done)\r