1 Return-Path: <amdragon@gmail.com>
\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 9F3DE431FB6
\r
6 for <notmuch@notmuchmail.org>; Thu, 3 Feb 2011 09:06:24 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,
\r
13 RCVD_IN_DNSWL_LOW=-0.7] 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 opQVcF6LNAmG for <notmuch@notmuchmail.org>;
\r
17 Thu, 3 Feb 2011 09:06:23 -0800 (PST)
\r
18 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com
\r
19 [209.85.216.181]) (using TLSv1 with cipher RC4-MD5 (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 96113431FB5
\r
22 for <notmuch@notmuchmail.org>; Thu, 3 Feb 2011 09:06:23 -0800 (PST)
\r
23 Received: by qyk12 with SMTP id 12so1247915qyk.5
\r
24 for <notmuch@notmuchmail.org>; Thu, 03 Feb 2011 09:06:22 -0800 (PST)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
26 h=domainkey-signature:mime-version:sender:in-reply-to:references:date
\r
27 :x-google-sender-auth:message-id:subject:from:to:cc:content-type
\r
28 :content-transfer-encoding;
\r
29 bh=TeJOGpmgjNAW4mjfcHl6TwHQztSm1M49W0cZL6j2GbI=;
\r
30 b=daF/fAE9H1FB+glOex55Rzmfgh9HPgEL4RYdPi6lZcZ7MN1kNK+jmkR6m9vT6mbzH4
\r
31 GxTHOWdyTQ+zJhymAI/zLEcArb8ctEsGobd3chYlNBx0AsvpJBh3JqxELfCUah7XPecg
\r
32 sqhyXcSzX5visVL4efPHTf17X19KQOa25ZOEQ=
\r
33 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
\r
34 h=mime-version:sender:in-reply-to:references:date
\r
35 :x-google-sender-auth:message-id:subject:from:to:cc:content-type
\r
36 :content-transfer-encoding;
\r
37 b=ViYqLrQeDHRb+66tfi2bj6KKsMmDkScooGi522RADB+NsH8ExNYgK/43wewsj9GAXS
\r
38 QPOjGTePtGllM6CQTQc9eysUe7wQQpxTFAQ0gKNDSEaXjYaWNQt5YcDTsp2SxobTlzR8
\r
39 eatFG8ya6HXkmwoiHVl1ds5AmElNislpEnL9U=
\r
41 Received: by 10.229.240.85 with SMTP id kz21mr9451701qcb.2.1296752780472; Thu,
\r
42 03 Feb 2011 09:06:20 -0800 (PST)
\r
43 Sender: amdragon@gmail.com
\r
44 Received: by 10.229.97.143 with HTTP; Thu, 3 Feb 2011 09:06:20 -0800 (PST)
\r
45 In-Reply-To: <1296690999-16542-3-git-send-email-thomas@schwinge.name>
\r
46 References: <87zkqeiffj.fsf@kepler.schwinge.homeip.net>
\r
47 <1296690999-16542-3-git-send-email-thomas@schwinge.name>
\r
48 Date: Thu, 3 Feb 2011 12:06:20 -0500
\r
49 X-Google-Sender-Auth: VAZt2cAqYEe_iKK1w-IeAiVHq2o
\r
50 Message-ID: <AANLkTi=_ZqOao8mMRRb=gLmX+MWchqZ0Af-VxJquwure@mail.gmail.com>
\r
51 Subject: Re: [PATCH 2/2] notmuch.el:notmuch-search-process-filter: Rewritten.
\r
52 Cope with incomplete lines.
\r
53 From: Austin Clements <amdragon@mit.edu>
\r
54 To: Thomas Schwinge <thomas@schwinge.name>
\r
55 Content-Type: text/plain; charset=ISO-8859-1
\r
56 Content-Transfer-Encoding: quoted-printable
\r
57 Cc: notmuch@notmuchmail.org
\r
58 X-BeenThere: notmuch@notmuchmail.org
\r
59 X-Mailman-Version: 2.1.13
\r
61 List-Id: "Use and development of the notmuch mail system."
\r
62 <notmuch.notmuchmail.org>
\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
66 List-Post: <mailto:notmuch@notmuchmail.org>
\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
70 X-List-Received-Date: Thu, 03 Feb 2011 17:06:24 -0000
\r
74 Is there a reason you keep the remaining data in a string instead of
\r
75 taking the more idiomatic elisp approach of leaving it in the process
\r
76 buffer? In fact, the code would probably be simpler if you
\r
77 immediately appended the string to the process buffer like a normal
\r
78 process-filter and then peeled things away using buffer-oriented
\r
79 regexp functions like looking-at. Elisp is a lot better at
\r
80 manipulating buffers than it is at manipulating strings.
\r
82 On Wed, Feb 2, 2011 at 6:56 PM, Thomas Schwinge <thomas@schwinge.name> wrot=
\r
84 > This issue has been lying in ambush as of 2009-11-24's commit
\r
85 > 93af7b574598637c2766dd1f8ef343962c9a8efb.
\r
87 > Signed-off-by: Thomas Schwinge <thomas@schwinge.name>
\r
89 > =A0emacs/notmuch.el | =A0 70 +++++++++++++++++++++++++++++++-------------=
\r
91 > =A01 files changed, 41 insertions(+), 29 deletions(-)
\r
93 > diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
94 > index 3d82f0d..35ccee6 100644
\r
95 > --- a/emacs/notmuch.el
\r
96 > +++ b/emacs/notmuch.el
\r
97 > @@ -641,9 +641,6 @@ non-authors is found, assume that all of the authors =
\r
99 > =A0 =A0 (propertize authors 'face 'notmuch-search-matching-authors)))
\r
101 > =A0(defun notmuch-search-insert-authors (format-string authors)
\r
102 > - =A0;; Save the match data to avoid interfering with
\r
103 > - =A0;; `notmuch-search-process-filter'.
\r
104 > - =A0(save-match-data
\r
105 > =A0 =A0 (let* ((formatted-authors (format format-string authors))
\r
106 > =A0 =A0 =A0 =A0 =A0 (formatted-sample (format format-string ""))
\r
107 > =A0 =A0 =A0 =A0 =A0 (visible-string formatted-authors)
\r
108 > @@ -709,7 +706,7 @@ non-authors is found, assume that all of the authors =
\r
110 > =A0 =A0 =A0 =A0 =A0(setq overlay (make-overlay start (point)))
\r
111 > =A0 =A0 =A0 =A0 =A0(overlay-put overlay 'invisible invis-spec)
\r
112 > =A0 =A0 =A0 =A0 =A0(overlay-put overlay 'isearch-open-invisible #'notmuch=
\r
113 -search-isearch-authors-show)))
\r
114 > - =A0 =A0 =A0(insert padding))))
\r
115 > + =A0 =A0 =A0(insert padding)))
\r
117 > =A0(defun notmuch-search-insert-field (field date count authors subject t=
\r
120 > @@ -736,6 +733,10 @@ non-authors is found, assume that all of the authors=
\r
122 > =A0 =A0 =A0 =A0 =A0do (notmuch-search-insert-field field date count autho=
\r
124 > =A0 (insert "\n"))
\r
126 > +(defvar notmuch-search-process-filter-data nil
\r
127 > + =A0"Data that has not yet been processed.")
\r
128 > +(make-variable-buffer-local 'notmuch-search-process-filter-data)
\r
130 > =A0(defun notmuch-search-process-filter (proc string)
\r
131 > =A0 "Process and filter the output of \"notmuch search\""
\r
132 > =A0 (let ((buffer (process-buffer proc))
\r
133 > @@ -743,31 +744,41 @@ non-authors is found, assume that all of the author=
\r
135 > =A0 =A0 (if (buffer-live-p buffer)
\r
136 > =A0 =A0 =A0 =A0(with-current-buffer buffer
\r
137 > =A0 =A0 =A0 =A0 =A0(save-excursion
\r
138 > - =A0 =A0 =A0 =A0 =A0 (let ((line 0)
\r
139 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (more t)
\r
140 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (inhibit-read-only t))
\r
141 > - =A0 =A0 =A0 =A0 =A0 =A0 (while more
\r
142 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if (string-match "^\\(thread:[0-9A-Fa-f]*\=
\r
143 \) \\([^][]*\\) \\(\\[[0-9/]*\\]\\) \\([^;]*\\); \\(.*\\) (\\([^()]*\\))$" =
\r
145 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (let* ((thread-id (match-string 1 s=
\r
147 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(date (match-string =
\r
149 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(count (match-string=
\r
151 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(authors (match-stri=
\r
153 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(subject (match-stri=
\r
155 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(tags (match-string =
\r
157 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(tag-list (if tags (=
\r
158 save-match-data (split-string tags)))))
\r
159 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (goto-char (point-max))
\r
160 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (let ((beg (point-marker)))
\r
161 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-search-show-result=
\r
162 date count authors subject tags)
\r
163 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-search-color-line =
\r
164 beg (point-marker) tag-list)
\r
165 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (put-text-property beg (poi=
\r
166 nt-marker) 'notmuch-search-thread-id thread-id)
\r
167 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (put-text-property beg (poi=
\r
168 nt-marker) 'notmuch-search-authors authors)
\r
169 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (put-text-property beg (poi=
\r
170 nt-marker) 'notmuch-search-subject subject)
\r
171 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if (string=3D thread-id no=
\r
172 tmuch-search-target-thread)
\r
173 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (progn
\r
174 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (set 'found-tar=
\r
176 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (set 'notmuch-s=
\r
177 earch-target-thread "found"))))
\r
178 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (set 'line (match-end 0)))
\r
179 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (set 'more nil)))))
\r
180 > + =A0 =A0 =A0 =A0 =A0 (let ((inhibit-read-only t)
\r
181 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; We may have a partial line saved fro=
\r
182 m the last iteration.
\r
183 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (string (concat notmuch-search-process-=
\r
184 filter-data string))
\r
185 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (start 0))
\r
186 > + =A0 =A0 =A0 =A0 =A0 =A0 (goto-char (point-max))
\r
187 > + =A0 =A0 =A0 =A0 =A0 =A0 ;; Split `string' into lines.
\r
188 > + =A0 =A0 =A0 =A0 =A0 =A0 (while (string-match "\n" string start)
\r
189 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 (let ((line (substring string start (match-=
\r
191 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; Save the beginning of the next line =
\r
192 already here, so that
\r
193 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; we can mangle the match data later o=
\r
195 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq start (match-end 0))
\r
196 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if (string-match
\r
197 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"^\\(thread:[0-9A-Fa-f]*\\) =
\r
198 \\([^][]*\\) \\(\\[[0-9/]*\\]\\) \\([^;]*\\); \\(.*\\) (\\([^()]*\\))$"
\r
199 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0line)
\r
200 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (let* ((thread-id (match-string=
\r
202 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(date (match-str=
\r
204 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(count (match-st=
\r
206 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(authors (match-=
\r
208 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(subject (match-=
\r
210 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(tags (match-str=
\r
212 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(tag-list (if ta=
\r
213 gs (split-string tags))))
\r
214 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (let ((beg (point-marker)))
\r
215 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-search-show-re=
\r
216 sult date count authors subject tags)
\r
217 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-search-color-l=
\r
218 ine beg (point-marker) tag-list)
\r
219 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (put-text-property beg =
\r
220 (point-marker) 'notmuch-search-thread-id thread-id)
\r
221 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (put-text-property beg =
\r
222 (point-marker) 'notmuch-search-authors authors)
\r
223 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (put-text-property beg =
\r
224 (point-marker) 'notmuch-search-subject subject)
\r
225 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if (string=3D thread-i=
\r
226 d notmuch-search-target-thread)
\r
227 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq found-tar=
\r
229 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 not=
\r
230 much-search-target-thread "found"))))
\r
231 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; Non-conforming line.
\r
232 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (insert (concat "Non-conforming lin=
\r
233 e (ignored): <" line ">.\n")))))
\r
234 > + =A0 =A0 =A0 =A0 =A0 =A0 ;; Save the remainder after the last line break=
\r
236 > + =A0 =A0 =A0 =A0 =A0 =A0 ;; interation.
\r
237 > + =A0 =A0 =A0 =A0 =A0 =A0 (setq notmuch-search-process-filter-data (subst=
\r
238 ring string start))))
\r
239 > =A0 =A0 =A0 =A0 =A0(if found-target
\r
240 > =A0 =A0 =A0 =A0 =A0 =A0 =A0(goto-char found-target)))
\r
241 > =A0 =A0 =A0 (delete-process proc))))
\r
242 > @@ -858,6 +869,7 @@ The optional parameters are used as follows:
\r
243 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "--sort=3Dnewest-first")
\r
244 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 query)))
\r
245 > =A0 =A0 =A0 =A0 =A0(set-process-sentinel proc 'notmuch-search-process-sen=
\r
247 > + =A0 =A0 =A0 =A0 (setq notmuch-search-process-filter-data nil)
\r
248 > =A0 =A0 =A0 =A0 =A0(set-process-filter proc 'notmuch-search-process-filte=
\r
250 > =A0 =A0 (run-hooks 'notmuch-search-hook)))
\r
255 > _______________________________________________
\r
256 > notmuch mailing list
\r
257 > notmuch@notmuchmail.org
\r
258 > http://notmuchmail.org/mailman/listinfo/notmuch
\r