use text properties rather than overlays

classic Classic list List threaded Threaded
13 messages Options
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

use text properties rather than overlays

In preparation for changes to support showing and hiding MIME parts on
the fly (general parts, choosing amongst multipart/alternative and
show updated signing/encryption status without redisplay) I'm trying
to clean up some of the `notmuch-show-mode' code. This patch is part
of that, though it stands upon its' own.

Austin provided some code to allow the invisible overlays to be added
to `notmuch-search-mode' buffers lazily. That same approach could be
used here, but it's not implemented yet.

[PATCH 1/2] emacs: Use text properties rather than overlays in
[PATCH 2/2] test: Update test to match previous patch.
_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.

Except for where invisibility is involved, replace the use of overlays
in `notmuch-show-mode' with text properties, which are more efficient
and can be merged together more effectively.
---
 emacs/notmuch-show.el |   66 +++++++++++++++++++++++++++++++-----------------
 emacs/notmuch-wash.el |    8 ++++-
 2 files changed, 48 insertions(+), 26 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e6a5b31..d6a0ac0 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -258,10 +258,10 @@ operation on the contents of the current buffer."
        (t
  'message-header-other))))
 
-    (overlay-put (make-overlay (point) (re-search-forward ":"))
- 'face 'message-header-name)
-    (overlay-put (make-overlay (point) (re-search-forward ".*$"))
- 'face face)))
+    (put-text-property (point) (re-search-forward ":")
+       'face 'message-header-name)
+    (put-text-property (point) (re-search-forward ".*$")
+       'face face)))
 
 (defun notmuch-show-colour-headers ()
   "Apply some colouring to the current headers."
@@ -278,12 +278,11 @@ operation on the contents of the current buffer."
   "Update the displayed tags of the current message."
   (save-excursion
     (goto-char (notmuch-show-message-top))
-    (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
- (let ((inhibit-read-only t))
-  (replace-match (concat "("
- (propertize (mapconcat 'identity tags " ")
-     'face 'notmuch-tag-face)
- ")"))))))
+    (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
+      (let ((inhibit-read-only t))
+ (replace-match (propertize (mapconcat 'identity tags " ")
+   'face '(notmuch-tag-face notmuch-message-summary-face))
+       nil nil nil 1)))))
 
 (defun notmuch-show-clean-address (address)
   "Try to clean a single email ADDRESS for display.  Return
@@ -310,15 +309,26 @@ unchanged ADDRESS if parsing fails."
   "Insert a notmuch style headerline based on HEADERS for a
 message at DEPTH in the current thread."
   (let ((start (point)))
-    (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))
-    (notmuch-show-clean-address (plist-get headers :From))
-    " ("
-    date
-    ") ("
-    (propertize (mapconcat 'identity tags " ")
- 'face 'notmuch-tag-face)
-    ")\n")
-    (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
+    (insert
+     (propertize (concat (notmuch-show-clean-address (plist-get headers :From))
+ " ("
+ date
+ ") (")
+ 'face 'notmuch-message-summary-face)
+     (propertize (mapconcat 'identity tags " ")
+ 'face '(notmuch-tag-face notmuch-message-summary-face))
+     (propertize ")\n"
+ 'face 'notmuch-message-summary-face))
+
+    ;; Ensure that any insertions at the start of this line (usually
+    ;; just spaces for indentation purposes) inherit the face of the
+    ;; rest of the line...
+    (put-text-property start (1+ start)
+       'front-sticky '(face))
+    ;; ...and that insertions at the end of this region do _not_
+    ;; inherit the face of the rest of this line.
+    (put-text-property (1- (point)) (point)
+       'rear-nonsticky '(face))))
 
 (defun notmuch-show-insert-header (header header-value)
   "Insert a single header."
@@ -753,8 +763,15 @@ current buffer, if possible."
 (defun notmuch-show-insert-bodypart (msg part depth)
   "Insert the body part PART at depth DEPTH in the current thread."
   (let ((content-type (downcase (plist-get part :content-type)))
- (nth (plist-get part :id)))
-    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
+ (nth (plist-get part :id))
+ (start (point)))
+    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)
+
+    ;; Ensure that face properties applied to text in the buffer by
+    ;; the part handler don't leak into the following text.
+    (put-text-property start (point-max)
+       'rear-nonsticky '(face)))
+
   ;; Some of the body part handlers leave point somewhere up in the
   ;; part, so we make sure that we're down at the end.
   (goto-char (point-max))
@@ -845,11 +862,12 @@ current buffer, if possible."
     (setq body-end (point-marker))
     (setq content-end (point-marker))
 
-    ;; Indent according to the depth in the thread.
-    (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth))
-
     (setq message-end (point-max-marker))
 
+    ;; Indent according to the depth in the thread.
+    (indent-rigidly message-start message-end
+        (* notmuch-show-indent-messages-width depth))
+
     ;; Save the extents of this message over the whole text of the
     ;; message.
     (put-text-property message-start message-end :notmuch-message-extent (cons message-start message-end))
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 5c1e830..84428a4 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -183,7 +183,9 @@ insert before the button, probably for indentation."
     (let* ((cite-start (match-beginning 0))
    (cite-end (match-end 0))
    (cite-lines (count-lines cite-start cite-end)))
-      (overlay-put (make-overlay cite-start cite-end) 'face 'message-cited-text)
+      (put-text-property cite-start cite-end 'face 'message-cited-text)
+      ;; Ensure that the next line doesn't inherit our face.
+      (put-text-property (1- cite-end) cite-end 'rear-nonsticky '(face))
       (when (> cite-lines (+ notmuch-wash-citation-lines-prefix
      notmuch-wash-citation-lines-suffix
      1))
@@ -205,7 +207,9 @@ insert before the button, probably for indentation."
   (sig-end-marker (make-marker)))
       (set-marker sig-start-marker sig-start)
       (set-marker sig-end-marker (point-max))
-      (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text)
+      (put-text-property sig-start-marker sig-end-marker 'face 'message-cited-text)
+      ;; Ensure that the next line doesn't inherit our face.
+      (put-text-property (1- sig-end-marker) sig-end-marker 'rear-nonsticky '(face))
       (notmuch-wash-region-to-button
        msg sig-start-marker sig-end-marker
        "signature" "\n"))))))
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH 2/2] test: Update test to match previous patch.

In reply to this post by David Edmondson
Indentation now uses tabs where possible.
---
 ...hread-maildir-storage-with-fourfold-indentation |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
index b0bf93e..1f7801e 100644
--- a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
+++ b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
@@ -69,7 +69,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
     notmuch mailing list
     [hidden email]
     http://notmuchmail.org/mailman/listinfo/notmuch
-        Lars Kellogg-Stedman <[hidden email]> (2009-11-17) (inbox signed unread)
+ Lars Kellogg-Stedman <[hidden email]> (2009-11-17) (inbox signed unread)
  Subject: Re: [notmuch] Working with Maildir storage?
  To: Mikhail Gusarov <[hidden email]>
  Cc: [hidden email]
@@ -101,7 +101,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
  notmuch mailing list
  [hidden email]
  http://notmuchmail.org/mailman/listinfo/notmuch
-            Mikhail Gusarov <[hidden email]> (2009-11-17) (inbox unread)
+    Mikhail Gusarov <[hidden email]> (2009-11-17) (inbox unread)
     Subject: [notmuch] Working with Maildir storage?
     To: [hidden email]
     Date: Wed, 18 Nov 2009 02:50:48 +0600
@@ -129,7 +129,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
     Desc: not available
     URL:
     <http://notmuchmail.org/pipermail/notmuch/attachments/20091118/0e33d964/attachment.pgp>
-            Keith Packard <[hidden email]> (2009-11-17) (inbox unread)
+    Keith Packard <[hidden email]> (2009-11-17) (inbox unread)
     Subject: [notmuch] Working with Maildir storage?
     To: [hidden email]
     Date: Tue, 17 Nov 2009 13:24:13 -0800
@@ -151,7 +151,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
     Thanks to everyone for trying out notmuch!
 
     -keith
-                Lars Kellogg-Stedman <[hidden email]> (2009-11-18) (inbox signed unread)
+ Lars Kellogg-Stedman <[hidden email]> (2009-11-18) (inbox signed unread)
  Subject: Re: [notmuch] Working with Maildir storage?
  To: Keith Packard <[hidden email]>
  Cc: [hidden email]
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Austin Clements Austin Clements
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.

In reply to this post by David Edmondson
LGTM other than one very minor nit, though I pretty reliably make
fence post errors when dealing with text properties, so perhaps
somebody else should check that.

Quoth David Edmondson on Jan 24 at 11:36 am:

> Except for where invisibility is involved, replace the use of overlays
> in `notmuch-show-mode' with text properties, which are more efficient
> and can be merged together more effectively.
> ---
>  emacs/notmuch-show.el |   66 +++++++++++++++++++++++++++++++-----------------
>  emacs/notmuch-wash.el |    8 ++++-
>  2 files changed, 48 insertions(+), 26 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index e6a5b31..d6a0ac0 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -258,10 +258,10 @@ operation on the contents of the current buffer."
>         (t
>   'message-header-other))))
>  
> -    (overlay-put (make-overlay (point) (re-search-forward ":"))
> - 'face 'message-header-name)
> -    (overlay-put (make-overlay (point) (re-search-forward ".*$"))
> - 'face face)))
> +    (put-text-property (point) (re-search-forward ":")
> +       'face 'message-header-name)
> +    (put-text-property (point) (re-search-forward ".*$")
> +       'face face)))

Does this need rear-nonsticky or are the headers already formed enough
by this point that it isn't necessary?

>  
>  (defun notmuch-show-colour-headers ()
>    "Apply some colouring to the current headers."
> @@ -278,12 +278,11 @@ operation on the contents of the current buffer."
>    "Update the displayed tags of the current message."
>    (save-excursion
>      (goto-char (notmuch-show-message-top))
> -    (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
> - (let ((inhibit-read-only t))
> -  (replace-match (concat "("
> - (propertize (mapconcat 'identity tags " ")
> -     'face 'notmuch-tag-face)
> - ")"))))))
> +    (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
> +      (let ((inhibit-read-only t))
> + (replace-match (propertize (mapconcat 'identity tags " ")
> +   'face '(notmuch-tag-face notmuch-message-summary-face))
> +       nil nil nil 1)))))
>  
>  (defun notmuch-show-clean-address (address)
>    "Try to clean a single email ADDRESS for display.  Return
> @@ -310,15 +309,26 @@ unchanged ADDRESS if parsing fails."
>    "Insert a notmuch style headerline based on HEADERS for a
>  message at DEPTH in the current thread."
>    (let ((start (point)))
> -    (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))
> -    (notmuch-show-clean-address (plist-get headers :From))
> -    " ("
> -    date
> -    ") ("
> -    (propertize (mapconcat 'identity tags " ")
> - 'face 'notmuch-tag-face)
> -    ")\n")
> -    (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
> +    (insert
> +     (propertize (concat (notmuch-show-clean-address (plist-get headers :From))
> + " ("
> + date
> + ") (")
> + 'face 'notmuch-message-summary-face)
> +     (propertize (mapconcat 'identity tags " ")
> + 'face '(notmuch-tag-face notmuch-message-summary-face))

I feel like I should know this, but what's the effect of giving a list
as the face property?  I assume it merges them in the same way it
merges, say, overlay and text property faces, but the documentation
only says that you can give a list, not what it means.

> +     (propertize ")\n"
> + 'face 'notmuch-message-summary-face))
> +
> +    ;; Ensure that any insertions at the start of this line (usually
> +    ;; just spaces for indentation purposes) inherit the face of the
> +    ;; rest of the line...
> +    (put-text-property start (1+ start)
> +       'front-sticky '(face))
> +    ;; ...and that insertions at the end of this region do _not_
> +    ;; inherit the face of the rest of this line.
> +    (put-text-property (1- (point)) (point)
> +       'rear-nonsticky '(face))))
>  
>  (defun notmuch-show-insert-header (header header-value)
>    "Insert a single header."
> @@ -753,8 +763,15 @@ current buffer, if possible."
>  (defun notmuch-show-insert-bodypart (msg part depth)
>    "Insert the body part PART at depth DEPTH in the current thread."
>    (let ((content-type (downcase (plist-get part :content-type)))
> - (nth (plist-get part :id)))
> -    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
> + (nth (plist-get part :id))
> + (start (point)))
> +    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)
> +
> +    ;; Ensure that face properties applied to text in the buffer by
> +    ;; the part handler don't leak into the following text.
> +    (put-text-property start (point-max)
> +       'rear-nonsticky '(face)))
> +
>    ;; Some of the body part handlers leave point somewhere up in the
>    ;; part, so we make sure that we're down at the end.
>    (goto-char (point-max))
> @@ -845,11 +862,12 @@ current buffer, if possible."
>      (setq body-end (point-marker))
>      (setq content-end (point-marker))
>  
> -    ;; Indent according to the depth in the thread.
> -    (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth))
> -
>      (setq message-end (point-max-marker))
>  
> +    ;; Indent according to the depth in the thread.
> +    (indent-rigidly message-start message-end
> +        (* notmuch-show-indent-messages-width depth))
> +

Why swap the order of the setq and the indent-rigidly?

>      ;; Save the extents of this message over the whole text of the
>      ;; message.
>      (put-text-property message-start message-end :notmuch-message-extent (cons message-start message-end))
> diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
> index 5c1e830..84428a4 100644
> --- a/emacs/notmuch-wash.el
> +++ b/emacs/notmuch-wash.el
> @@ -183,7 +183,9 @@ insert before the button, probably for indentation."
>      (let* ((cite-start (match-beginning 0))
>     (cite-end (match-end 0))
>     (cite-lines (count-lines cite-start cite-end)))
> -      (overlay-put (make-overlay cite-start cite-end) 'face 'message-cited-text)
> +      (put-text-property cite-start cite-end 'face 'message-cited-text)
> +      ;; Ensure that the next line doesn't inherit our face.
> +      (put-text-property (1- cite-end) cite-end 'rear-nonsticky '(face))
>        (when (> cite-lines (+ notmuch-wash-citation-lines-prefix
>       notmuch-wash-citation-lines-suffix
>       1))
> @@ -205,7 +207,9 @@ insert before the button, probably for indentation."
>    (sig-end-marker (make-marker)))
>        (set-marker sig-start-marker sig-start)
>        (set-marker sig-end-marker (point-max))
> -      (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text)
> +      (put-text-property sig-start-marker sig-end-marker 'face 'message-cited-text)
> +      ;; Ensure that the next line doesn't inherit our face.
> +      (put-text-property (1- sig-end-marker) sig-end-marker 'rear-nonsticky '(face))
>        (notmuch-wash-region-to-button
>         msg sig-start-marker sig-end-marker
>         "signature" "\n"))))))
_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.

