Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / fc / 95f42235308019722c61968a0df55451a836a5
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 EB597431FBF\r
6         for <notmuch@notmuchmail.org>; Sat, 10 Nov 2012 20:46:49 -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: -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 iuyUY+S+Cvfp for <notmuch@notmuchmail.org>;\r
16         Sat, 10 Nov 2012 20:46:47 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU\r
18         [18.7.68.35])\r
19         by olra.theworths.org (Postfix) with ESMTP id EDA66431FC4\r
20         for <notmuch@notmuchmail.org>; Sat, 10 Nov 2012 20:46:35 -0800 (PST)\r
21 X-AuditID: 12074423-b7fab6d0000008f9-3d-509f2dab8c2c\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
23         by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 7E.10.02297.BAD2F905; Sat, 10 Nov 2012 23:46:35 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id qAB4kObj008282; \r
27         Sat, 10 Nov 2012 23:46:24 -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 qAB4kJcE001918\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Sat, 10 Nov 2012 23:46:21 -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 1TXPR5-0003a5-NI; Sat, 10 Nov 2012 23:46:19 -0500\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH v2 2/3] emacs: Improve the regexp used to match id:'s in\r
41         messages\r
42 Date: Sat, 10 Nov 2012 23:46:14 -0500\r
43 Message-Id: <1352609175-12790-3-git-send-email-amdragon@mit.edu>\r
44 X-Mailer: git-send-email 1.7.10.4\r
45 In-Reply-To: <1352609175-12790-1-git-send-email-amdragon@mit.edu>\r
46 References: <1352609175-12790-1-git-send-email-amdragon@mit.edu>\r
47 X-Brightmail-Tracker:\r
48  H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsUixCmqrLtad36AwflmBYum6c4W12/OZLZo\r
49         7XvK4sDscev+a3aPZ6tuMXts/PuDJYA5issmJTUnsyy1SN8ugStj5beHTAWHpSuW31jK2sB4\r
50         QKyLkZNDQsBEonP9GzYIW0ziwr31QDYXh5DAPkaJ81PXMkM4GxglHkyYxQjhPGKSWNL+nB2k\r
51         RUhgLqPEmscBIDabgIbEtv3LGUFsEQFpiZ13Z7OC2MwCqRKrd3Ywg9jCAoES/fu2gsVZBFQl\r
52         utoXsoDYvAIOEif/32aEOENRovvZBLCTOAUcJfpn/GGE2OUgcebHe+YJjPwLGBlWMcqm5Fbp\r
53         5iZm5hSnJusWJyfm5aUW6Zrp5WaW6KWmlG5iBAUXu4vyDsY/B5UOMQpwMCrx8N54My9AiDWx\r
54         rLgy9xCjJAeTkihvss78ACG+pPyUyozE4oz4otKc1OJDjBIczEoivLU7gMp5UxIrq1KL8mFS\r
55         0hwsSuK811Ju+gsJpCeWpGanphakFsFkZTg4lCR4Y0GGChalpqdWpGXmlCCkmTg4QYbzAA1/\r
56         pAVUw1tckJhbnJkOkT/FqCglzsuhDZQQAElklObB9cKi/xWjONArwrxBICt4gIkDrvsV0GAm\r
57         oMGNR+aADC5JREhJNTAKtit8N35XJb5X/vipWvMJOT8Vju6WWSXw9N/WH60Rn7eu9DnxNOjf\r
58         FaFLG2Z8C/bd2ljGKCTYviohNugRZ1VAdeGmhIrfizSWtxw18nu9JKXrEb9BQFPwu+X2sy9v\r
59         4PhaKWUv6HD4UejxJuk0qfm7jDLX1b6XD7//8I3kbT/WZ6tWf9suomSjxFKckWioxVxUnAgA\r
60         Q244VNkCAAA=\r
61 Cc: sascha-ml-reply-to-2012-4@silbe.org\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.13\r
64 Precedence: list\r
65 List-Id: "Use and development of the notmuch mail system."\r
66         <notmuch.notmuchmail.org>\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
70 List-Post: <mailto:notmuch@notmuchmail.org>\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
73         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
74 X-List-Received-Date: Sun, 11 Nov 2012 04:46:50 -0000\r
75 \r
76 This regexp agrees with Xapian query syntax much more closely, though\r
77 we specifically disallow various cases that would be confusing in the\r
78 context of an email body (e.g., punctuation at the end of an id: link\r
79 is not considered part of the id: link because it's probably part of\r
80 the surrounding text).\r
81 \r
82 In particular, this handles id: links that are not surrounded by\r
83 quotes much better, which stash is much more likely to generate now\r
84 that we don't quote id's that don't need to be quoted.  It also\r
85 handles quoted id: links better.\r
86 \r
87 We update the buttonization test to reflect the new pattern.\r
88 ---\r
89  emacs/notmuch-show.el |   20 +++++++++++++++++++-\r
90  test/emacs-show       |   20 ++++++++++----------\r
91  2 files changed, 29 insertions(+), 11 deletions(-)\r
92 \r
93 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
94 index d061367..49961fb 100644\r
95 --- a/emacs/notmuch-show.el\r
96 +++ b/emacs/notmuch-show.el\r
97 @@ -996,6 +996,24 @@ message at DEPTH in the current thread."\r
98    "Insert the forest of threads FOREST."\r
99    (mapc (lambda (thread) (notmuch-show-insert-thread thread 0)) forest))\r
100  \r
101 +(defvar notmuch-id-regexp\r
102 +  (concat\r
103 +   ;; Match the id: prefix only if it begins a word (to disallow, for\r
104 +   ;; example, matching cid:).\r
105 +   "\\<id:\\("\r
106 +   ;; If the term starts with a ", then parse Xapian's quoted boolean\r
107 +   ;; term syntax, which allows for anything as long as embedded\r
108 +   ;; double quotes escaped by doubling them.  We also disallow\r
109 +   ;; newlines (which Xapian allows) to prevent runaway terms.\r
110 +   "\"\\([^\"\n]\\|\"\"\\)*\""\r
111 +   ;; Otherwise, parse Xapian's unquoted syntax, which goes up to the\r
112 +   ;; next space or ).  We disallow [.,;] as the last character\r
113 +   ;; because these are probably part of the surrounding text, and not\r
114 +   ;; part of the id.  This doesn't match single character ids; meh.\r
115 +   "\\|[^\"[:space:])][^[:space:])]*[^])[:space:].,:;?!]"\r
116 +   "\\)")\r
117 +  "The regexp used to match id: links in messages.")\r
118 +\r
119  (defun notmuch-show-buttonise-links (start end)\r
120    "Buttonise URLs and mail addresses between START and END.\r
121  \r
122 @@ -1004,7 +1022,7 @@ a corresponding notmuch search."\r
123    (goto-address-fontify-region start end)\r
124    (save-excursion\r
125      (goto-char start)\r
126 -    (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+\\1" end t)\r
127 +    (while (re-search-forward notmuch-id-regexp end t)\r
128        ;; remove the overlay created by goto-address-mode\r
129        (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)\r
130        (make-text-button (match-beginning 0) (match-end 0)\r
131 diff --git a/test/emacs-show b/test/emacs-show\r
132 index 9712633..8944e73 100755\r
133 --- a/test/emacs-show\r
134 +++ b/test/emacs-show\r
135 @@ -136,23 +136,23 @@ To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
136  Date: Fri, 05 Jan 2001 15:43:57 +0000\r
137  \r
138  <<id:abc>>\r
139 -<<id:abc.def.>> <<id:abc,def,>> <<id:abc;def;>> <<id:abc:def:>>\r
140 -<<id:foo@bar.?baz?>> <<id:foo@bar!.baz!>>\r
141 -(<<id:foo@bar.baz)>> [<<id:foo@bar.baz]>>\r
142 -<<id:foo@bar.baz...>>\r
143 +<<id:abc.def>>. <<id:abc,def>>, <<id:abc;def>>; <<id:abc:def>>:\r
144 +<<id:foo@bar.?baz>>? <<id:foo@bar!.baz>>!\r
145 +(<<id:foo@bar.baz>>) [<<id:foo@bar.baz>>]\r
146 +<<id:foo@bar.baz>>...\r
147  <<id:2+2=5>>\r
148  <<id:=_-:/.[]@$%+>>\r
149 -<<id:abc)def>>\r
150 -<<id:ab>>"c def\r
151 +<<id:abc>>)def\r
152 +<<id:ab"c>> def\r
153  <<id:"abc">>def\r
154 -<<id:"ab">>"c"def\r
155 -id:"ab c"def\r
156 +<<id:"ab""c">>def\r
157 +<<id:"ab c">>def\r
158  <<id:"abc">>.def\r
159  id:"abc\r
160  "\r
161 -<<id:)>>\r
162 +id:)\r
163  id:\r
164 -c<<id:xxx>>\r
165 +cid:xxx\r
166  EOF\r
167  test_expect_equal_file EXPECTED OUTPUT\r
168  \r
169 -- \r
170 1.7.10.4\r
171 \r