unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.
Date: Wed,  8 Feb 2012 08:02:11 +0000	[thread overview]
Message-ID: <1328688139-3865-3-git-send-email-dme@dme.org> (raw)
In-Reply-To: <1328688139-3865-1-git-send-email-dme@dme.org>

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

  parent reply	other threads:[~2012-02-08  8:02 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-25 10:18 [PATCH 0/3] reworked crypto toggle, plus a couple of other toggles David Edmondson
2012-01-25 10:18 ` [PATCH 1/3] emacs: Rework crypto switch toggle David Edmondson
2012-01-25 10:18 ` [PATCH 2/3] emacs: Allow `notmuch-show-mode' to display only matching messages David Edmondson
2012-01-25 10:18 ` [PATCH 3/3] emacs: Allow the indentation of content to be toggled David Edmondson
2012-01-29 22:30   ` Mark Walters
2012-01-30  9:29     ` David Edmondson
2012-01-30 16:32     ` David Edmondson
2012-01-29 20:06 ` [PATCH 0/3] reworked crypto toggle, plus a couple of other toggles Jameson Graef Rollins
2012-01-30  9:37   ` David Edmondson
2012-01-30 11:26     ` David Edmondson
2012-01-30 17:44       ` Jameson Graef Rollins
2012-01-30 11:31 ` [PATCH 0/3 v2] " David Edmondson
2012-01-30 11:31   ` [PATCH 1/3 v2] emacs: Rework crypto switch toggle David Edmondson
2012-01-30 11:31   ` [PATCH 2/3 v2] emacs: Allow `notmuch-show-mode' to display only matching messages David Edmondson
2012-01-30 11:31   ` [PATCH 3/3 v2] emacs: Allow the indentation of content to be toggled David Edmondson
2012-01-30 16:30 ` [PATCH 0/5 v3] reworked crypto toggle, plus a few other toggles David Edmondson
2012-01-30 16:31   ` [PATCH 1/5] emacs: Rework crypto switch toggle David Edmondson
2012-01-30 16:31   ` [PATCH 2/5] emacs: Allow `notmuch-show-mode' to display only matching messages David Edmondson
2012-01-30 16:31   ` [PATCH 3/5] emacs: Allow the indentation of content to be toggled David Edmondson
2012-01-30 16:31   ` [PATCH 4/5] emacs: Add a binding (>) to toggle the truncation of long lines David Edmondson
2012-01-30 17:33     ` Jani Nikula
2012-01-30 17:45       ` David Edmondson
2012-01-30 16:31   ` [PATCH 5/5] emacs: Retain the state of the buffer during `notmuch-show-refresh-view' David Edmondson
2012-01-30 20:19     ` Mark Walters
2012-01-31  6:17       ` David Edmondson
2012-01-30 17:03   ` [PATCH 0/5 v3] reworked crypto toggle, plus a few other toggles Tomi Ollila
2012-01-30 17:47   ` Jameson Graef Rollins
2012-01-31  8:09     ` David Edmondson
2012-01-31 16:31       ` Jameson Graef Rollins
2012-01-31 17:01         ` David Edmondson
2012-02-01 14:39 ` [PATCH v5 0/6] " David Edmondson
2012-02-01 14:39   ` [PATCH v5 1/6] emacs: Rework crypto switch toggle David Edmondson
2012-02-01 14:39   ` [PATCH v5 2/6] emacs: Allow `notmuch-show-mode' to display only matching messages David Edmondson
2012-02-01 14:39   ` [PATCH v5 3/6] emacs: Allow the indentation of content to be toggled David Edmondson
2012-02-01 14:39   ` [PATCH v5 4/6] emacs: Add a binding (t) to toggle the truncation of long lines David Edmondson
2012-02-01 14:39   ` [PATCH v5 5/6] emacs: Optionally retain the state of the buffer during `notmuch-show-refresh-view' David Edmondson
2012-02-01 14:39   ` [PATCH v5 6/6] emacs: Check that the parent buffer is alive before using it David Edmondson
2012-02-02 11:23 ` [PATCH v6 0/8] reworked crypto toggle, plus a few other toggles David Edmondson
2012-02-02 11:23   ` [PATCH v6 1/8] emacs: Rework crypto switch toggle David Edmondson
2012-02-03 10:47     ` David Edmondson
2012-02-02 11:23   ` [PATCH v6 2/8] emacs: Allow `notmuch-show-mode' to display only matching messages David Edmondson
2012-02-02 11:23   ` [PATCH v6 3/8] emacs: Allow the indentation of content to be toggled David Edmondson
2012-02-02 11:23   ` [PATCH v6 4/8] emacs: Add a binding (t) to toggle the truncation of long lines David Edmondson
2012-02-02 11:23   ` [PATCH v6 5/8] emacs: Optionally retain the state of the buffer during `notmuch-show-refresh-view' David Edmondson
2012-02-02 11:23   ` [PATCH v6 6/8] emacs: Check that the parent buffer is alive before using it David Edmondson
2012-02-02 11:23   ` [PATCH v6 7/8] emacs: Add `notmuch-show-only-matching-messages' David Edmondson
2012-02-02 11:23   ` [PATCH v6 8/8] emacs: A prefix argument to `notmuch-show' should invert the matching message behaviour David Edmondson
2012-02-06  9:21 ` [PATCH v7 0/8] reworked crypto toggle, plus a few other toggles David Edmondson
2012-02-06  9:21   ` [PATCH v7 1/8] emacs: Rework crypto switch toggle David Edmondson
2012-02-08  5:10     ` Austin Clements
2012-02-08  6:21       ` David Edmondson
2012-02-06  9:21   ` [PATCH v7 2/8] emacs: Allow `notmuch-show-mode' to display only matching messages David Edmondson
2012-02-06  9:21   ` [PATCH v7 3/8] emacs: Allow the indentation of content to be toggled David Edmondson
2012-02-06  9:21   ` [PATCH v7 4/8] emacs: Add a binding (t) to toggle the truncation of long lines David Edmondson
2012-02-06  9:21   ` [PATCH v7 5/8] emacs: Optionally retain the state of the buffer during `notmuch-show-refresh-view' David Edmondson
2012-02-06  9:21   ` [PATCH v7 6/8] emacs: Check that the parent buffer is alive before using it David Edmondson
2012-02-06  9:21   ` [PATCH v7 7/8] emacs: Add `notmuch-show-only-matching-messages' David Edmondson
2012-02-06  9:21   ` [PATCH v7 8/8] emacs: A prefix argument to `notmuch-show' should invert the matching message behaviour David Edmondson
2012-02-06 11:32   ` [PATCH v7 0/8] reworked crypto toggle, plus a few other toggles Tomi Ollila
2012-02-08  8:02 ` [PATCH v8 " David Edmondson
2012-02-08  8:02   ` [PATCH v8 1/8] emacs: Rework crypto switch toggle David Edmondson
2012-02-08 14:38     ` Austin Clements
2012-02-08  8:02   ` David Edmondson [this message]
2012-02-12 15:47     ` [PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode' David Bremner
2012-02-08  8:02   ` [PATCH v8 2/8] emacs: Allow `notmuch-show-mode' to display only matching messages David Edmondson
2012-02-08  8:02   ` [PATCH v3 2/2] test: Update test to match previous patch David Edmondson
2012-10-12 20:51     ` Ethan Glasser-Camp
2012-10-14 23:17       ` Jameson Graef Rollins
2012-02-08  8:02   ` [PATCH v8 3/8] emacs: Allow the indentation of content to be toggled David Edmondson
2012-02-08  8:02   ` [PATCH v8 4/8] emacs: Add a binding (t) to toggle the truncation of long lines David Edmondson
2012-02-08  8:02   ` [PATCH v8 5/8] emacs: Optionally retain the state of the buffer during `notmuch-show-refresh-view' David Edmondson
2012-02-08  8:02   ` [PATCH v8 6/8] emacs: Check that the parent buffer is alive before using it David Edmondson
2012-02-08  8:02   ` [PATCH v8 7/8] emacs: Add `notmuch-show-only-matching-messages' David Edmondson
2012-02-08  8:02   ` [PATCH v8 8/8] emacs: A prefix argument to `notmuch-show' should invert the matching message behaviour David Edmondson
2012-02-08 19:15   ` [PATCH v8 0/8] reworked crypto toggle, plus a few other toggles David Edmondson
2012-02-12 17:36   ` David Bremner
2012-02-19 20:56   ` Pieter Praet
2012-02-19 20:56     ` [PATCH 1/3] test: emacs: toggle processing of cryptographic MIME parts in `notmuch-show' Pieter Praet
2012-10-17 23:59       ` [PATCH 1/3] test: emacs: toggle eliding of non-matching messages " Ethan Glasser-Camp
2012-10-18  2:16         ` [PATCH] test: Move tests from emacs to emacs-show Ethan Glasser-Camp
2012-10-18 10:19           ` Tomi Ollila
2012-10-18 12:02           ` David Bremner
2012-02-19 20:56     ` [PATCH 2/3] test: emacs: toggle eliding of non-matching messages in `notmuch-show' Pieter Praet
2012-04-17 17:45       ` Mark Walters
2012-02-19 20:56     ` [PATCH 3/3] test: emacs: toggle thread content indentation " Pieter Praet
2012-10-15 22:17     ` [PATCH v8 0/8] reworked crypto toggle, plus a few other toggles Ethan Glasser-Camp
2012-10-18  0:41       ` David Bremner
  -- strict thread matches above, loose matches on Subject: below --
2012-01-24 11:36 use text properties rather than overlays David Edmondson
2012-02-07  8:46 ` [PATCH v3 0/2] " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1328688139-3865-3-git-send-email-dme@dme.org \
    --to=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).