Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / 15 / 645b9da717221bd0f3a77497967461b6c49228
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 7ED7E431FAF\r
6         for <notmuch@notmuchmail.org>; Wed,  8 Feb 2012 00:02:34 -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: -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 oleSCoeD+M9s for <notmuch@notmuchmail.org>;\r
16         Wed,  8 Feb 2012 00:02:32 -0800 (PST)\r
17 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
18         [74.125.82.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 AFDDC431FAE\r
21         for <notmuch@notmuchmail.org>; Wed,  8 Feb 2012 00:02:29 -0800 (PST)\r
22 Received: by werp13 with SMTP id p13so204855wer.26\r
23         for <notmuch@notmuchmail.org>; Wed, 08 Feb 2012 00:02:27 -0800 (PST)\r
24 MIME-Version: 1.0\r
25 Received: by 10.180.93.132 with SMTP id cu4mr24619138wib.9.1328688146996;\r
26         Wed, 08 Feb 2012 00:02:26 -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 dw7sm38019917wib.4.2012.02.08.00.02.22\r
30         (version=TLSv1/SSLv3 cipher=OTHER);\r
31         Wed, 08 Feb 2012 00:02:24 -0800 (PST)\r
32 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
33         id 44F3EA37FB; Wed,  8 Feb 2012 08:02:21 +0000 (GMT)\r
34 From: David Edmondson <dme@dme.org>\r
35 To: notmuch@notmuchmail.org\r
36 Subject: [PATCH v3 1/2] emacs: Use text properties rather than overlays in\r
37         `notmuch-show-mode'.\r
38 Date: Wed,  8 Feb 2012 08:02:11 +0000\r
39 Message-Id: <1328688139-3865-3-git-send-email-dme@dme.org>\r
40 X-Mailer: git-send-email 1.7.8.3\r
41 In-Reply-To: <1328688139-3865-1-git-send-email-dme@dme.org>\r
42 References: <1327486729-18052-1-git-send-email-dme@dme.org>\r
43         <1328688139-3865-1-git-send-email-dme@dme.org>\r
44 X-Gm-Message-State:\r
45  ALoCoQnf4ZETnf6LgjVHLIiuDO0HIcXULbpf7Nm4oFLxGEcbuWV9paUi3MRcakuywW1uwTaLQPAf\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Wed, 08 Feb 2012 08:02:35 -0000\r
59 \r
60 Except for where invisibility is involved, replace the use of overlays\r
61 in `notmuch-show-mode' with text properties, which are more efficient\r
62 and can be merged together more effectively.\r
63 ---\r
64  emacs/notmuch-show.el |   62 +++++++++++++++++++++++++++++++-----------------\r
65  emacs/notmuch-wash.el |    8 ++++-\r
66  2 files changed, 46 insertions(+), 24 deletions(-)\r
67 \r
68 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
69 index 7469e2e..bc1e7db 100644\r
70 --- a/emacs/notmuch-show.el\r
71 +++ b/emacs/notmuch-show.el\r
72 @@ -264,10 +264,10 @@ operation on the contents of the current buffer."\r
73                (t\r
74                 'message-header-other))))\r
75  \r
76 -    (overlay-put (make-overlay (point) (re-search-forward ":"))\r
77 -                'face 'message-header-name)\r
78 -    (overlay-put (make-overlay (point) (re-search-forward ".*$"))\r
79 -                'face face)))\r
80 +    (put-text-property (point) (re-search-forward ":")\r
81 +                      'face 'message-header-name)\r
82 +    (put-text-property (point) (re-search-forward ".*$")\r
83 +                      'face face)))\r
84  \r
85  (defun notmuch-show-colour-headers ()\r
86    "Apply some colouring to the current headers."\r
87 @@ -284,12 +284,11 @@ operation on the contents of the current buffer."\r
88    "Update the displayed tags of the current message."\r
89    (save-excursion\r
90      (goto-char (notmuch-show-message-top))\r
91 -    (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)\r
92 -       (let ((inhibit-read-only t))\r
93 -         (replace-match (concat "("\r
94 -                                (propertize (mapconcat 'identity tags " ")\r
95 -                                            'face 'notmuch-tag-face)\r
96 -                                ")"))))))\r
97 +    (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)\r
98 +      (let ((inhibit-read-only t))\r
99 +       (replace-match (propertize (mapconcat 'identity tags " ")\r
100 +                                  'face '(notmuch-tag-face notmuch-message-summary-face))\r
101 +                      nil nil nil 1)))))\r
102  \r
103  (defun notmuch-show-clean-address (address)\r
104    "Try to clean a single email ADDRESS for display.  Return\r
105 @@ -352,15 +351,26 @@ unchanged ADDRESS if parsing fails."\r
106    "Insert a notmuch style headerline based on HEADERS for a\r
107  message at DEPTH in the current thread."\r
108    (let ((start (point)))\r
109 -    (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))\r
110 -           (notmuch-show-clean-address (plist-get headers :From))\r
111 -           " ("\r
112 -           date\r
113 -           ") ("\r
114 -           (propertize (mapconcat 'identity tags " ")\r
115 -                       'face 'notmuch-tag-face)\r
116 -           ")\n")\r
117 -    (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))\r
118 +    (insert\r
119 +     (propertize (concat (notmuch-show-clean-address (plist-get headers :From))\r
120 +                        " ("\r
121 +                        date\r
122 +                        ") (")\r
123 +                'face 'notmuch-message-summary-face)\r
124 +     (propertize (mapconcat 'identity tags " ")\r
125 +                'face '(notmuch-tag-face notmuch-message-summary-face))\r
126 +     (propertize ")\n"\r
127 +                'face 'notmuch-message-summary-face))\r
128 +\r
129 +    ;; Ensure that any insertions at the start of this line (usually\r
130 +    ;; just spaces for indentation purposes) inherit the face of the\r
131 +    ;; rest of the line...\r
132 +    (put-text-property start (1+ start)\r
133 +                      'front-sticky '(face))\r
134 +    ;; ...and that insertions at the end of this region do _not_\r
135 +    ;; inherit the face of the rest of this line.\r
136 +    (put-text-property (1- (point)) (point)\r
137 +                      'rear-nonsticky '(face))))\r
138  \r
139  (defun notmuch-show-insert-header (header header-value)\r
140    "Insert a single header."\r
141 @@ -796,8 +806,15 @@ current buffer, if possible."\r
142  (defun notmuch-show-insert-bodypart (msg part depth)\r
143    "Insert the body part PART at depth DEPTH in the current thread."\r
144    (let ((content-type (downcase (plist-get part :content-type)))\r
145 -       (nth (plist-get part :id)))\r
146 -    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))\r
147 +       (nth (plist-get part :id))\r
148 +       (start (point)))\r
149 +    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)\r
150 +\r
151 +    ;; Ensure that face properties applied to text in the buffer by\r
152 +    ;; the part handler don't leak into the following text.\r
153 +    (put-text-property start (point-max)\r
154 +                      'rear-nonsticky '(face)))\r
155 +\r
156    ;; Some of the body part handlers leave point somewhere up in the\r
157    ;; part, so we make sure that we're down at the end.\r
158    (goto-char (point-max))\r
159 @@ -889,7 +906,8 @@ current buffer, if possible."\r
160      (setq content-end (point-marker))\r
161  \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
164 +    (indent-rigidly message-start message-end\r
165 +                   (* notmuch-show-indent-messages-width depth))\r
166  \r
167      (setq message-end (point-max-marker))\r
168  \r
169 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
170 index 56981d0..29a9d45 100644\r
171 --- a/emacs/notmuch-wash.el\r
172 +++ b/emacs/notmuch-wash.el\r
173 @@ -187,7 +187,9 @@ that PREFIX should not include a newline."\r
174      (let* ((cite-start (match-beginning 0))\r
175            (cite-end (match-end 0))\r
176            (cite-lines (count-lines cite-start cite-end)))\r
177 -      (overlay-put (make-overlay cite-start cite-end) 'face 'message-cited-text)\r
178 +      (put-text-property cite-start cite-end 'face 'message-cited-text)\r
179 +      ;; Ensure that the next line doesn't inherit our face.\r
180 +      (put-text-property (1- cite-end) cite-end 'rear-nonsticky '(face))\r
181        (when (> cite-lines (+ notmuch-wash-citation-lines-prefix\r
182                              notmuch-wash-citation-lines-suffix\r
183                              1))\r
184 @@ -209,7 +211,9 @@ that PREFIX should not include a newline."\r
185                   (sig-end-marker (make-marker)))\r
186               (set-marker sig-start-marker sig-start)\r
187               (set-marker sig-end-marker (point-max))\r
188 -             (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text)\r
189 +             (put-text-property sig-start-marker sig-end-marker 'face 'message-cited-text)\r
190 +             ;; Ensure that the next line doesn't inherit our face.\r
191 +             (put-text-property (1- sig-end-marker) sig-end-marker 'rear-nonsticky '(face))\r
192               (notmuch-wash-region-to-button\r
193                msg sig-start-marker sig-end-marker\r
194                "signature"))))))\r
195 -- \r
196 1.7.8.3\r
197 \r