Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 21 / a8fc594ebf74aec788b4e6ba8161b9dba8ce99
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 CC57142119B\r
6         for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 17:45:26 -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 DAdsDdqPZxm2 for <notmuch@notmuchmail.org>;\r
16         Thu, 12 Jul 2012 17:45:25 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
18         [18.9.25.15])\r
19         by olra.theworths.org (Postfix) with ESMTP id BA661431FAE\r
20         for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 17:45:25 -0700 (PDT)\r
21 X-AuditID: 1209190f-b7f306d0000008b4-93-4fff6fa596d1\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
23         by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id F4.91.02228.5AF6FFF4; Thu, 12 Jul 2012 20:45:25 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q6D0jPKO021124; \r
27         Thu, 12 Jul 2012 20:45:25 -0400\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 q6D0jND5010663\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Thu, 12 Jul 2012 20:45:24 -0400 (EDT)\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
36         (envelope-from <amdragon@mit.edu>)\r
37         id 1SpU0Z-0005Rw-Gj; Thu, 12 Jul 2012 20:45:23 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH 2/7] emacs: Use text properties instead of overlays for tag\r
41         coloring\r
42 Date: Thu, 12 Jul 2012 20:45:14 -0400\r
43 Message-Id: <1342140319-19859-3-git-send-email-amdragon@mit.edu>\r
44 X-Mailer: git-send-email 1.7.10\r
45 In-Reply-To: <1342140319-19859-1-git-send-email-amdragon@mit.edu>\r
46 References: <1342140319-19859-1-git-send-email-amdragon@mit.edu>\r
47 X-Brightmail-Tracker:\r
48  H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixG6nrrs0/7+/wfnLYhbXb85kdmD0eLbq\r
49         FnMAYxSXTUpqTmZZapG+XQJXxuyNKQUzpCvW7O5mbWDsEuti5OSQEDCR6N17iBHCFpO4cG89\r
50         WxcjF4eQwD5GiV9LLjKDJIQENjBKnGplhkg8YpJYeHEiK4Qzl1Fi4+wnrCBVbAIaEtv2Lwcb\r
51         JSIgLbHz7mygOAcHs4CaxJ8uFZCwsECIxIV3p1hAbBYBVYkl626zg9i8Ag4S369OhbpCXuLp\r
52         /T42EJtTwFFiw5cLrBBHOEg0HpvJPIGRfwEjwypG2ZTcKt3cxMyc4tRk3eLkxLy81CJdE73c\r
53         zBK91JTSTYygkOGU5N/B+O2g0iFGAQ5GJR7e37H//YVYE8uKK3MPMUpyMCmJ8rpkA4X4kvJT\r
54         KjMSizPii0pzUosPMUpwMCuJ8K6zB8rxpiRWVqUW5cOkpDlYlMR5r6bc9BcSSE8sSc1OTS1I\r
55         LYLJynBwKEnwcgJjQ0iwKDU9tSItM6cEIc3EwQkynAdo+LY8kOHFBYm5xZnpEPlTjIpS4rwX\r
56         QBICIImM0jy4XlhMv2IUB3pFmHcnSBUPMB3Adb8CGswENHjWz38gg0sSEVJSDYxlbZc/xu5e\r
57         f/0P14y36snZFRWPpA5dMghcsex8ubm/LsPL/Zt89ZzY9/A8/F0cdo+tuiFTpfLNVV++3+ll\r
58         89oexngVySz3Nzz8ZrLz1uKzi14fna7apZiR8WzWld3nP/48x5sbyV10VMRMNL98qcuxyG2l\r
59         VeeemIvGHQy+pnrc17feY99nzXIlluKMREMt5qLiRAD+QNtuxAIAAA==\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Fri, 13 Jul 2012 00:45:27 -0000\r
73 \r
74 Previously, tag-based search result highlighting was done by creating\r
75 an overlay over each search result.  However, overlays have annoying\r
76 front- and rear-advancement semantics that make it difficult to\r
77 manipulate text at their boundaries, which the next patch will do.\r
78 They also have performance problems (creating an overlay is linear in\r
79 the number of overlays between point and the new overlay, making\r
80 highlighting a search buffer quadratic in the number of results).\r
81 \r
82 Text properties have neither problem.  However, text properties make\r
83 it more difficult to apply multiple faces since, unlike with overlays,\r
84 a given character can only have a single 'face text property.  Hence,\r
85 we introduce a utility function that combines faces into any existing\r
86 'face text properties.\r
87 \r
88 Using this utility function, it's straightforward to apply all of the\r
89 appropriate tag faces in notmuch-search-color-line.\r
90 ---\r
91  emacs/notmuch-lib.el |   15 +++++++++++++++\r
92  emacs/notmuch.el     |   21 +++++++--------------\r
93  2 files changed, 22 insertions(+), 14 deletions(-)\r
94 \r
95 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
96 index aa25513..30db58f 100644\r
97 --- a/emacs/notmuch-lib.el\r
98 +++ b/emacs/notmuch-lib.el\r
99 @@ -269,6 +269,21 @@ current buffer, if possible."\r
100    (loop for (key value . rest) on plist by #'cddr\r
101         collect (cons (intern (substring (symbol-name key) 1)) value)))\r
102  \r
103 +(defun notmuch-combine-face-text-property (start end face)\r
104 +  "Combine FACE into the 'face text property between START and END.\r
105 +\r
106 +This function combines FACE with any existing faces between START\r
107 +and END.  Attributes specified by FACE take precedence over\r
108 +existing attributes.  FACE must be a face name (a symbol or\r
109 +string), a property list of face attributes, or a list of these."\r
110 +\r
111 +  (let ((pos start))\r
112 +    (while (< pos end)\r
113 +      (let ((cur (get-text-property pos 'face))\r
114 +           (next (next-single-property-change pos 'face nil end)))\r
115 +       (put-text-property pos next 'face (cons face cur))\r
116 +       (setq pos next)))))\r
117 +\r
118  ;; Compatibility functions for versions of emacs before emacs 23.\r
119  ;;\r
120  ;; Both functions here were copied from emacs 23 with the following copyright:\r
121 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
122 index ef18927..82c148d 100644\r
123 --- a/emacs/notmuch.el\r
124 +++ b/emacs/notmuch.el\r
125 @@ -633,20 +633,13 @@ foreground and blue background."\r
126  \r
127  (defun notmuch-search-color-line (start end line-tag-list)\r
128    "Colorize lines in `notmuch-show' based on tags."\r
129 -  ;; Create the overlay only if the message has tags which match one\r
130 -  ;; of those specified in `notmuch-search-line-faces'.\r
131 -  (let (overlay)\r
132 -    (mapc (lambda (elem)\r
133 -           (let ((tag (car elem))\r
134 -                 (attributes (cdr elem)))\r
135 -             (when (member tag line-tag-list)\r
136 -               (when (not overlay)\r
137 -                 (setq overlay (make-overlay start end)))\r
138 -               ;; Merge the specified properties with any already\r
139 -               ;; applied from an earlier match.\r
140 -               (overlay-put overlay 'face\r
141 -                            (append (overlay-get overlay 'face) attributes)))))\r
142 -         notmuch-search-line-faces)))\r
143 +  (mapc (lambda (elem)\r
144 +         (let ((tag (car elem))\r
145 +               (attributes (cdr elem)))\r
146 +           (when (member tag line-tag-list)\r
147 +             (notmuch-combine-face-text-property start end attributes))))\r
148 +       ;; Reverse the list so earlier entries take precedence\r
149 +       (reverse notmuch-search-line-faces)))\r
150  \r
151  (defun notmuch-search-author-propertize (authors)\r
152    "Split `authors' into matching and non-matching authors and\r
153 -- \r
154 1.7.10\r
155 \r