1 Return-Path: <kanru@kanru.info>
\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 00F7E431FBC
\r
6 for <notmuch@notmuchmail.org>; Thu, 24 Dec 2009 17:48:05 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 Received: from olra.theworths.org ([127.0.0.1])
\r
9 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
10 with ESMTP id hSo2Zg1uuRtW for <notmuch@notmuchmail.org>;
\r
11 Thu, 24 Dec 2009 17:48:04 -0800 (PST)
\r
12 Received: from cp20.secserverpros.com (cp20.secserverpros.com
\r
13 [67.220.217.187]) by olra.theworths.org (Postfix) with ESMTP id C3ABE431FAE
\r
14 for <notmuch@notmuchmail.org>; Thu, 24 Dec 2009 17:48:03 -0800 (PST)
\r
15 Received: from 61-30-10-70.static.tfn.net.tw ([61.30.10.70] helo=kanru.info)
\r
16 by cp20.secserverpros.com with esmtps (TLSv1:AES256-SHA:256)
\r
17 (Exim 4.69) (envelope-from <kanru@kanru.info>) id 1NNzHd-0007y4-78
\r
18 for notmuch@notmuchmail.org; Fri, 25 Dec 2009 01:48:03 +0000
\r
19 Received: from kanru (uid 1000) (envelope-from kanru@kanru.info) id 4c
\r
20 by kanru.info (DragonFly Mail Agent) Fri, 25 Dec 2009 09:47:05 +0800
\r
21 From: Kan-Ru Chen <kanru@kanru.info>
\r
22 To: david@tethera.net, notmuch@notmuchmail.org
\r
23 In-Reply-To: <1261665534-2445-1-git-send-email-david@tethera.net>
\r
24 References: <87ws0jydx0.fsf@yoom.home.cworth.org>
\r
25 <1261665534-2445-1-git-send-email-david@tethera.net>
\r
26 Date: Fri, 25 Dec 2009 09:47:02 +0800
\r
27 Message-ID: <87my17965l.fsf@anar.kanru.info>
\r
29 Content-Type: multipart/signed; boundary="=-=-=";
\r
30 micalg=pgp-sha256; protocol="application/pgp-signature"
\r
32 X-AntiAbuse: This header was added to track abuse,
\r
33 please include it with any abuse report
\r
34 X-AntiAbuse: Primary Hostname - cp20.secserverpros.com
\r
35 X-AntiAbuse: Original Domain - notmuchmail.org
\r
36 X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
\r
37 X-AntiAbuse: Sender Address Domain - kanru.info
\r
41 Cc: David Bremner <bremner@unb.ca>
\r
42 Subject: Re: [notmuch] [PATCH] notmuch.el: Refactor citation markup.
\r
43 Variables for minimum size, button text.
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.12
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Fri, 25 Dec 2009 01:48:05 -0000
\r
59 Content-Transfer-Encoding: quoted-printable
\r
61 On Thu, 24 Dec 2009 10:38:54 -0400, david@tethera.net wrote:
\r
62 > From: David Bremner <bremner@unb.ca>
\r
64 > This is a fairly intrusive rewrite.
\r
66 > - I pulled the common code for the signature and citation case out
\r
67 > into a separate function. This is not so much shorter, but I think it
\r
68 > will be easier to maintain.
\r
70 > - I replaced the sequence of (looking-at blah) (forward-line) with a sin=
\r
72 > re-search-forward per citation.
\r
76 > - notmuch-show-signature-button-format, notmuch-show-citation-button-form=
\r
78 > Allow customization of button text.
\r
80 > - notmuch-show-citation-lines-min
\r
81 > Do not buttonize citations below the given threshold.
\r
83 I like this idea, but this patch hides all citations larger than the
\r
84 threshold. I'd like to see limited lines of citations been displayed.
\r
88 > Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
\r
89 > eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enimad
\r
90 > minim veniam, quis nostrud exercitation ullamco laboris nisi ut
\r
91 > aliquip ex ea commodo consequat. Duis aute irure dolor in
\r
92 [ 6-line hidden citation. Click/Enter to show ]
\r
94 And click the button shows the rest.
\r
98 > I decided to start with a simple threshold, and only convert
\r
99 > sufficiently long citations to buttons. Once I started messing with
\r
100 > that code, I decided to rework it to be more maintainable and
\r
101 > hopefully faster.
\r
103 > This patch also fixes the problem of merging cites separated by a
\r
104 > single line of whitespace This is also fixed by the much simpler
\r
105 > <1260769295-12924-3-git-send-email-kanru@kanru.info>, but unlike that
\r
106 > patch there _shouldn't_ be a problem with eating the blank line after
\r
107 > a citation. I'm not sure about the other bugs fixed by Kan-Ru's
\r
108 > series; perhaps Kan-Ru can comment.
\r
111 > ++++++++++++++++++++++++++++++++++++++---------------------- 1 files
\r
112 > changed, 83 insertions(+), 47 deletions(-)
\r
114 > diff --git a/notmuch.el b/notmuch.el
\r
115 > index 97914f2..6a5ceea 100644
\r
118 > @@ -92,9 +92,24 @@ for indentation at the beginning of the line. But notm=
\r
120 > move past the indentation when testing this pattern, (so that the
\r
121 > pattern can still test against the entire line).")
\r
123 > +(defvar notmuch-show-signature-button-format=20
\r
124 > + "[ %d-line hidden signature. Click/Enter to show ]"
\r
125 > + "String used to construct button text for hidden signatures
\r
127 > +Can use up to one integer format parameter, i.e. %d")
\r
129 > +(defvar notmuch-show-citation-button-format=20
\r
130 > + "[ %d-line hidden citation. Click/Enter to show ]"
\r
131 > + "String used to construct button text for hidden citations.
\r
133 > +Can use up to one integer format parameter, i.e. %d")
\r
135 > (defvar notmuch-show-signature-lines-max 12
\r
136 > "Maximum length of signature that will be hidden by default.")
\r
138 > +(defvar notmuch-show-citation-lines-min 4
\r
139 > + "Minimum length of citation that will be hidden.")
\r
141 > (defvar notmuch-command "notmuch"
\r
142 > "Command to run the notmuch binary.")
\r
144 > @@ -593,54 +608,75 @@ which this thread was originally shown."
\r
145 > 'face 'notmuch-message-summary-face
\r
146 > :supertype 'notmuch-button-invisibility-toggle-type)
\r
148 > +(defun notmuch-show-citation-regexp (depth)
\r
149 > + "Build a regexp for matching citations at a given DEPTH (indent)"
\r
150 > + (let ((line-regexp (format "[[:space:]]\\{%d\\}*>.*\n" depth)))
\r
151 > + (concat "\\(?:^" line-regexp=20
\r
152 > + "\\(?:[[:space:]]*\n" line-regexp
\r
155 > +(defun notmuch-show-region-to-button (beg end type prefix button-text)
\r
156 > + "Auxilary function to do the actual making of overlays and buttons
\r
158 > +BEG and END are buffer locations. TYPE should a string, either
\r
159 > +\"citation\" or \"signature\". PREFIX is some arbitrary text to
\r
160 > +insert before the button, probably for indentation. BUTTON-TEXT
\r
161 > +is what to put on the button."
\r
163 > +;; This uses some slightly tricky conversions between strings and
\r
164 > +;; symbols because of the way the button code works. Note that
\r
165 > +;; replacing intern-soft with make-symbol will cause this to fail,=20
\r
166 > +;; since the newly created symbol has no plist.
\r
168 > + (let ((overlay (make-overlay beg end))
\r
169 > + (invis-spec (make-symbol (concat "notmuch-" type "-region")))
\r
170 > + (button-type (intern-soft (concat "notmuch-button-"=20
\r
171 > + type "-toggle-type"))))
\r
172 > + (add-to-invisibility-spec invis-spec)
\r
173 > + (overlay-put overlay 'invisible invis-spec)
\r
174 > + (goto-char (1+ end))
\r
175 > + (save-excursion=20
\r
176 > + (goto-char (1- beg))
\r
177 > + (insert prefix)
\r
178 > + (insert-button button-text
\r
179 > + 'invisibility-spec invis-spec
\r
180 > + :type button-type)
\r
183 > +=09=09=09=09=09=09=20
\r
184 > (defun notmuch-show-markup-citations-region (beg end depth)
\r
185 > - (goto-char beg)
\r
186 > - (beginning-of-line)
\r
187 > - (while (< (point) end)
\r
188 > - (let ((beg-sub (point-marker))
\r
189 > - (indent (make-string depth ? ))
\r
190 > - (citation ">"))
\r
191 > - (move-to-column depth)
\r
192 > - (if (looking-at citation)
\r
194 > - (while (looking-at citation)
\r
196 > - (move-to-column depth))
\r
197 > - (let ((overlay (make-overlay beg-sub (point)))
\r
198 > - (invis-spec (make-symbol "notmuch-citation-region")))
\r
199 > - (add-to-invisibility-spec invis-spec)
\r
200 > - (overlay-put overlay 'invisible invis-spec)
\r
201 > - (let ((p (point-marker))
\r
202 > - (cite-button-text
\r
203 > - (concat "[" (number-to-string (count-lines beg-sub=
\r
205 > - "-line citation. Click/Enter to show.]")))
\r
206 > - (goto-char (- beg-sub 1))
\r
207 > - (insert (concat "\n" indent))
\r
208 > - (insert-button cite-button-text
\r
209 > - 'invisibility-spec invis-spec
\r
210 > - :type 'notmuch-button-citation-toggle-typ=
\r
214 > - (move-to-column depth)
\r
215 > - (if (looking-at notmuch-show-signature-regexp)
\r
216 > - (let ((sig-lines (- (count-lines beg-sub end) 1)))
\r
217 > - (if (<=3D sig-lines notmuch-show-signature-lines-max)
\r
219 > - (let ((invis-spec (make-symbol "notmuch-signature-regi=
\r
221 > - (add-to-invisibility-spec invis-spec)
\r
222 > - (overlay-put (make-overlay beg-sub end)
\r
223 > - 'invisible invis-spec)
\r
224 > -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
\r
225 > - (goto-char (- beg-sub 1))
\r
226 > - (insert (concat "\n" indent))
\r
227 > - (let ((sig-button-text (concat "[" (number-to-string=
\r
229 > - "-line signature. Cli=
\r
230 ck/Enter to show.]")))
\r
231 > - (insert-button sig-button-text 'invisibility-spec =
\r
233 > - :type 'notmuch-button-signature-tog=
\r
237 > - (goto-char end))))))
\r
238 > - (forward-line))))
\r
239 > + "Markup citations, and up to one signature in the given region"
\r
241 > + (let ((citation-regexp (notmuch-show-citation-regexp depth))
\r
242 > + (signature-regexp (concat (format "^[[:space:]]\\{%d\\}" depth)=20
\r
243 > + notmuch-show-signature-regexp))
\r
244 > + (indent (make-string depth ? )))
\r
245 > + (goto-char beg)
\r
246 > + (beginning-of-line)
\r
247 > + (while (and (< (point) end)=20
\r
248 > + (re-search-forward citation-regexp end t))
\r
249 > + (let* ((cite-start (match-beginning 0))
\r
250 > + (cite-end (match-end 0))
\r
251 > + (cite-lines (count-lines cite-start cite-end)))
\r
252 > + (if (>=3D cite-lines notmuch-show-citation-lines-min)
\r
253 > + (notmuch-show-region-to-button=20
\r
254 > + cite-start cite-end
\r
257 > + (format notmuch-show-citation-button-format cite-lines)
\r
259 > + (if (re-search-forward signature-regexp end t)
\r
260 > + (let* ((sig-start (match-beginning 0))
\r
261 > + (sig-end (match-end 0))
\r
262 > + (sig-lines (1- (count-lines sig-start end))))
\r
263 > + (if (<=3D sig-lines notmuch-show-signature-lines-max)
\r
264 > + (notmuch-show-region-to-button=20
\r
269 > + (format notmuch-show-signature-button-format sig-lines)
\r
272 > (defun notmuch-show-markup-part (beg end depth)
\r
273 > (if (re-search-forward notmuch-show-part-begin-regexp nil t)
\r
277 > _______________________________________________
\r
278 > notmuch mailing list
\r
279 > notmuch@notmuchmail.org
\r
280 > http://notmuchmail.org/mailman/listinfo/notmuch
\r
283 Kan-Ru Chen | http://kanru.info
\r
285 Q: Why are my replies five sentences or less?
\r
286 A: http://five.sentenc.es/
\r
289 Content-Type: application/pgp-signature
\r
291 -----BEGIN PGP SIGNATURE-----
\r
292 Version: GnuPG v2.0.13 (GNU/Linux)
\r
294 iQIcBAEBCAAGBQJLNBmYAAoJEBsTLgHOxq1GHjkQAJ0q6tthvg669D19GxpXIKDC
\r
295 FBSsjbB92IpbJaZLg6OZrM+Rkq2sLB7B1hxKukBiF9B7F0BKrUKceZ+ei6Q+FNuU
\r
296 1BBTKsS/1oBBbOp6sHnq1wDY+YFd+x8lhrGi83V2yWpNjMXy4XOFO8F2Q53gsB0P
\r
297 SloGeit5Dzd3ey3QwDtYuSxhnvOjI4mR0oAZuvoWDNp55wjRJUCj+daspL9gv+qO
\r
298 AVSg8rfzeJ31syq6Me9GEkL9gQABSiEfciH5Nrf7LO+nueEOQ/GeQqolK4H2u/o0
\r
299 pi68wx03dJfHo04wzSzfVAkg3r/VdtLYs3LyWNVWCH1QZ1cMekR4d5/uFOr9L7If
\r
300 Fj1o38RPaBhLveedz0kz4qcL2Czz7dDWIrEB0t253oGjOmYr3qUX6Pn/bt2YLz0X
\r
301 Sq3iWs3/gEKyi7ll2lPS+RnrRqZoLWMm/RgvseVHG1R38hRBzLa1b8r9jqvwWYVe
\r
302 RqwyjgNl/1Hl5RYL3QmBsJhAzKlTzXzfSKo3KLnY8mgjM46Jl3Yz3sqLQIFQ85mR
\r
303 QAiZMDg14VqTnkt23ZkSbwG/ETsNSjd9TXQfL+veCQTNhmD4oBryOehcUdFlChzF
\r
304 gQRdm3LTCBn6Ok8BPWnj78g11z6GlgZeIhibACXpr6NVB71KhsSQhJ4U0Ztal8eD
\r
305 Tk0hA457z9e9zFtyppSr
\r
307 -----END PGP SIGNATURE-----
\r