Re: [PATCH v3] nmbug: Translate to Python
[notmuch-archives.git] / 1b / 45a77cc0983238cf26532440280a990b0cb100
1 Return-Path: <m.walters@qmul.ac.uk>\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 9F619431FAF\r
6         for <notmuch@notmuchmail.org>; Sat,  8 Dec 2012 00:48:26 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id OJpy3cTkUwP2 for <notmuch@notmuchmail.org>;\r
17         Sat,  8 Dec 2012 00:48:24 -0800 (PST)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 0BB5E431FAE\r
22         for <notmuch@notmuchmail.org>; Sat,  8 Dec 2012 00:48:24 -0800 (PST)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1ThG58-00069c-5s; Sat, 08 Dec 2012 08:48:22 +0000\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1ThG57-0004FC-Os; Sat, 08 Dec 2012 08:48:22 +0000\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH 07/10] emacs: Use --use-schema for search\r
34 In-Reply-To: <1354416002-3557-7-git-send-email-amdragon@mit.edu>\r
35 References: <1354416002-3557-1-git-send-email-amdragon@mit.edu>\r
36         <1354416002-3557-7-git-send-email-amdragon@mit.edu>\r
37 User-Agent: Notmuch/0.14+81~g9730584 (http://notmuchmail.org) Emacs/23.4.1\r
38         (x86_64-pc-linux-gnu)\r
39 Date: Sat, 08 Dec 2012 08:48:26 +0000\r
40 Message-ID: <87ehj1gc9x.fsf@qmul.ac.uk>\r
41 MIME-Version: 1.0\r
42 Content-Type: text/plain; charset=us-ascii\r
43 X-Sender-Host-Address: 93.97.24.31\r
44 X-QM-SPAM-Info: Sender has good ham record.  :)\r
45 X-QM-Body-MD5: 855dd0488c8187b0d0b2eda6089e4b62 (of first 20000 bytes)\r
46 X-SpamAssassin-Score: -1.8\r
47 X-SpamAssassin-SpamBar: -\r
48 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
49         determine if it is\r
50         spam. We require at least 5.0 points to mark a message as spam.\r
51         This message scored -1.8 points.\r
52         Summary of the scoring: \r
53         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
54         *      medium trust\r
55         *      [138.37.6.40 listed in list.dnswl.org]\r
56         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
57         provider *      (markwalters1009[at]gmail.com)\r
58         *  0.5 AWL AWL: From: address is in the auto white-list\r
59 X-QM-Scan-Virus: ClamAV says the message is clean\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Sat, 08 Dec 2012 08:48:26 -0000\r
73 \r
74 On Sun, 02 Dec 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
75 > We detect the special exit statuses and use these to produce specific\r
76 > diagnostic messages.\r
77 > ---\r
78 >  emacs/notmuch-lib.el |   32 ++++++++++++++++++++++++++++++++\r
79 >  emacs/notmuch.el     |   17 +++++++++++++----\r
80 >  2 files changed, 45 insertions(+), 4 deletions(-)\r
81 >\r
82 > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
83 > index 9402456..49b0da6 100644\r
84 > --- a/emacs/notmuch-lib.el\r
85 > +++ b/emacs/notmuch-lib.el\r
86 > @@ -325,6 +325,38 @@ string), a property list of face attributes, or a list of these."\r
87 >       (put-text-property pos next 'face (cons face cur))\r
88 >       (setq pos next)))))\r
89 >  \r
90 > +(defun notmuch-pop-up-error (msg)\r
91 > +  "Pop up an error buffer displaying MSG."\r
92 > +\r
93 > +  (let ((buf (get-buffer-create "*Notmuch errors*")))\r
94 > +    (with-current-buffer buf\r
95 > +      (view-mode)\r
96 > +      (let ((inhibit-read-only t))\r
97 > +     (erase-buffer)\r
98 > +     (insert msg)\r
99 > +     (unless (bolp)\r
100 > +       (insert "\n"))\r
101 > +     (goto-char (point-min))))\r
102 > +    (pop-to-buffer buf)))\r
103 \r
104 I am not sure about the erase-buffer in the above: do we definitely want\r
105 to remove all previous error information? For version mismatch possibly\r
106 we do but in patch 9 it is done for all show command-line error returns.\r
107 Incidentally why does show always pop-up an error but search only for\r
108 version-mismatches?\r
109 \r
110 Otherwise this looks good to me (but I am not that familiar with lisp\r
111 error handling)\r
112 \r
113 Best wishes\r
114 \r
115 Mark\r
116 \r
117 \r
118 \r
119 \r
120 \r
121 \r
122 > +(defun notmuch-version-mismatch-error (exit-status)\r
123 > +  "Signal a schema version mismatch error.\r
124 > +\r
125 > +EXIT-STATUS must be the exit status of the notmuch CLI command,\r
126 > +and must have the value 20 or 21.  This function will pop up an\r
127 > +error buffer with a descriptive message and signal an error."\r
128 > +  (cond ((= exit-status 20)\r
129 > +      (notmuch-pop-up-error "Error: Version mismatch.\r
130 > +Emacs requested an older output format than supported by the notmuch CLI.\r
131 > +You may need to restart Emacs or upgrade your notmuch Emacs package."))\r
132 > +     ((= exit-status 21)\r
133 > +      (notmuch-pop-up-error "Error: Version mismatch.\r
134 > +Emacs requested a newer output format than supported by the notmuch CLI.\r
135 > +You may need to restart Emacs or upgrade your notmuch package."))\r
136 > +     (t\r
137 > +      (error "Bad exit status %d" exit-status)))\r
138 > +  (error "notmuch CLI version mismatch"))\r
139 > +\r
140 >  ;; Compatibility functions for versions of emacs before emacs 23.\r
141 >  ;;\r
142 >  ;; Both functions here were copied from emacs 23 with the following copyright:\r
143 > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
144 > index f9454d8..e1f28ca 100644\r
145 > --- a/emacs/notmuch.el\r
146 > +++ b/emacs/notmuch.el\r
147 > @@ -644,6 +644,7 @@ of the result."\r
148 >       (exit-status (process-exit-status proc))\r
149 >       (never-found-target-thread nil))\r
150 >      (when (memq status '(exit signal))\r
151 > +      (catch 'return\r
152 >       (kill-buffer (process-get proc 'parse-buf))\r
153 >       (if (buffer-live-p buffer)\r
154 >           (with-current-buffer buffer\r
155 > @@ -655,8 +656,16 @@ of the result."\r
156 >                     (insert "Incomplete search results (search process was killed).\n"))\r
157 >                 (when (eq status 'exit)\r
158 >                   (insert "End of search results.")\r
159 > -                 (unless (= exit-status 0)\r
160 > -                   (insert (format " (process returned %d)" exit-status)))\r
161 > +                 (cond ((or (= exit-status 20) (= exit-status 21))\r
162 > +                        (kill-buffer)\r
163 > +                        (condition-case err\r
164 > +                            (notmuch-version-mismatch-error exit-status)\r
165 > +                          ;; Strange things happen when you signal\r
166 > +                          ;; an error from a sentinel.\r
167 > +                          (error (throw 'return nil))))\r
168 > +                       ((/= exit-status 0)\r
169 > +                        (insert (format " (process returned %d)"\r
170 > +                                        exit-status))))\r
171 >                   (insert "\n")\r
172 >                   (if (and atbob\r
173 >                            (not (string= notmuch-search-target-thread "found")))\r
174 > @@ -664,7 +673,7 @@ of the result."\r
175 >             (when (and never-found-target-thread\r
176 >                      notmuch-search-target-line)\r
177 >                 (goto-char (point-min))\r
178 > -               (forward-line (1- notmuch-search-target-line))))))))\r
179 > +               (forward-line (1- notmuch-search-target-line)))))))))\r
180 >  \r
181 >  (defcustom notmuch-search-line-faces '(("unread" :weight bold)\r
182 >                                      ("flagged" :foreground "blue"))\r
183 > @@ -938,7 +947,7 @@ Other optional parameters are used as follows:\r
184 >       (let ((proc (start-process\r
185 >                    "notmuch-search" buffer\r
186 >                    notmuch-command "search"\r
187 > -                  "--format=json"\r
188 > +                  "--format=json" "--use-schema=1"\r
189 >                    (if oldest-first\r
190 >                        "--sort=oldest-first"\r
191 >                      "--sort=newest-first")\r
192 > -- \r
193 > 1.7.10.4\r
194 >\r
195 > _______________________________________________\r
196 > notmuch mailing list\r
197 > notmuch@notmuchmail.org\r
198 > http://notmuchmail.org/mailman/listinfo/notmuch\r