Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / fb / 37e86373a8fcb31ea0a63392ebd36275e66447
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 06E74431FB6\r
6         for <notmuch@notmuchmail.org>; Thu,  5 Jul 2012 17:29:49 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \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 qi5oD58q+Za7 for <notmuch@notmuchmail.org>;\r
16         Thu,  5 Jul 2012 17:29:48 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
18         [18.9.25.14])\r
19         by olra.theworths.org (Postfix) with ESMTP id E6BE1431FAE\r
20         for <notmuch@notmuchmail.org>; Thu,  5 Jul 2012 17:29:47 -0700 (PDT)\r
21 X-AuditID: 1209190e-b7fb56d0000008b2-b4-4ff6317a344e\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
23         by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 9E.60.02226.A7136FF4; Thu,  5 Jul 2012 20:29:46 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q660Tjd2002667; \r
27         Thu, 5 Jul 2012 20:29:45 -0400\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q660Tfn6015427\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Thu, 5 Jul 2012 20:29:42 -0400 (EDT)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1SmwQX-00057a-77; Thu, 05 Jul 2012 20:29:41 -0400\r
37 Date: Thu, 5 Jul 2012 20:29:41 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: Mark Walters <markwalters1009@gmail.com>\r
40 Subject: Re: [PATCH v2 0/9] JSON-based search-mode\r
41 Message-ID: <20120706002941.GB18195@mit.edu>\r
42 References: <1341354059-29396-1-git-send-email-amdragon@mit.edu>\r
43         <1341521547-15502-1-git-send-email-amdragon@mit.edu>\r
44         <87y5mx3mtd.fsf@qmul.ac.uk>\r
45 MIME-Version: 1.0\r
46 Content-Type: text/plain; charset=us-ascii\r
47 Content-Disposition: inline\r
48 In-Reply-To: <87y5mx3mtd.fsf@qmul.ac.uk>\r
49 User-Agent: Mutt/1.5.21 (2010-09-15)\r
50 X-Brightmail-Tracker:\r
51  H4sIAAAAAAAAA+NgFprJKsWRmVeSWpSXmKPExsUixCmqrVtl+M3f4HSLlMXquTwW12/OZLZ4\r
52         s3IeqwOzx85Zd9k9Dn9dyOLxbNUt5gDmKC6blNSczLLUIn27BK6M/S0XGAv+elQsmXuRuYFx\r
53         l0UXIyeHhICJRP+GvYwQtpjEhXvr2boYuTiEBPYxShy+cwvKWc8o8WPHb3YI5wSTRFfzWlYI\r
54         ZwmjRPfq6yxdjBwcLAIqEm/P14CMYhPQkNi2fznYWBEBHYnbhxawg9jMAvoSK0/OZAaxhQWM\r
55         JPY17GYBsXmBaua1/IeaOZVRYvrOdjaIhKDEyZlPWCCatSRu/HvJBLKLWUBaYvk/DpAwJ9Cu\r
56         3T/uge0SBTphysltbBMYhWYh6Z6FpHsWQvcCRuZVjLIpuVW6uYmZOcWpybrFyYl5ealFusZ6\r
57         uZkleqkppZsYwaEuybeD8etBpUOMAhyMSjy8xrlf/IVYE8uKK3MPMUpyMCmJ8j7W/+YvxJeU\r
58         n1KZkVicEV9UmpNafIhRgoNZSYS3N+OrvxBvSmJlVWpRPkxKmoNFSZz3SspNfyGB9MSS1OzU\r
59         1ILUIpisDAeHkgTvSgOgoYJFqempFWmZOSUIaSYOTpDhPEDDF4LU8BYXJOYWZ6ZD5E8x6nKs\r
60         e3PkBqMQS15+XqqUOO9qkCIBkKKM0jy4ObAU9YpRHOgtYd61IFU8wPQGN+kV0BImoCV5iz+B\r
61         LClJREhJNTCGf+rov/p+xbnY8yvTZqWwHTr3vrN9hjZvlemxwDuqhlLc58/y+ykfjj99e9Ep\r
62         hw1Xbt3avOHlhr+/eae1+ujpTlt68Naqz4WvsxW3nBbwDmD1+/vYLqDjwJYvf66xzV7NJXI/\r
63         85FI+oETjR3fJv8Oy9/9dlvp62cuFjoL9hncV1isF+oR2HfQXYmlOCPRUIu5qDgRACGTIdYs        AwAA\r
64 Cc: tomi.ollila@iki.fi, notmuch@notmuchmail.org\r
65 X-BeenThere: notmuch@notmuchmail.org\r
66 X-Mailman-Version: 2.1.13\r
67 Precedence: list\r
68 List-Id: "Use and development of the notmuch mail system."\r
69         <notmuch.notmuchmail.org>\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
73 List-Post: <mailto:notmuch@notmuchmail.org>\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
76         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
77 X-List-Received-Date: Fri, 06 Jul 2012 00:29:49 -0000\r
78 \r
79 Quoth Mark Walters on Jul 05 at 10:44 pm:\r
80 > On Thu, 05 Jul 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
81 > > This should account for all of Mark's and Tomi's comments.  This\r
82 > > version\r
83 > > * renames the "format" variables to "format-string" and "spec" to be\r
84 > >   less confusing,\r
85 > > * reverts to the original behavior of ignoring the user's format\r
86 > >   specification for tags (since we make assumptions about this format\r
87 > >   elsewhere),\r
88 > > * swaps the error helper and search-target patches to fix the\r
89 > >   temporary issue with error message placement,\r
90 > > * adds documentation on point movement in the JSON parser,\r
91 > > * breaks out the JSON EOF testing function,\r
92 > > * beefs up a few commit messages,\r
93 > > * and adds a NEWS patch.\r
94 > >\r
95 > > For ease of reviewing, the diff diff is below.\r
96 > >\r
97 > > I've written most of a follow-on patch series that cleans up the\r
98 > > handling of metadata and tag changes by attaching the JSON result\r
99 > > object to the result.  This means we don't need a proliferation of\r
100 > > text properties to store the result metadata, and we can make updates\r
101 > > to a result (e.g., tag changes) by updating this result object and\r
102 > > then re-rendering the result line from scratch, rather than trying to\r
103 > > update the result line in place.  This makes it possible to obey user\r
104 > > formatting for the tag list and has other perks like recoloring\r
105 > > results when their tags change.  I'll send it along once this patch\r
106 > > series is accepted.\r
107 > >\r
108 > > diff --git a/NEWS b/NEWS\r
109 > > index d29ec5b..a1a6e93 100644\r
110 > > --- a/NEWS\r
111 > > +++ b/NEWS\r
112 > > @@ -14,6 +14,23 @@ Maildir tag synchronization\r
113 > >    messages (typically causing new messages to not receive the "unread"\r
114 > >    tag).\r
115 > >  \r
116 > > +Emacs Interface\r
117 > > +---------------\r
118 > > +\r
119 > > +Search now uses the JSON format internally\r
120 > > +\r
121 > > +  This should address problems with unusual characters in authors and\r
122 > > +  subject lines that could confuse the old text-based search parser.\r
123 > > +\r
124 > > +The date shown in search results is no longer padded before applying\r
125 > > +user-specified formatting\r
126 > > +\r
127 > > +  Previously, the date in the search results was padded to fixed width\r
128 > > +  before being formatted with `notmuch-search-result-format`.  It is\r
129 > > +  no longer padded.  The default format has been updated, but if\r
130 > > +  you've customized this variable, you may have to change your date\r
131 > > +  format from `"%s "` to `"%12s "`.\r
132 > > +\r
133 > >  Notmuch 0.13.2 (2012-06-02)\r
134 > >  ===========================\r
135 > >  \r
136 > > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
137 > > index f7cda33..9e04d97 100644\r
138 > > --- a/emacs/notmuch-lib.el\r
139 > > +++ b/emacs/notmuch-lib.el\r
140 > > @@ -399,8 +399,9 @@ resynchronize after an error by moving point."\r
141 > >  \r
142 > >  Returns 'retry if there is insufficient input to parse the\r
143 > >  beginning of the compound.  If this is able to parse the\r
144 > > -beginning of a compound, it returns t and later calls to\r
145 > > -`notmuch-json-read' will return the compound's elements.\r
146 > > +beginning of a compound, it moves point past the token that opens\r
147 > > +the compound and returns t.  Later calls to `notmuch-json-read'\r
148 > > +will return the compound's elements.\r
149 > >  \r
150 > >  Entering JSON objects is current unimplemented."\r
151 > >  \r
152 > > @@ -423,7 +424,8 @@ Entering JSON objects is current unimplemented."\r
153 > >  Returns 'retry if there is insufficient input to parse a complete\r
154 > >  JSON value.  If the parser is currently inside a compound value\r
155 > >  and the next token ends the list or object, returns 'end.\r
156 > > -Otherwise, returns the value."\r
157 > > +Otherwise, moves point to just past the end of the value and\r
158 > > +returns the value."\r
159\r
160 > I think that point can move when 'retry is returned (past terminators\r
161 > and commas for example). It might also be worth saying that it returns\r
162 > the next value passing command and terminators and whitespace after\r
163 > point.\r
164 \r
165 How about\r
166 \r
167 Returns 'retry if there is insufficient input to parse a complete JSON\r
168 value (though it may still move point over separators or whitespace).\r
169 If the parser is currently inside a compound value and the next token\r
170 ends the list or object, this moves point just past the terminator and\r
171 returns 'end.  Otherwise, this moves point to just past the end of the\r
172 value and returns the value.\r
173 \r
174 ?\r
175 \r
176 > >  \r
177 > >    (with-current-buffer (notmuch-json-buffer jp)\r
178 > >      (or\r
179 > > @@ -474,11 +476,22 @@ Otherwise, returns the value."\r
180 > >            (notmuch-json-partial-pos jp) nil\r
181 > >            (notmuch-json-partial-state jp) nil)\r
182 > >      ;; Parse the value\r
183 > > -    (let* ((json-object-type 'plist)\r
184 > > -           (json-array-type 'list)\r
185 > > -           (json-false nil))\r
186 > > +    (let ((json-object-type 'plist)\r
187 > > +          (json-array-type 'list)\r
188 > > +          (json-false nil))\r
189 > >        (json-read)))))))\r
190 > >  \r
191 > > +(defun notmuch-json-eof (jp)\r
192 > > +  "Signal a json-error if there is more input in JP's buffer.\r
193\r
194 > Would `data' be better than `input' (to distinguish allowed whitespace\r
195 > from disallowed data)?\r
196 \r
197 Ah, yes.\r
198 \r
199   "Signal a json-error if there is more data in JP's buffer.\r
200 \r
201 Moves point to the beginning of any trailing data or to the end\r
202 of the buffer if there is only trailing whitespace."\r
203 \r
204 ?\r
205 \r
206 > > +Moves point to the beginning of any trailing garbage or to the\r
207 > > +end of the buffer if there is no trailing garbage."\r
208 > > +\r
209 > > +  (with-current-buffer (notmuch-json-buffer jp)\r
210 > > +    (skip-chars-forward " \t\r\n")\r
211 > > +    (unless (eobp)\r
212 > > +      (signal 'json-error (list "Trailing garbage following JSON data")))))\r
213 > > +\r
214 > >  (provide 'notmuch-lib)\r
215 > >  \r
216 > >  ;; Local Variables:\r
217 > > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
218 > > index 2a09a98..fabb7c0 100644\r
219 > > --- a/emacs/notmuch.el\r
220 > > +++ b/emacs/notmuch.el\r
221 > > @@ -702,28 +702,29 @@ non-authors is found, assume that all of the authors match."\r
222 > >       (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))\r
223 > >        (insert padding))))\r
224 > >  \r
225 > > -(defun notmuch-search-insert-field (field format result)\r
226 > > +(defun notmuch-search-insert-field (field format-string result)\r
227 > >    (cond\r
228 > >     ((string-equal field "date")\r
229 > > -    (insert (propertize (format format (plist-get result :date_relative))\r
230 > > +    (insert (propertize (format format-string (plist-get result :date_relative))\r
231 > >                     'face 'notmuch-search-date)))\r
232 > >     ((string-equal field "count")\r
233 > > -    (insert (propertize (format format (format "[%s/%s]"\r
234 > > -                                          (plist-get result :matched)\r
235 > > -                                          (plist-get result :total)))\r
236 > > +    (insert (propertize (format format-string\r
237 > > +                           (format "[%s/%s]" (plist-get result :matched)\r
238 > > +                                   (plist-get result :total)))\r
239 > >                     'face 'notmuch-search-count)))\r
240 > >     ((string-equal field "subject")\r
241 > > -    (insert (propertize (format format (plist-get result :subject))\r
242 > > +    (insert (propertize (format format-string (plist-get result :subject))\r
243 > >                     'face 'notmuch-search-subject)))\r
244 > >  \r
245 > >     ((string-equal field "authors")\r
246 > > -    (notmuch-search-insert-authors format (plist-get result :authors)))\r
247 > > +    (notmuch-search-insert-authors format-string (plist-get result :authors)))\r
248 > >  \r
249 > >     ((string-equal field "tags")\r
250 > > -    (insert\r
251 > > -     (format format (propertize\r
252 > > -                (mapconcat 'identity (plist-get result :tags) " ")\r
253 > > -                'font-lock-face 'notmuch-tag-face))))))\r
254 > > +    ;; Ignore format-string here because notmuch-search-set-tags\r
255 > > +    ;; depends on the format of this\r
256 > > +    (insert (concat "(" (propertize\r
257 > > +                    (mapconcat 'identity (plist-get result :tags) " ")\r
258 > > +                    'font-lock-face 'notmuch-tag-face) ")")))))\r
259 > >  \r
260 > >  (defun notmuch-search-show-result (result)\r
261 > >    ;; Ignore excluded matches\r
262 > > @@ -731,8 +732,8 @@ non-authors is found, assume that all of the authors match."\r
263 > >      (let ((beg (point-max)))\r
264 > >        (save-excursion\r
265 > >     (goto-char beg)\r
266 > > -   (dolist (format notmuch-search-result-format)\r
267 > > -     (notmuch-search-insert-field (car format) (cdr format) result))\r
268 > > +   (dolist (spec notmuch-search-result-format)\r
269 > > +     (notmuch-search-insert-field (car spec) (cdr spec) result))\r
270 > >     (insert "\n")\r
271 > >     (notmuch-search-color-line beg (point) (plist-get result :tags))\r
272 > >     (put-text-property beg (point) 'notmuch-search-thread-id\r
273 > > @@ -790,11 +791,8 @@ non-authors is found, assume that all of the authors match."\r
274 > >                  (otherwise (notmuch-search-show-result result)))))\r
275 > >             ((end)\r
276 > >              ;; Any trailing data is unexpected\r
277 > > -            (with-current-buffer parse-buf\r
278 > > -              (skip-chars-forward " \t\r\n")\r
279 > > -              (if (eobp)\r
280 > > -                  (setq done t)\r
281 > > -                (signal 'json-error nil)))))\r
282 > > +            (notmuch-json-eof notmuch-search-json-parser)\r
283 > > +            (setq done t)))\r
284\r
285 > I think this used to only set `done' if there was not trailing data but\r
286 > now does so anyway?\r
287 \r
288 It still won't set done if there's trailing data because\r
289 notmuch-json-eof will signal an error, which will unwind to the\r
290 condition-case (which will then consume said trailing data and done\r
291 will get set on the next time through the loop).\r
292 \r
293 > Best wishes\r
294\r
295 > Mark\r
296\r
297 > >         (json-error\r
298 > >          ;; Do our best to resynchronize and ensure forward\r
299 > >          ;; progress\r