On Tue, 24 Jan 2012 11:15:11 -0500, Austin Clements <[hidden email]> wrote:

> LGTM other than one very minor nit, though I pretty reliably make
> fence post errors when dealing with text properties, so perhaps
> somebody else should check that.
>
> Quoth David Edmondson on Jan 24 at 11:36 am:
> > Except for where invisibility is involved, replace the use of overlays
> > in `notmuch-show-mode' with text properties, which are more efficient
> > and can be merged together more effectively.
> > ---
> >  emacs/notmuch-show.el |   66 +++++++++++++++++++++++++++++++-----------------
> >  emacs/notmuch-wash.el |    8 ++++-
> >  2 files changed, 48 insertions(+), 26 deletions(-)
> >
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index e6a5b31..d6a0ac0 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -258,10 +258,10 @@ operation on the contents of the current buffer."
> >         (t
> >   'message-header-other))))
> >  
> > -    (overlay-put (make-overlay (point) (re-search-forward ":"))
> > - 'face 'message-header-name)
> > -    (overlay-put (make-overlay (point) (re-search-forward ".*$"))
> > - 'face face)))
> > +    (put-text-property (point) (re-search-forward ":")
> > +       'face 'message-header-name)
> > +    (put-text-property (point) (re-search-forward ".*$")
> > +       'face face)))
>
> Does this need rear-nonsticky or are the headers already formed enough
> by this point that it isn't necessary?
It isn't necessary here.

> >  (defun notmuch-show-colour-headers ()
> >    "Apply some colouring to the current headers."
> > @@ -278,12 +278,11 @@ operation on the contents of the current buffer."
> >    "Update the displayed tags of the current message."
> >    (save-excursion
> >      (goto-char (notmuch-show-message-top))
> > -    (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
> > - (let ((inhibit-read-only t))
> > -  (replace-match (concat "("
> > - (propertize (mapconcat 'identity tags " ")
> > -     'face 'notmuch-tag-face)
> > - ")"))))))
> > +    (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
> > +      (let ((inhibit-read-only t))
> > + (replace-match (propertize (mapconcat 'identity tags " ")
> > +   'face '(notmuch-tag-face notmuch-message-summary-face))
> > +       nil nil nil 1)))))
> >  
> >  (defun notmuch-show-clean-address (address)
> >    "Try to clean a single email ADDRESS for display.  Return
> > @@ -310,15 +309,26 @@ unchanged ADDRESS if parsing fails."
> >    "Insert a notmuch style headerline based on HEADERS for a
> >  message at DEPTH in the current thread."
> >    (let ((start (point)))
> > -    (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))
> > -    (notmuch-show-clean-address (plist-get headers :From))
> > -    " ("
> > -    date
> > -    ") ("
> > -    (propertize (mapconcat 'identity tags " ")
> > - 'face 'notmuch-tag-face)
> > -    ")\n")
> > -    (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
> > +    (insert
> > +     (propertize (concat (notmuch-show-clean-address (plist-get headers :From))
> > + " ("
> > + date
> > + ") (")
> > + 'face 'notmuch-message-summary-face)
> > +     (propertize (mapconcat 'identity tags " ")
> > + 'face '(notmuch-tag-face notmuch-message-summary-face))
>
> I feel like I should know this, but what's the effect of giving a list
> as the face property?  I assume it merges them in the same way it
> merges, say, overlay and text property faces, but the documentation
> only says that you can give a list, not what it means.
It's as though they are applied in reverse order, so attributes of the
faces nearer the front of the list win.

> > +     (propertize ")\n"
> > + 'face 'notmuch-message-summary-face))
> > +
> > +    ;; Ensure that any insertions at the start of this line (usually
> > +    ;; just spaces for indentation purposes) inherit the face of the
> > +    ;; rest of the line...
> > +    (put-text-property start (1+ start)
> > +       'front-sticky '(face))
> > +    ;; ...and that insertions at the end of this region do _not_
> > +    ;; inherit the face of the rest of this line.
> > +    (put-text-property (1- (point)) (point)
> > +       'rear-nonsticky '(face))))
> >  
> >  (defun notmuch-show-insert-header (header header-value)
> >    "Insert a single header."
> > @@ -753,8 +763,15 @@ current buffer, if possible."
> >  (defun notmuch-show-insert-bodypart (msg part depth)
> >    "Insert the body part PART at depth DEPTH in the current thread."
> >    (let ((content-type (downcase (plist-get part :content-type)))
> > - (nth (plist-get part :id)))
> > -    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
> > + (nth (plist-get part :id))
> > + (start (point)))
> > +    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)
> > +
> > +    ;; Ensure that face properties applied to text in the buffer by
> > +    ;; the part handler don't leak into the following text.
> > +    (put-text-property start (point-max)
> > +       'rear-nonsticky '(face)))
> > +
> >    ;; Some of the body part handlers leave point somewhere up in the
> >    ;; part, so we make sure that we're down at the end.
> >    (goto-char (point-max))
> > @@ -845,11 +862,12 @@ current buffer, if possible."
> >      (setq body-end (point-marker))
> >      (setq content-end (point-marker))
> >  
> > -    ;; Indent according to the depth in the thread.
> > -    (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth))
> > -
> >      (setq message-end (point-max-marker))
> >  
> > +    ;; Indent according to the depth in the thread.
> > +    (indent-rigidly message-start message-end
> > +        (* notmuch-show-indent-messages-width depth))
> > +
>
> Why swap the order of the setq and the indent-rigidly?
A mistake.

I spent some time trying to use `line-prefix' and `wrap-prefix'
properties to replace the indentation, but couldn't get it to work well
when combined with invisible overlays (the effect is as though faces
start bleeding out from the end of the invisible region).

