--- /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 4AC4E431FBC\r
+ for <notmuch@notmuchmail.org>; Thu, 13 Dec 2012 03:00: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 afw67v0E+FnS for <notmuch@notmuchmail.org>;\r
+ Thu, 13 Dec 2012 03:00: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 48794431FB6\r
+ for <notmuch@notmuchmail.org>; Thu, 13 Dec 2012 03:00: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 1Tj6Wk-0007mi-Ux; Thu, 13 Dec 2012 11:00:36 +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 1Tj6Wk-0007MG-FX; Thu, 13 Dec 2012 11:00:30 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>,notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 07/10] emacs: Use --use-schema for search\r
+In-Reply-To: <20121213014341.GC6187@mit.edu>\r
+References: <1354416002-3557-1-git-send-email-amdragon@mit.edu>\r
+ <1354416002-3557-7-git-send-email-amdragon@mit.edu>\r
+ <87ehj1gc9x.fsf@qmul.ac.uk> <20121213014341.GC6187@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: Thu, 13 Dec 2012 11:00:32 +0000\r
+Message-ID: <87wqwmdxnz.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: b59664664e3162e334e982da296f1eba (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: Thu, 13 Dec 2012 11:00:43 -0000\r
+\r
+On Thu, 13 Dec 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> Quoth Mark Walters on Dec 08 at 8:48 am:\r
+>> On Sun, 02 Dec 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
+>> > We detect the special exit statuses and use these to produce specific\r
+>> > diagnostic messages.\r
+>> > ---\r
+>> > emacs/notmuch-lib.el | 32 ++++++++++++++++++++++++++++++++\r
+>> > emacs/notmuch.el | 17 +++++++++++++----\r
+>> > 2 files changed, 45 insertions(+), 4 deletions(-)\r
+>> >\r
+>> > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+>> > index 9402456..49b0da6 100644\r
+>> > --- a/emacs/notmuch-lib.el\r
+>> > +++ b/emacs/notmuch-lib.el\r
+>> > @@ -325,6 +325,38 @@ string), a property list of face attributes, or a list of these."\r
+>> > (put-text-property pos next 'face (cons face cur))\r
+>> > (setq pos next)))))\r
+>> > \r
+>> > +(defun notmuch-pop-up-error (msg)\r
+>> > + "Pop up an error buffer displaying MSG."\r
+>> > +\r
+>> > + (let ((buf (get-buffer-create "*Notmuch errors*")))\r
+>> > + (with-current-buffer buf\r
+>> > + (view-mode)\r
+>> > + (let ((inhibit-read-only t))\r
+>> > + (erase-buffer)\r
+>> > + (insert msg)\r
+>> > + (unless (bolp)\r
+>> > + (insert "\n"))\r
+>> > + (goto-char (point-min))))\r
+>> > + (pop-to-buffer buf)))\r
+>> \r
+>> I am not sure about the erase-buffer in the above: do we definitely want\r
+>> to remove all previous error information? For version mismatch possibly\r
+>> we do but in patch 9 it is done for all show command-line error returns.\r
+>\r
+> Why wouldn't we want to use a cleared buffer in all cases?\r
+> notmuch-pop-up-error is only ever used when a command terminates, so\r
+> there's no danger of us clearing errors that the user hasn't seen yet.\r
+\r
+Just to make sure I understand this: whenever an error occurs the error\r
+popup appears so we see the message. Then the next error can safely\r
+erase buffer before showing the new error message?\r
+\r
+>> Incidentally why does show always pop-up an error but search only for\r
+>> version-mismatches?\r
+>\r
+> Historical reasons, I suppose. I was maintaining the status quo for\r
+> search (which already had *some* error handling), but there was no\r
+> error-handling status quo for show. Probably search should be more\r
+> vocal when the command fails.\r
+\r
+Should notmuch-call-notmuch-process also be switched to this framework?\r
+In particular that also puts errors in "*Notmuch errors*" so my earlier\r
+concern may be valid in this case.\r
+\r
+Best wishes\r
+\r
+Mark\r
+>\r
+>> Otherwise this looks good to me (but I am not that familiar with lisp\r
+>> error handling)\r
+>> \r
+>> Best wishes\r
+>> \r
+>> Mark\r
+>> \r
+>> \r
+>> \r
+>> \r
+>> \r
+>> \r
+>> > +(defun notmuch-version-mismatch-error (exit-status)\r
+>> > + "Signal a schema version mismatch error.\r
+>> > +\r
+>> > +EXIT-STATUS must be the exit status of the notmuch CLI command,\r
+>> > +and must have the value 20 or 21. This function will pop up an\r
+>> > +error buffer with a descriptive message and signal an error."\r
+>> > + (cond ((= exit-status 20)\r
+>> > + (notmuch-pop-up-error "Error: Version mismatch.\r
+>> > +Emacs requested an older output format than supported by the notmuch CLI.\r
+>> > +You may need to restart Emacs or upgrade your notmuch Emacs package."))\r
+>> > + ((= exit-status 21)\r
+>> > + (notmuch-pop-up-error "Error: Version mismatch.\r
+>> > +Emacs requested a newer output format than supported by the notmuch CLI.\r
+>> > +You may need to restart Emacs or upgrade your notmuch package."))\r
+>> > + (t\r
+>> > + (error "Bad exit status %d" exit-status)))\r
+>> > + (error "notmuch CLI version mismatch"))\r
+>> > +\r
+>> > ;; Compatibility functions for versions of emacs before emacs 23.\r
+>> > ;;\r
+>> > ;; Both functions here were copied from emacs 23 with the following copyright:\r
+>> > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+>> > index f9454d8..e1f28ca 100644\r
+>> > --- a/emacs/notmuch.el\r
+>> > +++ b/emacs/notmuch.el\r
+>> > @@ -644,6 +644,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
+>> > @@ -655,8 +656,16 @@ of the result."\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
+>> > + (cond ((or (= exit-status 20) (= exit-status 21))\r
+>> > + (kill-buffer)\r
+>> > + (condition-case err\r
+>> > + (notmuch-version-mismatch-error exit-status)\r
+>> > + ;; Strange things happen when you signal\r
+>> > + ;; an error from a sentinel.\r
+>> > + (error (throw 'return nil))))\r
+>> > + ((/= exit-status 0)\r
+>> > + (insert (format " (process returned %d)"\r
+>> > + exit-status))))\r
+>> > (insert "\n")\r
+>> > (if (and atbob\r
+>> > (not (string= notmuch-search-target-thread "found")))\r
+>> > @@ -664,7 +673,7 @@ of the result."\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
+>> > @@ -938,7 +947,7 @@ Other optional parameters are used as follows:\r
+>> > (let ((proc (start-process\r
+>> > "notmuch-search" buffer\r
+>> > notmuch-command "search"\r
+>> > - "--format=json"\r
+>> > + "--format=json" "--use-schema=1"\r
+>> > (if oldest-first\r
+>> > "--sort=oldest-first"\r
+>> > "--sort=newest-first")\r
+>> >\r
+>> > _______________________________________________\r
+>> > notmuch mailing list\r
+>> > notmuch@notmuchmail.org\r
+>> > http://notmuchmail.org/mailman/listinfo/notmuch\r
+>\r
+> -- \r
+> Austin Clements MIT/'06/PhD/CSAIL\r
+> amdragon@mit.edu http://web.mit.edu/amdragon\r
+> Somewhere in the dream we call reality you will find me,\r
+> searching for the reality we call dreams.\r