1 Return-Path: <amdragon@mit.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 57DDF431FBD
\r
6 for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 18:40:35 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id r0mFkuGIQxoe for <notmuch@notmuchmail.org>;
\r
16 Sat, 1 Dec 2012 18:40:32 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 22E6E429E3C
\r
20 for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 18:40:23 -0800 (PST)
\r
21 X-AuditID: 12074423-b7fcb6d000000927-c2-50babf9667f3
\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
23 by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id E6.57.02343.69FBAB05; Sat, 1 Dec 2012 21:40:22 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id qB22eBLU022862;
\r
27 Sat, 1 Dec 2012 21:40:11 -0500
\r
28 Received: from drake.dyndns.org
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qB22e6dF025602
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Sat, 1 Dec 2012 21:40:10 -0500 (EST)
\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
36 (envelope-from <amdragon@mit.edu>)
\r
37 id 1TezTS-0000xh-28; Sat, 01 Dec 2012 21:40:06 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 07/10] emacs: Use --use-schema for search
\r
41 Date: Sat, 1 Dec 2012 21:39:59 -0500
\r
42 Message-Id: <1354416002-3557-7-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.10.4
\r
44 In-Reply-To: <1354416002-3557-1-git-send-email-amdragon@mit.edu>
\r
45 References: <1354416002-3557-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker:
\r
47 H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsUixG6nrjtt/64Ag/anphbXb85kdmD0eLbq
\r
48 FnMAYxSXTUpqTmZZapG+XQJXxtU3Z5kLlshVbF/8mbmB8Yp4FyMnh4SAiUTHhgvsELaYxIV7
\r
49 69m6GLk4hAT2MUp0dmxnAkkICaxnlGicnAyReMgk0bN6NzNEYi5Q4okwiM0moCGxbf9yRhBb
\r
50 REBaYufd2axdjBwczAJqEn+6VEDCwgKWEvPP/2IFsVkEVCWWLm4AK+cVsJe4PXsdI8QRihLd
\r
51 zyawgbRyCjhIrOjmgdhkL/H/9zW2CYz8CxgZVjHKpuRW6eYmZuYUpybrFicn5uWlFuma6eVm
\r
52 luilppRuYgQHjIvyDsY/B5UOMQpwMCrx8EbM2RUgxJpYVlyZe4hRkoNJSZT3yg6gEF9Sfkpl
\r
53 RmJxRnxRaU5q8SFGCQ5mJRFeFhOgHG9KYmVValE+TEqag0VJnPdayk1/IYH0xJLU7NTUgtQi
\r
54 mKwMB4eSBO/lvUCNgkWp6akVaZk5JQhpJg5OkOE8QMPD94EMLy5IzC3OTIfIn2JUlBLn9QNJ
\r
55 CIAkMkrz4HphEf2KURzoFWFeT5AqHmAygOt+BTSYCWjwm2XbQQaXJCKkpBoYI65+KVvN+KTi
\r
56 0ozjSwP0yspOrrq9xu73Pa8lEaKuz7r/CetyMOhxaS7XX6X5qGVK4jtrO4u7014d+jj5VLvh
\r
57 zgvdwW55z5gXPZ/SzaYzfYNjo8uUq1HhDPdi9KN2L1d3E0vu9cpcsu23b5TEwo2OMzx9Ey75
\r
58 ZomvmMRld1DS6f66WykrVlbZKrEUZyQaajEXFScCAA6i2aTDAgAA
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Sun, 02 Dec 2012 02:40:35 -0000
\r
73 We detect the special exit statuses and use these to produce specific
\r
74 diagnostic messages.
\r
76 emacs/notmuch-lib.el | 32 ++++++++++++++++++++++++++++++++
\r
77 emacs/notmuch.el | 17 +++++++++++++----
\r
78 2 files changed, 45 insertions(+), 4 deletions(-)
\r
80 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
81 index 9402456..49b0da6 100644
\r
82 --- a/emacs/notmuch-lib.el
\r
83 +++ b/emacs/notmuch-lib.el
\r
84 @@ -325,6 +325,38 @@ string), a property list of face attributes, or a list of these."
\r
85 (put-text-property pos next 'face (cons face cur))
\r
88 +(defun notmuch-pop-up-error (msg)
\r
89 + "Pop up an error buffer displaying MSG."
\r
91 + (let ((buf (get-buffer-create "*Notmuch errors*")))
\r
92 + (with-current-buffer buf
\r
94 + (let ((inhibit-read-only t))
\r
99 + (goto-char (point-min))))
\r
100 + (pop-to-buffer buf)))
\r
102 +(defun notmuch-version-mismatch-error (exit-status)
\r
103 + "Signal a schema version mismatch error.
\r
105 +EXIT-STATUS must be the exit status of the notmuch CLI command,
\r
106 +and must have the value 20 or 21. This function will pop up an
\r
107 +error buffer with a descriptive message and signal an error."
\r
108 + (cond ((= exit-status 20)
\r
109 + (notmuch-pop-up-error "Error: Version mismatch.
\r
110 +Emacs requested an older output format than supported by the notmuch CLI.
\r
111 +You may need to restart Emacs or upgrade your notmuch Emacs package."))
\r
112 + ((= exit-status 21)
\r
113 + (notmuch-pop-up-error "Error: Version mismatch.
\r
114 +Emacs requested a newer output format than supported by the notmuch CLI.
\r
115 +You may need to restart Emacs or upgrade your notmuch package."))
\r
117 + (error "Bad exit status %d" exit-status)))
\r
118 + (error "notmuch CLI version mismatch"))
\r
120 ;; Compatibility functions for versions of emacs before emacs 23.
\r
122 ;; Both functions here were copied from emacs 23 with the following copyright:
\r
123 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
124 index f9454d8..e1f28ca 100644
\r
125 --- a/emacs/notmuch.el
\r
126 +++ b/emacs/notmuch.el
\r
127 @@ -644,6 +644,7 @@ of the result."
\r
128 (exit-status (process-exit-status proc))
\r
129 (never-found-target-thread nil))
\r
130 (when (memq status '(exit signal))
\r
132 (kill-buffer (process-get proc 'parse-buf))
\r
133 (if (buffer-live-p buffer)
\r
134 (with-current-buffer buffer
\r
135 @@ -655,8 +656,16 @@ of the result."
\r
136 (insert "Incomplete search results (search process was killed).\n"))
\r
137 (when (eq status 'exit)
\r
138 (insert "End of search results.")
\r
139 - (unless (= exit-status 0)
\r
140 - (insert (format " (process returned %d)" exit-status)))
\r
141 + (cond ((or (= exit-status 20) (= exit-status 21))
\r
143 + (condition-case err
\r
144 + (notmuch-version-mismatch-error exit-status)
\r
145 + ;; Strange things happen when you signal
\r
146 + ;; an error from a sentinel.
\r
147 + (error (throw 'return nil))))
\r
148 + ((/= exit-status 0)
\r
149 + (insert (format " (process returned %d)"
\r
153 (not (string= notmuch-search-target-thread "found")))
\r
154 @@ -664,7 +673,7 @@ of the result."
\r
155 (when (and never-found-target-thread
\r
156 notmuch-search-target-line)
\r
157 (goto-char (point-min))
\r
158 - (forward-line (1- notmuch-search-target-line))))))))
\r
159 + (forward-line (1- notmuch-search-target-line)))))))))
\r
161 (defcustom notmuch-search-line-faces '(("unread" :weight bold)
\r
162 ("flagged" :foreground "blue"))
\r
163 @@ -938,7 +947,7 @@ Other optional parameters are used as follows:
\r
164 (let ((proc (start-process
\r
165 "notmuch-search" buffer
\r
166 notmuch-command "search"
\r
168 + "--format=json" "--use-schema=1"
\r
170 "--sort=oldest-first"
\r
171 "--sort=newest-first")
\r