>
> >      ;; Save the extents of this message over the whole text of the
> >      ;; message.
> >      (put-text-property message-start message-end :notmuch-message-extent (cons message-start message-end))
> > diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
> > index 5c1e830..84428a4 100644
> > --- a/emacs/notmuch-wash.el
> > +++ b/emacs/notmuch-wash.el
> > @@ -183,7 +183,9 @@ insert before the button, probably for indentation."
> >      (let* ((cite-start (match-beginning 0))
> >     (cite-end (match-end 0))
> >     (cite-lines (count-lines cite-start cite-end)))
> > -      (overlay-put (make-overlay cite-start cite-end) 'face 'message-cited-text)
> > +      (put-text-property cite-start cite-end 'face 'message-cited-text)
> > +      ;; Ensure that the next line doesn't inherit our face.
> > +      (put-text-property (1- cite-end) cite-end 'rear-nonsticky '(face))
> >        (when (> cite-lines (+ notmuch-wash-citation-lines-prefix
> >       notmuch-wash-citation-lines-suffix
> >       1))
> > @@ -205,7 +207,9 @@ insert before the button, probably for indentation."
> >    (sig-end-marker (make-marker)))
> >        (set-marker sig-start-marker sig-start)
> >        (set-marker sig-end-marker (point-max))
> > -      (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text)
> > +      (put-text-property sig-start-marker sig-end-marker 'face 'message-cited-text)
> > +      ;; Ensure that the next line doesn't inherit our face.
> > +      (put-text-property (1- sig-end-marker) sig-end-marker 'rear-nonsticky '(face))
> >        (notmuch-wash-region-to-button
> >         msg sig-start-marker sig-end-marker
> >         "signature" "\n"))))))

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch

