Re: [PATCH] add has: query prefix to search for specific properties
[notmuch-archives.git] / 38 / 94b56c5c10ad4a0e984dd3ff1b817b3b441ed5
1 Return-Path: <m.walters@qmul.ac.uk>\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 42367431FB6\r
6         for <notmuch@notmuchmail.org>; Sat, 11 Feb 2012 14:24:58 -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: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 l78Gjk3UDCac for <notmuch@notmuchmail.org>;\r
17         Sat, 11 Feb 2012 14:24:57 -0800 (PST)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 1D490431FAE\r
22         for <notmuch@notmuchmail.org>; Sat, 11 Feb 2012 14:24:57 -0800 (PST)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1RwLNC-0002yX-Os; Sat, 11 Feb 2012 22:24:53 +0000\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
28         helo=localhost)\r
29         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
30         (envelope-from <m.walters@qmul.ac.uk>)\r
31         id 1RwLNC-0004Pv-9I; Sat, 11 Feb 2012 22:24:50 +0000\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org\r
34 Subject: Re: [PATCH v3 1/2] emacs: Use text properties rather than overlays in\r
35         `notmuch-show-mode'.\r
36 In-Reply-To: <1328604377-20121-2-git-send-email-dme@dme.org>\r
37 References: <1327405007-4026-1-git-send-email-dme@dme.org>\r
38         <1328604377-20121-1-git-send-email-dme@dme.org>\r
39         <1328604377-20121-2-git-send-email-dme@dme.org>\r
40 User-Agent: Notmuch/0.11.1+172~g6a5d2c5 (http://notmuchmail.org) Emacs/23.2.1\r
41         (i486-pc-linux-gnu)\r
42 Date: Sat, 11 Feb 2012 22:26:09 +0000\r
43 Message-ID: <87hayxm2gu.fsf@qmul.ac.uk>\r
44 MIME-Version: 1.0\r
45 Content-Type: text/plain; charset=us-ascii\r
46 X-Sender-Host-Address: 94.192.233.223\r
47 X-QM-SPAM-Info: Sender has good ham record.  :)\r
48 X-QM-Body-MD5: 6e1d7473f94427528500a7fc9a0db091 (of first 20000 bytes)\r
49 X-SpamAssassin-Score: -1.8\r
50 X-SpamAssassin-SpamBar: -\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
52         determine if it is\r
53         spam. We require at least 5.0 points to mark a message as spam.\r
54         This message scored -1.8 points.\r
55         Summary of the scoring: \r
56         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
57         *      medium trust\r
58         *      [138.37.6.40 listed in list.dnswl.org]\r
59         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
60         provider *      (markwalters1009[at]gmail.com)\r
61         * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
62         *      domain\r
63         *  0.5 AWL AWL: From: address is in the auto white-list\r
64 X-QM-Scan-Virus: ClamAV says the message is clean\r
65 X-BeenThere: notmuch@notmuchmail.org\r
66 X-Mailman-Version: 2.1.13\r
67 Precedence: list\r
68 List-Id: "Use and development of the notmuch mail system."\r
69         <notmuch.notmuchmail.org>\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
73 List-Post: <mailto:notmuch@notmuchmail.org>\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
76         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
77 X-List-Received-Date: Sat, 11 Feb 2012 22:24:58 -0000\r
78 \r
79 \r
80 Hi\r
81 \r
82 I looked at this and think its ok except for one trivial (but\r
83 significant) rebase error.\r
84 \r
85 Best wishes \r
86 \r
87 Mark\r
88 \r
89 On Tue,  7 Feb 2012 08:46:16 +0000, David Edmondson <dme@dme.org> wrote:\r
90 > Except for where invisibility is involved, replace the use of overlays\r
91 > in `notmuch-show-mode' with text properties, which are more efficient\r
92 > and can be merged together more effectively.\r
93 > ---\r
94 >  emacs/notmuch-show.el |   62 +++++++++++++++++++++++++++++++-----------------\r
95 >  emacs/notmuch-wash.el |    8 ++++-\r
96 >  2 files changed, 46 insertions(+), 24 deletions(-)\r
97\r
98 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
99 > index 7469e2e..bc1e7db 100644\r
100 > --- a/emacs/notmuch-show.el\r
101 > +++ b/emacs/notmuch-show.el\r
102 > @@ -264,10 +264,10 @@ operation on the contents of the current buffer."\r
103 >              (t\r
104 >               'message-header-other))))\r
105 >  \r
106 > -    (overlay-put (make-overlay (point) (re-search-forward ":"))\r
107 > -              'face 'message-header-name)\r
108 > -    (overlay-put (make-overlay (point) (re-search-forward ".*$"))\r
109 > -              'face face)))\r
110 > +    (put-text-property (point) (re-search-forward ":")\r
111 > +                    'face 'message-header-name)\r
112 > +    (put-text-property (point) (re-search-forward ".*$")\r
113 > +                    'face face)))\r
114 >  \r
115 >  (defun notmuch-show-colour-headers ()\r
116 >    "Apply some colouring to the current headers."\r
117 > @@ -284,12 +284,11 @@ operation on the contents of the current buffer."\r
118 >    "Update the displayed tags of the current message."\r
119 >    (save-excursion\r
120 >      (goto-char (notmuch-show-message-top))\r
121 > -    (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)\r
122 > -     (let ((inhibit-read-only t))\r
123 > -       (replace-match (concat "("\r
124 > -                              (propertize (mapconcat 'identity tags " ")\r
125 > -                                          'face 'notmuch-tag-face)\r
126 > -                              ")"))))))\r
127 > +    (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)\r
128 > +      (let ((inhibit-read-only t))\r
129 > +     (replace-match (propertize (mapconcat 'identity tags " ")\r
130 > +                                'face '(notmuch-tag-face notmuch-message-summary-face))\r
131 > +                    nil nil nil 1)))))\r
132 >  \r
133 >  (defun notmuch-show-clean-address (address)\r
134 >    "Try to clean a single email ADDRESS for display.  Return\r
135 > @@ -352,15 +351,26 @@ unchanged ADDRESS if parsing fails."\r
136 >    "Insert a notmuch style headerline based on HEADERS for a\r
137 >  message at DEPTH in the current thread."\r
138 >    (let ((start (point)))\r
139 > -    (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))\r
140 > -         (notmuch-show-clean-address (plist-get headers :From))\r
141 > -         " ("\r
142 > -         date\r
143 > -         ") ("\r
144 > -         (propertize (mapconcat 'identity tags " ")\r
145 > -                     'face 'notmuch-tag-face)\r
146 > -         ")\n")\r
147 > -    (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))\r
148 > +    (insert\r
149 > +     (propertize (concat (notmuch-show-clean-address (plist-get headers :From))\r
150 > +                      " ("\r
151 > +                      date\r
152 > +                      ") (")\r
153 > +              'face 'notmuch-message-summary-face)\r
154 > +     (propertize (mapconcat 'identity tags " ")\r
155 > +              'face '(notmuch-tag-face notmuch-message-summary-face))\r
156 > +     (propertize ")\n"\r
157 > +              'face 'notmuch-message-summary-face))\r
158 > +\r
159 > +    ;; Ensure that any insertions at the start of this line (usually\r
160 > +    ;; just spaces for indentation purposes) inherit the face of the\r
161 > +    ;; rest of the line...\r
162 > +    (put-text-property start (1+ start)\r
163 > +                    'front-sticky '(face))\r
164 > +    ;; ...and that insertions at the end of this region do _not_\r
165 > +    ;; inherit the face of the rest of this line.\r
166 > +    (put-text-property (1- (point)) (point)\r
167 > +                    'rear-nonsticky '(face))))\r
168 >  \r
169 >  (defun notmuch-show-insert-header (header header-value)\r
170 >    "Insert a single header."\r
171 > @@ -796,8 +806,15 @@ current buffer, if possible."\r
172 >  (defun notmuch-show-insert-bodypart (msg part depth)\r
173 >    "Insert the body part PART at depth DEPTH in the current thread."\r
174 >    (let ((content-type (downcase (plist-get part :content-type)))\r
175 > -     (nth (plist-get part :id)))\r
176 > -    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))\r
177 > +     (nth (plist-get part :id))\r
178 > +     (start (point)))\r
179 > +    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)\r
180 > +\r
181 > +    ;; Ensure that face properties applied to text in the buffer by\r
182 > +    ;; the part handler don't leak into the following text.\r
183 > +    (put-text-property start (point-max)\r
184 > +                    'rear-nonsticky '(face)))\r
185 > +\r
186 >    ;; Some of the body part handlers leave point somewhere up in the\r
187 >    ;; part, so we make sure that we're down at the end.\r
188 >    (goto-char (point-max))\r
189 > @@ -889,7 +906,8 @@ current buffer, if possible."\r
190 >      (setq content-end (point-marker))\r
191 >  \r
192 >      ;; Indent according to the depth in the thread.\r
193 > -    (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth))\r
194 > +    (indent-rigidly message-start message-end\r
195 > +                 (* notmuch-show-indent-messages-width depth))\r
196 >  \r
197 >      (setq message-end (point-max-marker))\r
198 \r
199 I think the setq has to come before the indent-rigidly. (Also I think\r
200 there is a whitespace error in the second line of the indent-rigidly.)\r
201 \r
202 >  \r
203 > diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
204 > index 56981d0..29a9d45 100644\r
205 > --- a/emacs/notmuch-wash.el\r
206 > +++ b/emacs/notmuch-wash.el\r
207 > @@ -187,7 +187,9 @@ that PREFIX should not include a newline."\r
208 >      (let* ((cite-start (match-beginning 0))\r
209 >          (cite-end (match-end 0))\r
210 >          (cite-lines (count-lines cite-start cite-end)))\r
211 > -      (overlay-put (make-overlay cite-start cite-end) 'face 'message-cited-text)\r
212 > +      (put-text-property cite-start cite-end 'face 'message-cited-text)\r
213 > +      ;; Ensure that the next line doesn't inherit our face.\r
214 > +      (put-text-property (1- cite-end) cite-end 'rear-nonsticky '(face))\r
215 >        (when (> cite-lines (+ notmuch-wash-citation-lines-prefix\r
216 >                            notmuch-wash-citation-lines-suffix\r
217 >                            1))\r
218 > @@ -209,7 +211,9 @@ that PREFIX should not include a newline."\r
219 >                 (sig-end-marker (make-marker)))\r
220 >             (set-marker sig-start-marker sig-start)\r
221 >             (set-marker sig-end-marker (point-max))\r
222 > -           (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text)\r
223 > +           (put-text-property sig-start-marker sig-end-marker 'face 'message-cited-text)\r
224 > +           ;; Ensure that the next line doesn't inherit our face.\r
225 > +           (put-text-property (1- sig-end-marker) sig-end-marker 'rear-nonsticky '(face))\r
226 >             (notmuch-wash-region-to-button\r
227 >              msg sig-start-marker sig-end-marker\r
228 >              "signature"))))))\r
229 > -- \r
230 > 1.7.8.3\r
231\r
232 > _______________________________________________\r
233 > notmuch mailing list\r
234 > notmuch@notmuchmail.org\r
235 > http://notmuchmail.org/mailman/listinfo/notmuch\r