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 F05FB421192
\r
6 for <notmuch@notmuchmail.org>; Tue, 24 Jan 2012 03:38:04 -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 fVmtGrHa6Ctz for <notmuch@notmuchmail.org>;
\r
16 Tue, 24 Jan 2012 03:38:02 -0800 (PST)
\r
17 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com
\r
18 [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id AC612429E54
\r
21 for <notmuch@notmuchmail.org>; Tue, 24 Jan 2012 03:38:01 -0800 (PST)
\r
22 Received: by wibhi8 with SMTP id hi8so1469492wib.26
\r
23 for <notmuch@notmuchmail.org>; Tue, 24 Jan 2012 03:38:00 -0800 (PST)
\r
25 Received: by 10.180.81.66 with SMTP id y2mr19814993wix.20.1327405080413;
\r
26 Tue, 24 Jan 2012 03:38:00 -0800 (PST)
\r
27 Received: from hotblack-desiato.hh.sledj.net
\r
28 (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])
\r
29 by mx.google.com with ESMTPS id eq5sm51535261wib.2.2012.01.24.03.37.58
\r
30 (version=TLSv1/SSLv3 cipher=OTHER);
\r
31 Tue, 24 Jan 2012 03:37:59 -0800 (PST)
\r
32 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
33 id 3EFDE9FD48; Tue, 24 Jan 2012 11:37:57 +0000 (GMT)
\r
34 From: David Edmondson <dme@dme.org>
\r
35 To: notmuch@notmuchmail.org
\r
36 Subject: [PATCH 1/2] emacs: Use text properties rather than overlays in
\r
37 `notmuch-show-mode'.
\r
38 Date: Tue, 24 Jan 2012 11:36:46 +0000
\r
39 Message-Id: <1327405007-4026-2-git-send-email-dme@dme.org>
\r
40 X-Mailer: git-send-email 1.7.8.3
\r
41 In-Reply-To: <1327405007-4026-1-git-send-email-dme@dme.org>
\r
42 References: <1327405007-4026-1-git-send-email-dme@dme.org>
\r
44 ALoCoQlRKoszs2VPoVgyWVX4moy2RnU8eoyVFtIp38FrD3ThXRvrjtnjfDWkd5LC4+IUqGDc7RaC
\r
45 X-BeenThere: notmuch@notmuchmail.org
\r
46 X-Mailman-Version: 2.1.13
\r
48 List-Id: "Use and development of the notmuch mail system."
\r
49 <notmuch.notmuchmail.org>
\r
50 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
52 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
53 List-Post: <mailto:notmuch@notmuchmail.org>
\r
54 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
55 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
56 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
57 X-List-Received-Date: Tue, 24 Jan 2012 11:38:05 -0000
\r
59 Except for where invisibility is involved, replace the use of overlays
\r
60 in `notmuch-show-mode' with text properties, which are more efficient
\r
61 and can be merged together more effectively.
\r
63 emacs/notmuch-show.el | 66 +++++++++++++++++++++++++++++++-----------------
\r
64 emacs/notmuch-wash.el | 8 ++++-
\r
65 2 files changed, 48 insertions(+), 26 deletions(-)
\r
67 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
68 index e6a5b31..d6a0ac0 100644
\r
69 --- a/emacs/notmuch-show.el
\r
70 +++ b/emacs/notmuch-show.el
\r
71 @@ -258,10 +258,10 @@ operation on the contents of the current buffer."
\r
73 'message-header-other))))
\r
75 - (overlay-put (make-overlay (point) (re-search-forward ":"))
\r
76 - 'face 'message-header-name)
\r
77 - (overlay-put (make-overlay (point) (re-search-forward ".*$"))
\r
79 + (put-text-property (point) (re-search-forward ":")
\r
80 + 'face 'message-header-name)
\r
81 + (put-text-property (point) (re-search-forward ".*$")
\r
84 (defun notmuch-show-colour-headers ()
\r
85 "Apply some colouring to the current headers."
\r
86 @@ -278,12 +278,11 @@ operation on the contents of the current buffer."
\r
87 "Update the displayed tags of the current message."
\r
89 (goto-char (notmuch-show-message-top))
\r
90 - (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
\r
91 - (let ((inhibit-read-only t))
\r
92 - (replace-match (concat "("
\r
93 - (propertize (mapconcat 'identity tags " ")
\r
94 - 'face 'notmuch-tag-face)
\r
96 + (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
\r
97 + (let ((inhibit-read-only t))
\r
98 + (replace-match (propertize (mapconcat 'identity tags " ")
\r
99 + 'face '(notmuch-tag-face notmuch-message-summary-face))
\r
100 + nil nil nil 1)))))
\r
102 (defun notmuch-show-clean-address (address)
\r
103 "Try to clean a single email ADDRESS for display. Return
\r
104 @@ -310,15 +309,26 @@ unchanged ADDRESS if parsing fails."
\r
105 "Insert a notmuch style headerline based on HEADERS for a
\r
106 message at DEPTH in the current thread."
\r
107 (let ((start (point)))
\r
108 - (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))
\r
109 - (notmuch-show-clean-address (plist-get headers :From))
\r
113 - (propertize (mapconcat 'identity tags " ")
\r
114 - 'face 'notmuch-tag-face)
\r
116 - (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
\r
118 + (propertize (concat (notmuch-show-clean-address (plist-get headers :From))
\r
122 + 'face 'notmuch-message-summary-face)
\r
123 + (propertize (mapconcat 'identity tags " ")
\r
124 + 'face '(notmuch-tag-face notmuch-message-summary-face))
\r
125 + (propertize ")\n"
\r
126 + 'face 'notmuch-message-summary-face))
\r
128 + ;; Ensure that any insertions at the start of this line (usually
\r
129 + ;; just spaces for indentation purposes) inherit the face of the
\r
130 + ;; rest of the line...
\r
131 + (put-text-property start (1+ start)
\r
132 + 'front-sticky '(face))
\r
133 + ;; ...and that insertions at the end of this region do _not_
\r
134 + ;; inherit the face of the rest of this line.
\r
135 + (put-text-property (1- (point)) (point)
\r
136 + 'rear-nonsticky '(face))))
\r
138 (defun notmuch-show-insert-header (header header-value)
\r
139 "Insert a single header."
\r
140 @@ -753,8 +763,15 @@ current buffer, if possible."
\r
141 (defun notmuch-show-insert-bodypart (msg part depth)
\r
142 "Insert the body part PART at depth DEPTH in the current thread."
\r
143 (let ((content-type (downcase (plist-get part :content-type)))
\r
144 - (nth (plist-get part :id)))
\r
145 - (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
\r
146 + (nth (plist-get part :id))
\r
148 + (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)
\r
150 + ;; Ensure that face properties applied to text in the buffer by
\r
151 + ;; the part handler don't leak into the following text.
\r
152 + (put-text-property start (point-max)
\r
153 + 'rear-nonsticky '(face)))
\r
155 ;; Some of the body part handlers leave point somewhere up in the
\r
156 ;; part, so we make sure that we're down at the end.
\r
157 (goto-char (point-max))
\r
158 @@ -845,11 +862,12 @@ current buffer, if possible."
\r
159 (setq body-end (point-marker))
\r
160 (setq content-end (point-marker))
\r
162 - ;; Indent according to the depth in the thread.
\r
163 - (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth))
\r
165 (setq message-end (point-max-marker))
\r
167 + ;; Indent according to the depth in the thread.
\r
168 + (indent-rigidly message-start message-end
\r
169 + (* notmuch-show-indent-messages-width depth))
\r
171 ;; Save the extents of this message over the whole text of the
\r
173 (put-text-property message-start message-end :notmuch-message-extent (cons message-start message-end))
\r
174 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
\r
175 index 5c1e830..84428a4 100644
\r
176 --- a/emacs/notmuch-wash.el
\r
177 +++ b/emacs/notmuch-wash.el
\r
178 @@ -183,7 +183,9 @@ insert before the button, probably for indentation."
\r
179 (let* ((cite-start (match-beginning 0))
\r
180 (cite-end (match-end 0))
\r
181 (cite-lines (count-lines cite-start cite-end)))
\r
182 - (overlay-put (make-overlay cite-start cite-end) 'face 'message-cited-text)
\r
183 + (put-text-property cite-start cite-end 'face 'message-cited-text)
\r
184 + ;; Ensure that the next line doesn't inherit our face.
\r
185 + (put-text-property (1- cite-end) cite-end 'rear-nonsticky '(face))
\r
186 (when (> cite-lines (+ notmuch-wash-citation-lines-prefix
\r
187 notmuch-wash-citation-lines-suffix
\r
189 @@ -205,7 +207,9 @@ insert before the button, probably for indentation."
\r
190 (sig-end-marker (make-marker)))
\r
191 (set-marker sig-start-marker sig-start)
\r
192 (set-marker sig-end-marker (point-max))
\r
193 - (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text)
\r
194 + (put-text-property sig-start-marker sig-end-marker 'face 'message-cited-text)
\r
195 + ;; Ensure that the next line doesn't inherit our face.
\r
196 + (put-text-property (1- sig-end-marker) sig-end-marker 'rear-nonsticky '(face))
\r
197 (notmuch-wash-region-to-button
\r
198 msg sig-start-marker sig-end-marker
\r
199 "signature" "\n"))))))
\r