--- /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 57DDF431FBD\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 18:40:35 -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 r0mFkuGIQxoe for <notmuch@notmuchmail.org>;\r
+ Sat, 1 Dec 2012 18:40:32 -0800 (PST)\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 22E6E429E3C\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 18:40:23 -0800 (PST)\r
+X-AuditID: 12074423-b7fcb6d000000927-c2-50babf9667f3\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id E6.57.02343.69FBAB05; Sat, 1 Dec 2012 21:40:22 -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 qB22eBLU022862; \r
+ Sat, 1 Dec 2012 21:40:11 -0500\r
+Received: from drake.dyndns.org\r
+ (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+ [209.6.116.242]) (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 qB22e6dF025602\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Sat, 1 Dec 2012 21:40:10 -0500 (EST)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1TezTS-0000xh-28; Sat, 01 Dec 2012 21:40:06 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 07/10] emacs: Use --use-schema for search\r
+Date: Sat, 1 Dec 2012 21:39:59 -0500\r
+Message-Id: <1354416002-3557-7-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1354416002-3557-1-git-send-email-amdragon@mit.edu>\r
+References: <1354416002-3557-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsUixG6nrjtt/64Ag/anphbXb85kdmD0eLbq\r
+ FnMAYxSXTUpqTmZZapG+XQJXxtU3Z5kLlshVbF/8mbmB8Yp4FyMnh4SAiUTHhgvsELaYxIV7\r
+ 69m6GLk4hAT2MUp0dmxnAkkICaxnlGicnAyReMgk0bN6NzNEYi5Q4okwiM0moCGxbf9yRhBb\r
+ REBaYufd2axdjBwczAJqEn+6VEDCwgKWEvPP/2IFsVkEVCWWLm4AK+cVsJe4PXsdI8QRihLd\r
+ zyawgbRyCjhIrOjmgdhkL/H/9zW2CYz8CxgZVjHKpuRW6eYmZuYUpybrFicn5uWlFuma6eVm\r
+ luilppRuYgQHjIvyDsY/B5UOMQpwMCrx8EbM2RUgxJpYVlyZe4hRkoNJSZT3yg6gEF9Sfkpl\r
+ RmJxRnxRaU5q8SFGCQ5mJRFeFhOgHG9KYmVValE+TEqag0VJnPdayk1/IYH0xJLU7NTUgtQi\r
+ mKwMB4eSBO/lvUCNgkWp6akVaZk5JQhpJg5OkOE8QMPD94EMLy5IzC3OTIfIn2JUlBLn9QNJ\r
+ CIAkMkrz4HphEf2KURzoFWFeT5AqHmAygOt+BTSYCWjwm2XbQQaXJCKkpBoYI65+KVvN+KTi\r
+ 0ozjSwP0yspOrrq9xu73Pa8lEaKuz7r/CetyMOhxaS7XX6X5qGVK4jtrO4u7014d+jj5VLvh\r
+ zgvdwW55z5gXPZ/SzaYzfYNjo8uUq1HhDPdi9KN2L1d3E0vu9cpcsu23b5TEwo2OMzx9Ey75\r
+ ZomvmMRld1DS6f66WykrVlbZKrEUZyQaajEXFScCAA6i2aTDAgAA\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: Sun, 02 Dec 2012 02:40:35 -0000\r
+\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
++(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
+1.7.10.4\r
+\r