attachment0 (203 bytes) Download Attachment
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH v2 0/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.

In reply to this post by David Edmondson
v2:
- simple rebase.

David Edmondson (2):
  emacs: Use text properties rather than overlays in
    `notmuch-show-mode'.
  test: Update test to match previous patch.

 emacs/notmuch-show.el                              |   66 ++++++++++++-------
 emacs/notmuch-wash.el                              |    8 ++-
 ...hread-maildir-storage-with-fourfold-indentation |    8 +-
 3 files changed, 52 insertions(+), 30 deletions(-)

--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH v2 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.

Except for where invisibility is involved, replace the use of overlays
in `notmuch-show-mode' with text properties, which are more efficient
and can be merged together more effectively.
---
 emacs/notmuch-show.el |   66 +++++++++++++++++++++++++++++++-----------------
 emacs/notmuch-wash.el |    8 ++++-
 2 files changed, 48 insertions(+), 26 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7469e2e..13d2e81 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -264,10 +264,10 @@ operation on the contents of the current buffer."
        (t
  'message-header-other))))
 
-    (overlay-put (make-overlay (point) (re-search-forward ":"))
- 'face 'message-header-name)
-    (overlay-put (make-overlay (point) (re-search-forward ".*$"))
- 'face face)))
+    (put-text-property (point) (re-search-forward ":")
+       'face 'message-header-name)
+    (put-text-property (point) (re-search-forward ".*$")
+       'face face)))
 
 (defun notmuch-show-colour-headers ()
   "Apply some colouring to the current headers."
@@ -284,12 +284,11 @@ operation on the contents of the current buffer."
   "Update the displayed tags of the current message."
   (save-excursion
     (goto-char (notmuch-show-message-top))
-    (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
- (let ((inhibit-read-only t))
-  (replace-match (concat "("
- (propertize (mapconcat 'identity tags " ")
-     'face 'notmuch-tag-face)
- ")"))))))
+    (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
+      (let ((inhibit-read-only t))
+ (replace-match (propertize (mapconcat 'identity tags " ")
+   'face '(notmuch-tag-face notmuch-message-summary-face))
+       nil nil nil 1)))))
 
 (defun notmuch-show-clean-address (address)
   "Try to clean a single email ADDRESS for display.  Return
@@ -352,15 +351,26 @@ unchanged ADDRESS if parsing fails."
   "Insert a notmuch style headerline based on HEADERS for a
 message at DEPTH in the current thread."
   (let ((start (point)))
-    (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))
-    (notmuch-show-clean-address (plist-get headers :From))
-    " ("
-    date
-    ") ("
-    (propertize (mapconcat 'identity tags " ")
- 'face 'notmuch-tag-face)
-    ")\n")
-    (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
+    (insert
+     (propertize (concat (notmuch-show-clean-address (plist-get headers :From))
+ " ("
+ date
+ ") (")
+ 'face 'notmuch-message-summary-face)
+     (propertize (mapconcat 'identity tags " ")
+ 'face '(notmuch-tag-face notmuch-message-summary-face))
+     (propertize ")\n"
+ 'face 'notmuch-message-summary-face))
+
+    ;; Ensure that any insertions at the start of this line (usually
+    ;; just spaces for indentation purposes) inherit the face of the
+    ;; rest of the line...
+    (put-text-property start (1+ start)
+       'front-sticky '(face))
+    ;; ...and that insertions at the end of this region do _not_
+    ;; inherit the face of the rest of this line.
+    (put-text-property (1- (point)) (point)
+       'rear-nonsticky '(face))))
 
 (defun notmuch-show-insert-header (header header-value)
   "Insert a single header."
@@ -796,8 +806,15 @@ current buffer, if possible."
 (defun notmuch-show-insert-bodypart (msg part depth)
   "Insert the body part PART at depth DEPTH in the current thread."
   (let ((content-type (downcase (plist-get part :content-type)))
- (nth (plist-get part :id)))
-    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
+ (nth (plist-get part :id))
+ (start (point)))
+    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)
+
+    ;; Ensure that face properties applied to text in the buffer by
+    ;; the part handler don't leak into the following text.
+    (put-text-property start (point-max)
+       'rear-nonsticky '(face)))
+
   ;; Some of the body part handlers leave point somewhere up in the
   ;; part, so we make sure that we're down at the end.
   (goto-char (point-max))
@@ -888,11 +905,12 @@ current buffer, if possible."
     (setq body-end (point-marker))
     (setq content-end (point-marker))
 
-    ;; Indent according to the depth in the thread.
-    (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth))
-
     (setq message-end (point-max-marker))
 
+    ;; Indent according to the depth in the thread.
+    (indent-rigidly message-start message-end
+        (* notmuch-show-indent-messages-width depth))
+
     ;; Save the extents of this message over the whole text of the
     ;; message.
     (put-text-property message-start message-end :notmuch-message-extent (cons message-start message-end))
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 56981d0..29a9d45 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -187,7 +187,9 @@ that PREFIX should not include a newline."
     (let* ((cite-start (match-beginning 0))
    (cite-end (match-end 0))
    (cite-lines (count-lines cite-start cite-end)))
-      (overlay-put (make-overlay cite-start cite-end) 'face 'message-cited-text)
+      (put-text-property cite-start cite-end 'face 'message-cited-text)
+      ;; Ensure that the next line doesn't inherit our face.
+      (put-text-property (1- cite-end) cite-end 'rear-nonsticky '(face))
       (when (> cite-lines (+ notmuch-wash-citation-lines-prefix
      notmuch-wash-citation-lines-suffix
      1))
@@ -209,7 +211,9 @@ that PREFIX should not include a newline."
   (sig-end-marker (make-marker)))
       (set-marker sig-start-marker sig-start)
       (set-marker sig-end-marker (point-max))
-      (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text)
+      (put-text-property sig-start-marker sig-end-marker 'face 'message-cited-text)
+      ;; Ensure that the next line doesn't inherit our face.
+      (put-text-property (1- sig-end-marker) sig-end-marker 'rear-nonsticky '(face))
       (notmuch-wash-region-to-button
        msg sig-start-marker sig-end-marker
        "signature"))))))
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH v2 2/2] test: Update test to match previous patch.

