unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* use text properties rather than overlays
@ 2012-01-24 11:36 David Edmondson
  2012-01-24 11:36 ` [PATCH 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: David Edmondson @ 2012-01-24 11:36 UTC (permalink / raw)
  To: notmuch

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.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.
  2012-01-24 11:36 use text properties rather than overlays David Edmondson
@ 2012-01-24 11:36 ` David Edmondson
  2012-01-24 16:15   ` Austin Clements
  2012-01-24 11:36 ` [PATCH 2/2] test: Update test to match previous patch David Edmondson
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: David Edmondson @ 2012-01-24 11:36 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/2] test: Update test to match previous patch.
  2012-01-24 11:36 use text properties rather than overlays David Edmondson
  2012-01-24 11:36 ` [PATCH 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
@ 2012-01-24 11:36 ` David Edmondson
  2012-02-06 16:08 ` [PATCH v2 0/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
  2012-02-07  8:46 ` [PATCH v3 0/2] use text properties rather than overlays David Edmondson
  3 siblings, 0 replies; 13+ messages in thread
From: David Edmondson @ 2012-01-24 11:36 UTC (permalink / raw)
  To: notmuch

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
     notmuch@notmuchmail.org
     http://notmuchmail.org/mailman/listinfo/notmuch
-        Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-17) (inbox signed unread)
+	Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-17) (inbox signed unread)
 	Subject: Re: [notmuch] Working with Maildir storage?
 	To: Mikhail Gusarov <dottedmag@dottedmag.net>
 	Cc: notmuch@notmuchmail.org
@@ -101,7 +101,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
 	notmuch mailing list
 	notmuch@notmuchmail.org
 	http://notmuchmail.org/mailman/listinfo/notmuch
-            Mikhail Gusarov <dottedmag@dottedmag.net> (2009-11-17) (inbox unread)
+	    Mikhail Gusarov <dottedmag@dottedmag.net> (2009-11-17) (inbox unread)
 	    Subject: [notmuch] Working with Maildir storage?
 	    To: notmuch@notmuchmail.org
 	    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 <keithp@keithp.com> (2009-11-17) (inbox unread)
+	    Keith Packard <keithp@keithp.com> (2009-11-17) (inbox unread)
 	    Subject: [notmuch] Working with Maildir storage?
 	    To: notmuch@notmuchmail.org
 	    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 <lars@seas.harvard.edu> (2009-11-18) (inbox signed unread)
+		Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (inbox signed unread)
 		Subject: Re: [notmuch] Working with Maildir storage?
 		To: Keith Packard <keithp@keithp.com>
 		Cc: notmuch@notmuchmail.org
-- 
1.7.8.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.
  2012-01-24 11:36 ` [PATCH 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
@ 2012-01-24 16:15   ` Austin Clements
  2012-01-24 16:46     ` David Edmondson
  0 siblings, 1 reply; 13+ messages in thread
From: Austin Clements @ 2012-01-24 16:15 UTC (permalink / raw)
  To: David Edmondson; +Cc: notmuch

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"))))))

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.
  2012-01-24 16:15   ` Austin Clements
@ 2012-01-24 16:46     ` David Edmondson
  0 siblings, 0 replies; 13+ messages in thread
From: David Edmondson @ 2012-01-24 16:46 UTC (permalink / raw)
  To: Austin Clements; +Cc: notmuch

[-- Attachment #1: Type: text/plain, Size: 8117 bytes --]

On Tue, 24 Jan 2012 11:15:11 -0500, Austin Clements <amdragon@MIT.EDU> 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"))))))

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 0/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.
  2012-01-24 11:36 use text properties rather than overlays David Edmondson
  2012-01-24 11:36 ` [PATCH 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
  2012-01-24 11:36 ` [PATCH 2/2] test: Update test to match previous patch David Edmondson
@ 2012-02-06 16:08 ` David Edmondson
  2012-02-06 16:08   ` [PATCH v2 1/2] " David Edmondson
  2012-02-06 16:08   ` [PATCH v2 2/2] test: Update test to match previous patch David Edmondson
  2012-02-07  8:46 ` [PATCH v3 0/2] use text properties rather than overlays David Edmondson
  3 siblings, 2 replies; 13+ messages in thread
From: David Edmondson @ 2012-02-06 16:08 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.
  2012-02-06 16:08 ` [PATCH v2 0/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
@ 2012-02-06 16:08   ` David Edmondson
  2012-02-06 16:13     ` David Edmondson
  2012-02-06 16:08   ` [PATCH v2 2/2] test: Update test to match previous patch David Edmondson
  1 sibling, 1 reply; 13+ messages in thread
From: David Edmondson @ 2012-02-06 16:08 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 2/2] test: Update test to match previous patch.
  2012-02-06 16:08 ` [PATCH v2 0/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
  2012-02-06 16:08   ` [PATCH v2 1/2] " David Edmondson
@ 2012-02-06 16:08   ` David Edmondson
  1 sibling, 0 replies; 13+ messages in thread
From: David Edmondson @ 2012-02-06 16:08 UTC (permalink / raw)
  To: notmuch

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
     notmuch@notmuchmail.org
     http://notmuchmail.org/mailman/listinfo/notmuch
-        Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-17) (inbox signed unread)
+	Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-17) (inbox signed unread)
 	Subject: Re: [notmuch] Working with Maildir storage?
 	To: Mikhail Gusarov <dottedmag@dottedmag.net>
 	Cc: notmuch@notmuchmail.org
@@ -101,7 +101,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
 	notmuch mailing list
 	notmuch@notmuchmail.org
 	http://notmuchmail.org/mailman/listinfo/notmuch
-            Mikhail Gusarov <dottedmag@dottedmag.net> (2009-11-17) (inbox unread)
+	    Mikhail Gusarov <dottedmag@dottedmag.net> (2009-11-17) (inbox unread)
 	    Subject: [notmuch] Working with Maildir storage?
 	    To: notmuch@notmuchmail.org
 	    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 <keithp@keithp.com> (2009-11-17) (inbox unread)
+	    Keith Packard <keithp@keithp.com> (2009-11-17) (inbox unread)
 	    Subject: [notmuch] Working with Maildir storage?
 	    To: notmuch@notmuchmail.org
 	    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 <lars@seas.harvard.edu> (2009-11-18) (inbox signed unread)
+		Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (inbox signed unread)
 		Subject: Re: [notmuch] Working with Maildir storage?
 		To: Keith Packard <keithp@keithp.com>
 		Cc: notmuch@notmuchmail.org
-- 
1.7.8.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.
  2012-02-06 16:08   ` [PATCH v2 1/2] " David Edmondson
@ 2012-02-06 16:13     ` David Edmondson
  0 siblings, 0 replies; 13+ messages in thread
From: David Edmondson @ 2012-02-06 16:13 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]

