1 Return-Path: <dme@dme.org>
\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 D5C00431FBD
\r
6 for <notmuch@notmuchmail.org>; Tue, 7 Feb 2012 00:46:26 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 3eaEFUajlNOk for <notmuch@notmuchmail.org>;
\r
16 Tue, 7 Feb 2012 00:46:26 -0800 (PST)
\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com
\r
18 [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
19 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
20 C9A0C431FAE for <notmuch@notmuchmail.org>; Tue, 7 Feb 2012 00:46:25 -0800
\r
22 Received: by wgbdt12 with SMTP id dt12so6168829wgb.2
\r
23 for <notmuch@notmuchmail.org>; Tue, 07 Feb 2012 00:46:23 -0800 (PST)
\r
24 Received: by 10.180.103.132 with SMTP id fw4mr41753613wib.3.1328604383156;
\r
25 Tue, 07 Feb 2012 00:46:23 -0800 (PST)
\r
26 Received: from hotblack-desiato.hh.sledj.net
\r
27 (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])
\r
28 by mx.google.com with ESMTPS id ho4sm30661130wib.3.2012.02.07.00.46.20
\r
29 (version=TLSv1/SSLv3 cipher=OTHER);
\r
30 Tue, 07 Feb 2012 00:46:21 -0800 (PST)
\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
32 id 0CE0DA05C6; Tue, 7 Feb 2012 08:46:19 +0000 (GMT)
\r
33 From: David Edmondson <dme@dme.org>
\r
34 To: notmuch@notmuchmail.org
\r
35 Subject: [PATCH v3 1/2] emacs: Use text properties rather than overlays in
\r
36 `notmuch-show-mode'.
\r
37 Date: Tue, 7 Feb 2012 08:46:16 +0000
\r
38 Message-Id: <1328604377-20121-2-git-send-email-dme@dme.org>
\r
39 X-Mailer: git-send-email 1.7.8.3
\r
40 In-Reply-To: <1328604377-20121-1-git-send-email-dme@dme.org>
\r
41 References: <1327405007-4026-1-git-send-email-dme@dme.org>
\r
42 <1328604377-20121-1-git-send-email-dme@dme.org>
\r
43 X-BeenThere: notmuch@notmuchmail.org
\r
44 X-Mailman-Version: 2.1.13
\r
46 List-Id: "Use and development of the notmuch mail system."
\r
47 <notmuch.notmuchmail.org>
\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
51 List-Post: <mailto:notmuch@notmuchmail.org>
\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
55 X-List-Received-Date: Tue, 07 Feb 2012 08:46:27 -0000
\r
57 Except for where invisibility is involved, replace the use of overlays
\r
58 in `notmuch-show-mode' with text properties, which are more efficient
\r
59 and can be merged together more effectively.
\r
61 emacs/notmuch-show.el | 62 +++++++++++++++++++++++++++++++-----------------
\r
62 emacs/notmuch-wash.el | 8 ++++-
\r
63 2 files changed, 46 insertions(+), 24 deletions(-)
\r
65 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
66 index 7469e2e..bc1e7db 100644
\r
67 --- a/emacs/notmuch-show.el
\r
68 +++ b/emacs/notmuch-show.el
\r
69 @@ -264,10 +264,10 @@ operation on the contents of the current buffer."
\r
71 'message-header-other))))
\r
73 - (overlay-put (make-overlay (point) (re-search-forward ":"))
\r
74 - 'face 'message-header-name)
\r
75 - (overlay-put (make-overlay (point) (re-search-forward ".*$"))
\r
77 + (put-text-property (point) (re-search-forward ":")
\r
78 + 'face 'message-header-name)
\r
79 + (put-text-property (point) (re-search-forward ".*$")
\r
82 (defun notmuch-show-colour-headers ()
\r
83 "Apply some colouring to the current headers."
\r
84 @@ -284,12 +284,11 @@ operation on the contents of the current buffer."
\r
85 "Update the displayed tags of the current message."
\r
87 (goto-char (notmuch-show-message-top))
\r
88 - (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
\r
89 - (let ((inhibit-read-only t))
\r
90 - (replace-match (concat "("
\r
91 - (propertize (mapconcat 'identity tags " ")
\r
92 - 'face 'notmuch-tag-face)
\r
94 + (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
\r
95 + (let ((inhibit-read-only t))
\r
96 + (replace-match (propertize (mapconcat 'identity tags " ")
\r
97 + 'face '(notmuch-tag-face notmuch-message-summary-face))
\r
98 + nil nil nil 1)))))
\r
100 (defun notmuch-show-clean-address (address)
\r
101 "Try to clean a single email ADDRESS for display. Return
\r
102 @@ -352,15 +351,26 @@ unchanged ADDRESS if parsing fails."
\r
103 "Insert a notmuch style headerline based on HEADERS for a
\r
104 message at DEPTH in the current thread."
\r
105 (let ((start (point)))
\r
106 - (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))
\r
107 - (notmuch-show-clean-address (plist-get headers :From))
\r
111 - (propertize (mapconcat 'identity tags " ")
\r
112 - 'face 'notmuch-tag-face)
\r
114 - (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
\r
116 + (propertize (concat (notmuch-show-clean-address (plist-get headers :From))
\r
120 + 'face 'notmuch-message-summary-face)
\r
121 + (propertize (mapconcat 'identity tags " ")
\r
122 + 'face '(notmuch-tag-face notmuch-message-summary-face))
\r
123 + (propertize ")\n"
\r
124 + 'face 'notmuch-message-summary-face))
\r
126 + ;; Ensure that any insertions at the start of this line (usually
\r
127 + ;; just spaces for indentation purposes) inherit the face of the
\r
128 + ;; rest of the line...
\r
129 + (put-text-property start (1+ start)
\r
130 + 'front-sticky '(face))
\r
131 + ;; ...and that insertions at the end of this region do _not_
\r
132 + ;; inherit the face of the rest of this line.
\r
133 + (put-text-property (1- (point)) (point)
\r
134 + 'rear-nonsticky '(face))))
\r
136 (defun notmuch-show-insert-header (header header-value)
\r
137 "Insert a single header."
\r
138 @@ -796,8 +806,15 @@ current buffer, if possible."
\r
139 (defun notmuch-show-insert-bodypart (msg part depth)
\r
140 "Insert the body part PART at depth DEPTH in the current thread."
\r
141 (let ((content-type (downcase (plist-get part :content-type)))
\r
142 - (nth (plist-get part :id)))
\r
143 - (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
\r
144 + (nth (plist-get part :id))
\r
146 + (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)
\r
148 + ;; Ensure that face properties applied to text in the buffer by
\r
149 + ;; the part handler don't leak into the following text.
\r
150 + (put-text-property start (point-max)
\r
151 + 'rear-nonsticky '(face)))
\r
153 ;; Some of the body part handlers leave point somewhere up in the
\r
154 ;; part, so we make sure that we're down at the end.
\r
155 (goto-char (point-max))
\r
156 @@ -889,7 +906,8 @@ current buffer, if possible."
\r
157 (setq content-end (point-marker))
\r
159 ;; Indent according to the depth in the thread.
\r
160 - (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth))
\r
161 + (indent-rigidly message-start message-end
\r
162 + (* notmuch-show-indent-messages-width depth))
\r
164 (setq message-end (point-max-marker))
\r
166 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
\r
167 index 56981d0..29a9d45 100644
\r
168 --- a/emacs/notmuch-wash.el
\r
169 +++ b/emacs/notmuch-wash.el
\r
170 @@ -187,7 +187,9 @@ that PREFIX should not include a newline."
\r
171 (let* ((cite-start (match-beginning 0))
\r
172 (cite-end (match-end 0))
\r
173 (cite-lines (count-lines cite-start cite-end)))
\r
174 - (overlay-put (make-overlay cite-start cite-end) 'face 'message-cited-text)
\r
175 + (put-text-property cite-start cite-end 'face 'message-cited-text)
\r
176 + ;; Ensure that the next line doesn't inherit our face.
\r
177 + (put-text-property (1- cite-end) cite-end 'rear-nonsticky '(face))
\r
178 (when (> cite-lines (+ notmuch-wash-citation-lines-prefix
\r
179 notmuch-wash-citation-lines-suffix
\r
181 @@ -209,7 +211,9 @@ that PREFIX should not include a newline."
\r
182 (sig-end-marker (make-marker)))
\r
183 (set-marker sig-start-marker sig-start)
\r
184 (set-marker sig-end-marker (point-max))
\r
185 - (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text)
\r
186 + (put-text-property sig-start-marker sig-end-marker 'face 'message-cited-text)
\r
187 + ;; Ensure that the next line doesn't inherit our face.
\r
188 + (put-text-property (1- sig-end-marker) sig-end-marker 'rear-nonsticky '(face))
\r
189 (notmuch-wash-region-to-button
\r
190 msg sig-start-marker sig-end-marker
\r