In reply to this post by David Edmondson
Indentation now uses tabs where possible.
---
 ...hread-maildir-storage-with-fourfold-indentation |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
index b0bf93e..1f7801e 100644
--- a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
+++ b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
@@ -69,7 +69,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
     notmuch mailing list
     [hidden email]
     http://notmuchmail.org/mailman/listinfo/notmuch
-        Lars Kellogg-Stedman <[hidden email]> (2009-11-17) (inbox signed unread)
+ Lars Kellogg-Stedman <[hidden email]> (2009-11-17) (inbox signed unread)
  Subject: Re: [notmuch] Working with Maildir storage?
  To: Mikhail Gusarov <[hidden email]>
  Cc: [hidden email]
@@ -101,7 +101,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
  notmuch mailing list
  [hidden email]
  http://notmuchmail.org/mailman/listinfo/notmuch
-            Mikhail Gusarov <[hidden email]> (2009-11-17) (inbox unread)
+    Mikhail Gusarov <[hidden email]> (2009-11-17) (inbox unread)
     Subject: [notmuch] Working with Maildir storage?
     To: [hidden email]
     Date: Wed, 18 Nov 2009 02:50:48 +0600
@@ -129,7 +129,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
     Desc: not available
     URL:
     <http://notmuchmail.org/pipermail/notmuch/attachments/20091118/0e33d964/attachment.pgp>
