[PATCH v2 05/14] cli/reply: reorganize create_reply_message()
[notmuch-archives.git] / e2 / 5e182415e0c7d36036da9127cd9ea811b98047
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 D07C6431FC3\r
6         for <notmuch@notmuchmail.org>; Fri, 13 Jul 2012 11:43:13 -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 U7AtCs89czgo for <notmuch@notmuchmail.org>;\r
16         Fri, 13 Jul 2012 11:43:13 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU\r
18         [18.9.25.12])\r
19         by olra.theworths.org (Postfix) with ESMTP id 110CA431FAE\r
20         for <notmuch@notmuchmail.org>; Fri, 13 Jul 2012 11:43:13 -0700 (PDT)\r
21 X-AuditID: 1209190c-b7f806d000006b87-f9-50006c3e29f1\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
23         by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 90.EB.27527.F3C60005; Fri, 13 Jul 2012 14:43:11 -0400 (EDT)\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 q6DIhAmL010142; \r
27         Fri, 13 Jul 2012 14:43:10 -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 q6DIh9iV020003\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Fri, 13 Jul 2012 14:43:09 -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 1SpkpY-0008D3-RJ; Fri, 13 Jul 2012 14:43:08 -0400\r
37 Date: Fri, 13 Jul 2012 14:43:08 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: Mark Walters <markwalters1009@gmail.com>\r
40 Subject: Re: [PATCH 2/7] emacs: Use text properties instead of overlays for\r
41         tag coloring\r
42 Message-ID: <20120713184308.GB31182@mit.edu>\r
43 References: <1342140319-19859-1-git-send-email-amdragon@mit.edu>\r
44         <1342140319-19859-3-git-send-email-amdragon@mit.edu>\r
45         <877gu78ruk.fsf@qmul.ac.uk>\r
46 MIME-Version: 1.0\r
47 Content-Type: text/plain; charset=us-ascii\r
48 Content-Disposition: inline\r
49 In-Reply-To: <877gu78ruk.fsf@qmul.ac.uk>\r
50 User-Agent: Mutt/1.5.21 (2010-09-15)\r
51 X-Brightmail-Tracker:\r
52  H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hRV1rXPYQgwuLec2WL1XB6L6zdnMjsw\r
53         eeycdZfd49mqW8wBTFFcNimpOZllqUX6dglcGUun32Up2Kla8eT8FfYGxkuyXYycHBICJhK7\r
54         f15jhrDFJC7cW8/WxcjFISSwj1Fi7e9uZghnA6PEy0+LmCCck0wS827fZodwljBKzPi8E6yf\r
55         RUBV4ueBV6wgNpuAhsS2/csZQWwRAR2J24cWsIPYzALSEt9+NwNN4uAQFoiS2Ho6AiTMC1Ry\r
56         5fQhRoiZUxklTvzZyg6REJQ4OfMJC0SvlsSNfy/BekHmLP/HARLmBFrVPHU+G4gtKqAiMeXk\r
57         NrYJjEKzkHTPQtI9C6F7ASPzKkbZlNwq3dzEzJzi1GTd4uTEvLzUIl1DvdzMEr3UlNJNjOCw\r
58         luTZwfjmoNIhRgEORiUe3nR/hgAh1sSy4srcQ4ySHExKorw/M4FCfEn5KZUZicUZ8UWlOanF\r
59         hxglOJiVRHh1jIFyvCmJlVWpRfkwKWkOFiVx3sspN/2FBNITS1KzU1MLUotgsjIcHEoSvAnZ\r
60         QI2CRanpqRVpmTklCGkmDk6Q4TxAw4NAaniLCxJzizPTIfKnGBWlxHlngyQEQBIZpXlwvbC0\r
61         84pRHOgVYd4wkCoeYMqC634FNJgJaPCsn//8gQaXJCKkpBoYk5++fXFC0cpWkMHi0P95saKR\r
62         GnpP7mU3s2Yy/I7z4W27EnPQ5NICD/5d+zur7EI6/R+cufvy+J34PpuvIc+m7JY2UTOVUuro\r
63         lf10oMri3ddd/9WzvrgInwpjmBe9LefgrdonFx9lFDFEHHZtidXk/X1curi91vPSSvG7kn8F\r
64         C6MV43Xkj2QqsRRnJBpqMRcVJwIARt2fIhYDAAA=\r
65 Cc: notmuch@notmuchmail.org\r
66 X-BeenThere: notmuch@notmuchmail.org\r
67 X-Mailman-Version: 2.1.13\r
68 Precedence: list\r
69 List-Id: "Use and development of the notmuch mail system."\r
70         <notmuch.notmuchmail.org>\r
71 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
72         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
73 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
74 List-Post: <mailto:notmuch@notmuchmail.org>\r
75 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
76 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
77         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
78 X-List-Received-Date: Fri, 13 Jul 2012 18:43:14 -0000\r
79 \r
80 Quoth Mark Walters on Jul 13 at  6:59 pm:\r
81 > On Fri, 13 Jul 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
82 > > Previously, tag-based search result highlighting was done by creating\r
83 > > an overlay over each search result.  However, overlays have annoying\r
84 > > front- and rear-advancement semantics that make it difficult to\r
85 > > manipulate text at their boundaries, which the next patch will do.\r
86 > > They also have performance problems (creating an overlay is linear in\r
87 > > the number of overlays between point and the new overlay, making\r
88 > > highlighting a search buffer quadratic in the number of results).\r
89 > >\r
90 > > Text properties have neither problem.  However, text properties make\r
91 > > it more difficult to apply multiple faces since, unlike with overlays,\r
92 > > a given character can only have a single 'face text property.  Hence,\r
93 > > we introduce a utility function that combines faces into any existing\r
94 > > 'face text properties.\r
95 > >\r
96 > > Using this utility function, it's straightforward to apply all of the\r
97 > > appropriate tag faces in notmuch-search-color-line.\r
98\r
99 > I have some recollection of people talking about text properties as\r
100 > opposed to overlays some time ago but saying one problem was you\r
101 > couldn't do invisibility with text properties. Is that correct and is it\r
102 > a concern? (Otherwise it all looks good)\r
103 \r
104 I believe the problem was that isearch can only automatically expand\r
105 invisible text that's marked invisible using overlays.  Regardless,\r
106 this shouldn't be an issue for this patch because invisibility and\r
107 faces are controlled by different text properties.  It also shouldn't\r
108 be a problem for the next patch because, while we do use overlays to\r
109 hide authors, that overlay should always be strictly within the search\r
110 result (even if it's at the end of the result format, we'll follow it\r
111 with a newline) and hence deleting the entire search result region\r
112 should also delete the author invisibility overlay.\r
113 \r
114 > Best wishes\r
115\r
116 > Mark\r
117 > > ---\r
118 > >  emacs/notmuch-lib.el |   15 +++++++++++++++\r
119 > >  emacs/notmuch.el     |   21 +++++++--------------\r
120 > >  2 files changed, 22 insertions(+), 14 deletions(-)\r
121 > >\r
122 > > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
123 > > index aa25513..30db58f 100644\r
124 > > --- a/emacs/notmuch-lib.el\r
125 > > +++ b/emacs/notmuch-lib.el\r
126 > > @@ -269,6 +269,21 @@ current buffer, if possible."\r
127 > >    (loop for (key value . rest) on plist by #'cddr\r
128 > >     collect (cons (intern (substring (symbol-name key) 1)) value)))\r
129 > >  \r
130 > > +(defun notmuch-combine-face-text-property (start end face)\r
131 > > +  "Combine FACE into the 'face text property between START and END.\r
132 > > +\r
133 > > +This function combines FACE with any existing faces between START\r
134 > > +and END.  Attributes specified by FACE take precedence over\r
135 > > +existing attributes.  FACE must be a face name (a symbol or\r
136 > > +string), a property list of face attributes, or a list of these."\r
137 > > +\r
138 > > +  (let ((pos start))\r
139 > > +    (while (< pos end)\r
140 > > +      (let ((cur (get-text-property pos 'face))\r
141 > > +       (next (next-single-property-change pos 'face nil end)))\r
142 > > +   (put-text-property pos next 'face (cons face cur))\r
143 > > +   (setq pos next)))))\r
144 > > +\r
145 > >  ;; Compatibility functions for versions of emacs before emacs 23.\r
146 > >  ;;\r
147 > >  ;; Both functions here were copied from emacs 23 with the following copyright:\r
148 > > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
149 > > index ef18927..82c148d 100644\r
150 > > --- a/emacs/notmuch.el\r
151 > > +++ b/emacs/notmuch.el\r
152 > > @@ -633,20 +633,13 @@ foreground and blue background."\r
153 > >  \r
154 > >  (defun notmuch-search-color-line (start end line-tag-list)\r
155 > >    "Colorize lines in `notmuch-show' based on tags."\r
156 > > -  ;; Create the overlay only if the message has tags which match one\r
157 > > -  ;; of those specified in `notmuch-search-line-faces'.\r
158 > > -  (let (overlay)\r
159 > > -    (mapc (lambda (elem)\r
160 > > -       (let ((tag (car elem))\r
161 > > -             (attributes (cdr elem)))\r
162 > > -         (when (member tag line-tag-list)\r
163 > > -           (when (not overlay)\r
164 > > -             (setq overlay (make-overlay start end)))\r
165 > > -           ;; Merge the specified properties with any already\r
166 > > -           ;; applied from an earlier match.\r
167 > > -           (overlay-put overlay 'face\r
168 > > -                        (append (overlay-get overlay 'face) attributes)))))\r
169 > > -     notmuch-search-line-faces)))\r
170 > > +  (mapc (lambda (elem)\r
171 > > +     (let ((tag (car elem))\r
172 > > +           (attributes (cdr elem)))\r
173 > > +       (when (member tag line-tag-list)\r
174 > > +         (notmuch-combine-face-text-property start end attributes))))\r
175 > > +   ;; Reverse the list so earlier entries take precedence\r
176 > > +   (reverse notmuch-search-line-faces)))\r
177 > >  \r
178 > >  (defun notmuch-search-author-propertize (authors)\r
179 > >    "Split `authors' into matching and non-matching authors and\r