On Mon,  6 Feb 2012 16:08:21 +0000, David Edmondson <dme@dme.org> 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:"20120124161511.GC16740@mit.edu"), but
suggested that someone else should look it over. Any volunteers?

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v3 0/2] use text properties rather than overlays
  2012-01-24 11:36 use text properties rather than overlays David Edmondson
                   ` (2 preceding siblings ...)
  2012-02-06 16:08 ` [PATCH v2 0/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
@ 2012-02-07  8:46 ` David Edmondson
  2012-02-07  8:46   ` [PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
  2012-02-07  8:46   ` [PATCH v3 2/2] test: Update test to match previous patch David Edmondson
  3 siblings, 2 replies; 13+ messages in thread
From: David Edmondson @ 2012-02-07  8:46 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.
  2012-02-07  8:46 ` [PATCH v3 0/2] use text properties rather than overlays David Edmondson
@ 2012-02-07  8:46   ` David Edmondson
  2012-02-11 22:26     ` Mark Walters
  2012-02-07  8:46   ` [PATCH v3 2/2] test: Update test to match previous patch David Edmondson
  1 sibling, 1 reply; 13+ messages in thread
From: David Edmondson @ 2012-02-07  8:46 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 2/2] test: Update test to match previous patch.
  2012-02-07  8:46 ` [PATCH v3 0/2] use text properties rather than overlays David Edmondson
  2012-02-07  8:46   ` [PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
@ 2012-02-07  8:46   ` David Edmondson
  1 sibling, 0 replies; 13+ messages in thread
From: David Edmondson @ 2012-02-07  8:46 UTC (permalink / raw)
  To: notmuch

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
     notmuch@notmuchmail.org
     http://notmuchmail.org/mailman/listinfo/notmuch
-        Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-17) (inbox signed unread)
+	Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-17) (inbox signed unread)
 	Subject: Re: [notmuch] Working with Maildir storage?
 	To: Mikhail Gusarov <dottedmag@dottedmag.net>
 	Cc: notmuch@notmuchmail.org
@@ -101,7 +101,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
 	notmuch mailing list
 	notmuch@notmuchmail.org
 	http://notmuchmail.org/mailman/listinfo/notmuch
-            Mikhail Gusarov <dottedmag@dottedmag.net> (2009-11-17) (inbox unread)
+	    Mikhail Gusarov <dottedmag@dottedmag.net> (2009-11-17) (inbox unread)
 	    Subject: [notmuch] Working with Maildir storage?
 	    To: notmuch@notmuchmail.org
 	    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 <keithp@keithp.com> (2009-11-17) (inbox unread)
+	    Keith Packard <keithp@keithp.com> (2009-11-17) (inbox unread)
 	    Subject: [notmuch] Working with Maildir storage?
 	    To: notmuch@notmuchmail.org
 	    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 <lars@seas.harvard.edu> (2009-11-18) (inbox signed unread)
+		Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-18) (inbox signed unread)
 		Subject: Re: [notmuch] Working with Maildir storage?
 		To: Keith Packard <keithp@keithp.com>
 		Cc: notmuch@notmuchmail.org
-- 
1.7.8.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.
  2012-02-07  8:46   ` [PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
@ 2012-02-11 22:26     ` Mark Walters
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Walters @ 2012-02-11 22:26 UTC (permalink / raw)
  To: David Edmondson, notmuch


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 <dme@dme.org> 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
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-02-11 22:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-24 11:36 use text properties rather than overlays David Edmondson
2012-01-24 11:36 ` [PATCH 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
2012-01-24 16:15   ` Austin Clements
2012-01-24 16:46     ` David Edmondson
2012-01-24 11:36 ` [PATCH 2/2] test: Update test to match previous patch David Edmondson
2012-02-06 16:08 ` [PATCH v2 0/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
2012-02-06 16:08   ` [PATCH v2 1/2] " David Edmondson
2012-02-06 16:13     ` David Edmondson
2012-02-06 16:08   ` [PATCH v2 2/2] test: Update test to match previous patch David Edmondson
2012-02-07  8:46 ` [PATCH v3 0/2] use text properties rather than overlays David Edmondson
2012-02-07  8:46   ` [PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Edmondson
2012-02-11 22:26     ` Mark Walters
2012-02-07  8:46   ` [PATCH v3 2/2] test: Update test to match previous patch David Edmondson

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).