-            Keith Packard <[hidden email]> (2009-11-17) (inbox unread)
+    Keith Packard <[hidden email]> (2009-11-17) (inbox unread)
     Subject: [notmuch] Working with Maildir storage?
     To: [hidden email]
     Date: Tue, 17 Nov 2009 13:24:13 -0800
@@ -151,7 +151,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
     Thanks to everyone for trying out notmuch!
 
     -keith
-                Lars Kellogg-Stedman <[hidden email]> (2009-11-18) (inbox signed unread)
+ Lars Kellogg-Stedman <[hidden email]> (2009-11-18) (inbox signed unread)
  Subject: Re: [notmuch] Working with Maildir storage?
  To: Keith Packard <[hidden email]>
  Cc: [hidden email]
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH v2 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.

In reply to this post by David Edmondson
On Mon,  6 Feb 2012 16:08:21 +0000, David Edmondson <[hidden email]> wrote:
> Except for where invisibility is involved, replace the use of overlays
> in `notmuch-show-mode' with text properties, which are more efficient
> and can be merged together more effectively.

Austin reviewed this (id:"[hidden email]"), but
suggested that someone else should look it over. Any volunteers?

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch

attachment0 (203 bytes) Download Attachment
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH v3 0/2] use text properties rather than overlays

In reply to this post by David Edmondson
v3:
- Undo mistaken minor edit - no functional change.

David Edmondson (2):
  emacs: Use text properties rather than overlays in
    `notmuch-show-mode'.
  test: Update test to match previous patch.

 emacs/notmuch-show.el                              |   62 +++++++++++++-------
 emacs/notmuch-wash.el                              |    8 ++-
 ...hread-maildir-storage-with-fourfold-indentation |    8 +-
 3 files changed, 50 insertions(+), 28 deletions(-)

--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.

Except for where invisibility is involved, replace the use of overlays
in `notmuch-show-mode' with text properties, which are more efficient
and can be merged together more effectively.
---
 emacs/notmuch-show.el |   62 +++++++++++++++++++++++++++++++-----------------
 emacs/notmuch-wash.el |    8 ++++-
 2 files changed, 46 insertions(+), 24 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7469e2e..bc1e7db 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -264,10 +264,10 @@ operation on the contents of the current buffer."
        (t
  'message-header-other))))
 
-    (overlay-put (make-overlay (point) (re-search-forward ":"))
- 'face 'message-header-name)
-    (overlay-put (make-overlay (point) (re-search-forward ".*$"))
- 'face face)))
+    (put-text-property (point) (re-search-forward ":")
+       'face 'message-header-name)
+    (put-text-property (point) (re-search-forward ".*$")
+       'face face)))
 
 (defun notmuch-show-colour-headers ()
   "Apply some colouring to the current headers."
@@ -284,12 +284,11 @@ operation on the contents of the current buffer."
   "Update the displayed tags of the current message."
   (save-excursion
     (goto-char (notmuch-show-message-top))
-    (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
- (let ((inhibit-read-only t))
-  (replace-match (concat "("
- (propertize (mapconcat 'identity tags " ")
-     'face 'notmuch-tag-face)
- ")"))))))
+    (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
+      (let ((inhibit-read-only t))
+ (replace-match (propertize (mapconcat 'identity tags " ")
+   'face '(notmuch-tag-face notmuch-message-summary-face))
+       nil nil nil 1)))))
 
 (defun notmuch-show-clean-address (address)
   "Try to clean a single email ADDRESS for display.  Return
@@ -352,15 +351,26 @@ unchanged ADDRESS if parsing fails."
   "Insert a notmuch style headerline based on HEADERS for a
 message at DEPTH in the current thread."
   (let ((start (point)))
-    (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))
-    (notmuch-show-clean-address (plist-get headers :From))
-    " ("
-    date
-    ") ("
-    (propertize (mapconcat 'identity tags " ")
- 'face 'notmuch-tag-face)
-    ")\n")
-    (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
+    (insert
+     (propertize (concat (notmuch-show-clean-address (plist-get headers :From))
+ " ("
+ date
+ ") (")
+ 'face 'notmuch-message-summary-face)
+     (propertize (mapconcat 'identity tags " ")
+ 'face '(notmuch-tag-face notmuch-message-summary-face))
+     (propertize ")\n"
+ 'face 'notmuch-message-summary-face))
+
+    ;; Ensure that any insertions at the start of this line (usually
+    ;; just spaces for indentation purposes) inherit the face of the
+    ;; rest of the line...
+    (put-text-property start (1+ start)
+       'front-sticky '(face))
+    ;; ...and that insertions at the end of this region do _not_
+    ;; inherit the face of the rest of this line.
+    (put-text-property (1- (point)) (point)
+       'rear-nonsticky '(face))))
 
 (defun notmuch-show-insert-header (header header-value)
   "Insert a single header."
@@ -796,8 +806,15 @@ current buffer, if possible."
 (defun notmuch-show-insert-bodypart (msg part depth)
   "Insert the body part PART at depth DEPTH in the current thread."
   (let ((content-type (downcase (plist-get part :content-type)))
- (nth (plist-get part :id)))
-    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
+ (nth (plist-get part :id))
+ (start (point)))
+    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)
+
+    ;; Ensure that face properties applied to text in the buffer by
+    ;; the part handler don't leak into the following text.
+    (put-text-property start (point-max)
+       'rear-nonsticky '(face)))
+
   ;; Some of the body part handlers leave point somewhere up in the
   ;; part, so we make sure that we're down at the end.
   (goto-char (point-max))
@@ -889,7 +906,8 @@ current buffer, if possible."
     (setq content-end (point-marker))
 
     ;; Indent according to the depth in the thread.
-    (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth))
+    (indent-rigidly message-start message-end
+        (* notmuch-show-indent-messages-width depth))
 
     (setq message-end (point-max-marker))
 
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 56981d0..29a9d45 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -187,7 +187,9 @@ that PREFIX should not include a newline."
     (let* ((cite-start (match-beginning 0))
    (cite-end (match-end 0))
    (cite-lines (count-lines cite-start cite-end)))
-      (overlay-put (make-overlay cite-start cite-end) 'face 'message-cited-text)
+      (put-text-property cite-start cite-end 'face 'message-cited-text)
+      ;; Ensure that the next line doesn't inherit our face.
+      (put-text-property (1- cite-end) cite-end 'rear-nonsticky '(face))
       (when (> cite-lines (+ notmuch-wash-citation-lines-prefix
      notmuch-wash-citation-lines-suffix
      1))
@@ -209,7 +211,9 @@ that PREFIX should not include a newline."
   (sig-end-marker (make-marker)))
       (set-marker sig-start-marker sig-start)
       (set-marker sig-end-marker (point-max))
-      (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text)
+      (put-text-property sig-start-marker sig-end-marker 'face 'message-cited-text)
+      ;; Ensure that the next line doesn't inherit our face.
+      (put-text-property (1- sig-end-marker) sig-end-marker 'rear-nonsticky '(face))
       (notmuch-wash-region-to-button
        msg sig-start-marker sig-end-marker
        "signature"))))))
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
David Edmondson David Edmondson
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[PATCH v3 2/2] test: Update test to match previous patch.

In reply to this post by David Edmondson
Indentation now uses tabs where possible.
---
 ...hread-maildir-storage-with-fourfold-indentation |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
index b0bf93e..1f7801e 100644
--- a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
+++ b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
@@ -69,7 +69,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
     notmuch mailing list
     [hidden email]
     http://notmuchmail.org/mailman/listinfo/notmuch
-        Lars Kellogg-Stedman <[hidden email]> (2009-11-17) (inbox signed unread)
+ Lars Kellogg-Stedman <[hidden email]> (2009-11-17) (inbox signed unread)
  Subject: Re: [notmuch] Working with Maildir storage?
  To: Mikhail Gusarov <[hidden email]>
  Cc: [hidden email]
@@ -101,7 +101,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
  notmuch mailing list
  [hidden email]
  http://notmuchmail.org/mailman/listinfo/notmuch
-            Mikhail Gusarov <[hidden email]> (2009-11-17) (inbox unread)
+    Mikhail Gusarov <[hidden email]> (2009-11-17) (inbox unread)
     Subject: [notmuch] Working with Maildir storage?
     To: [hidden email]
     Date: Wed, 18 Nov 2009 02:50:48 +0600
@@ -129,7 +129,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
     Desc: not available
     URL:
     <http://notmuchmail.org/pipermail/notmuch/attachments/20091118/0e33d964/attachment.pgp>
-            Keith Packard <[hidden email]> (2009-11-17) (inbox unread)
+    Keith Packard <[hidden email]> (2009-11-17) (inbox unread)
     Subject: [notmuch] Working with Maildir storage?
     To: [hidden email]
     Date: Tue, 17 Nov 2009 13:24:13 -0800
@@ -151,7 +151,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
     Thanks to everyone for trying out notmuch!
 
     -keith
-                Lars Kellogg-Stedman <[hidden email]> (2009-11-18) (inbox signed unread)
+ Lars Kellogg-Stedman <[hidden email]> (2009-11-18) (inbox signed unread)
  Subject: Re: [notmuch] Working with Maildir storage?
  To: Keith Packard <[hidden email]>
  Cc: [hidden email]
--
1.7.8.3

_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Mark Walters Mark Walters
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.

In reply to this post by David Edmondson

Hi

I looked at this and think its ok except for one trivial (but
significant) rebase error.

Best wishes

Mark

On Tue,  7 Feb 2012 08:46:16 +0000, David Edmondson <[hidden email]> wrote:

> Except for where invisibility is involved, replace the use of overlays
> in `notmuch-show-mode' with text properties, which are more efficient
> and can be merged together more effectively.
> ---
>  emacs/notmuch-show.el |   62 +++++++++++++++++++++++++++++++-----------------
>  emacs/notmuch-wash.el |    8 ++++-
>  2 files changed, 46 insertions(+), 24 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 7469e2e..bc1e7db 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -264,10 +264,10 @@ operation on the contents of the current buffer."
>         (t
>   'message-header-other))))
>  
> -    (overlay-put (make-overlay (point) (re-search-forward ":"))
> - 'face 'message-header-name)
> -    (overlay-put (make-overlay (point) (re-search-forward ".*$"))
> - 'face face)))
> +    (put-text-property (point) (re-search-forward ":")
> +       'face 'message-header-name)
> +    (put-text-property (point) (re-search-forward ".*$")
> +       'face face)))
>  
>  (defun notmuch-show-colour-headers ()
>    "Apply some colouring to the current headers."
> @@ -284,12 +284,11 @@ operation on the contents of the current buffer."
>    "Update the displayed tags of the current message."
>    (save-excursion
>      (goto-char (notmuch-show-message-top))
> -    (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
> - (let ((inhibit-read-only t))
> -  (replace-match (concat "("
> - (propertize (mapconcat 'identity tags " ")
> -     'face 'notmuch-tag-face)
> - ")"))))))
> +    (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
> +      (let ((inhibit-read-only t))
> + (replace-match (propertize (mapconcat 'identity tags " ")
> +   'face '(notmuch-tag-face notmuch-message-summary-face))
> +       nil nil nil 1)))))
>  
>  (defun notmuch-show-clean-address (address)
>    "Try to clean a single email ADDRESS for display.  Return
> @@ -352,15 +351,26 @@ unchanged ADDRESS if parsing fails."
>    "Insert a notmuch style headerline based on HEADERS for a
>  message at DEPTH in the current thread."
>    (let ((start (point)))
> -    (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))
> -    (notmuch-show-clean-address (plist-get headers :From))
> -    " ("
> -    date
> -    ") ("
> -    (propertize (mapconcat 'identity tags " ")
> - 'face 'notmuch-tag-face)
> -    ")\n")
> -    (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
> +    (insert
> +     (propertize (concat (notmuch-show-clean-address (plist-get headers :From))
> + " ("
> + date
> + ") (")
> + 'face 'notmuch-message-summary-face)
> +     (propertize (mapconcat 'identity tags " ")
> + 'face '(notmuch-tag-face notmuch-message-summary-face))
> +     (propertize ")\n"
> + 'face 'notmuch-message-summary-face))
> +
> +    ;; Ensure that any insertions at the start of this line (usually
> +    ;; just spaces for indentation purposes) inherit the face of the
> +    ;; rest of the line...
> +    (put-text-property start (1+ start)
> +       'front-sticky '(face))
> +    ;; ...and that insertions at the end of this region do _not_
> +    ;; inherit the face of the rest of this line.
> +    (put-text-property (1- (point)) (point)
> +       'rear-nonsticky '(face))))
>  
>  (defun notmuch-show-insert-header (header header-value)
>    "Insert a single header."
> @@ -796,8 +806,15 @@ current buffer, if possible."
>  (defun notmuch-show-insert-bodypart (msg part depth)
>    "Insert the body part PART at depth DEPTH in the current thread."
>    (let ((content-type (downcase (plist-get part :content-type)))
> - (nth (plist-get part :id)))
> -    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
> + (nth (plist-get part :id))
> + (start (point)))
> +    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)
> +
> +    ;; Ensure that face properties applied to text in the buffer by
> +    ;; the part handler don't leak into the following text.
> +    (put-text-property start (point-max)
> +       'rear-nonsticky '(face)))
> +
>    ;; Some of the body part handlers leave point somewhere up in the
>    ;; part, so we make sure that we're down at the end.
>    (goto-char (point-max))
> @@ -889,7 +906,8 @@ current buffer, if possible."
>      (setq content-end (point-marker))
>  
>      ;; Indent according to the depth in the thread.
> -    (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth))
> +    (indent-rigidly message-start message-end
> +        (* notmuch-show-indent-messages-width depth))
>  
>      (setq message-end (point-max-marker))

I think the setq has to come before the indent-rigidly. (Also I think
there is a whitespace error in the second line of the indent-rigidly.)

>  
> diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
> index 56981d0..29a9d45 100644
> --- a/emacs/notmuch-wash.el
> +++ b/emacs/notmuch-wash.el
> @@ -187,7 +187,9 @@ that PREFIX should not include a newline."
>      (let* ((cite-start (match-beginning 0))
>     (cite-end (match-end 0))
>     (cite-lines (count-lines cite-start cite-end)))
> -      (overlay-put (make-overlay cite-start cite-end) 'face 'message-cited-text)
> +      (put-text-property cite-start cite-end 'face 'message-cited-text)
> +      ;; Ensure that the next line doesn't inherit our face.
> +      (put-text-property (1- cite-end) cite-end 'rear-nonsticky '(face))
>        (when (> cite-lines (+ notmuch-wash-citation-lines-prefix
>       notmuch-wash-citation-lines-suffix
>       1))
> @@ -209,7 +211,9 @@ that PREFIX should not include a newline."
>    (sig-end-marker (make-marker)))
>        (set-marker sig-start-marker sig-start)
>        (set-marker sig-end-marker (point-max))
> -      (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text)
> +      (put-text-property sig-start-marker sig-end-marker 'face 'message-cited-text)
> +      ;; Ensure that the next line doesn't inherit our face.
> +      (put-text-property (1- sig-end-marker) sig-end-marker 'rear-nonsticky '(face))
>        (notmuch-wash-region-to-button
>         msg sig-start-marker sig-end-marker
>         "signature"))))))
> --
> 1.7.8.3
>
> _______________________________________________
> notmuch mailing list
> [hidden email]
> http://notmuchmail.org/mailman/listinfo/notmuch
_______________________________________________
notmuch mailing list
[hidden email]
http://notmuchmail.org/mailman/listinfo/notmuch
Loading...