--- /dev/null
+Return-Path: <dme@dme.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id EE28D431FBC\r
+ for <notmuch@notmuchmail.org>; Mon, 6 Feb 2012 08:08:28 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id RN+KvhBwUuYb for <notmuch@notmuchmail.org>;\r
+ Mon, 6 Feb 2012 08:08:28 -0800 (PST)\r
+Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
+ [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 0141F431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 6 Feb 2012 08:08:27 -0800 (PST)\r
+Received: by wibhi8 with SMTP id hi8so4952689wib.26\r
+ for <notmuch@notmuchmail.org>; Mon, 06 Feb 2012 08:08:26 -0800 (PST)\r
+MIME-Version: 1.0\r
+Received: by 10.180.83.70 with SMTP id o6mr2795260wiy.19.1328544506822;\r
+ Mon, 06 Feb 2012 08:08:26 -0800 (PST)\r
+Received: from hotblack-desiato.hh.sledj.net\r
+ (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
+ by mx.google.com with ESMTPS id n5sm47676065wiw.7.2012.02.06.08.08.24\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Mon, 06 Feb 2012 08:08:25 -0800 (PST)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+ id 413FBA05C6; Mon, 6 Feb 2012 16:08:23 +0000 (GMT)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 1/2] emacs: Use text properties rather than overlays in\r
+ `notmuch-show-mode'.\r
+Date: Mon, 6 Feb 2012 16:08:21 +0000\r
+Message-Id: <1328544502-22615-2-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.8.3\r
+In-Reply-To: <1328544502-22615-1-git-send-email-dme@dme.org>\r
+References: <1327405007-4026-1-git-send-email-dme@dme.org>\r
+ <1328544502-22615-1-git-send-email-dme@dme.org>\r
+X-Gm-Message-State:\r
+ ALoCoQkaOeb6HA0t5q1lObu7uTR0xN7SRoC6m9ICUjjV/jfE3OdmGPY1kRbtZ6LSu0Fdf7BHOO7A\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 06 Feb 2012 16:08:29 -0000\r
+\r
+Except for where invisibility is involved, replace the use of overlays\r
+in `notmuch-show-mode' with text properties, which are more efficient\r
+and can be merged together more effectively.\r
+---\r
+ emacs/notmuch-show.el | 66 +++++++++++++++++++++++++++++++-----------------\r
+ emacs/notmuch-wash.el | 8 ++++-\r
+ 2 files changed, 48 insertions(+), 26 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 7469e2e..13d2e81 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -264,10 +264,10 @@ operation on the contents of the current buffer."\r
+ (t\r
+ 'message-header-other))))\r
+ \r
+- (overlay-put (make-overlay (point) (re-search-forward ":"))\r
+- 'face 'message-header-name)\r
+- (overlay-put (make-overlay (point) (re-search-forward ".*$"))\r
+- 'face face)))\r
++ (put-text-property (point) (re-search-forward ":")\r
++ 'face 'message-header-name)\r
++ (put-text-property (point) (re-search-forward ".*$")\r
++ 'face face)))\r
+ \r
+ (defun notmuch-show-colour-headers ()\r
+ "Apply some colouring to the current headers."\r
+@@ -284,12 +284,11 @@ operation on the contents of the current buffer."\r
+ "Update the displayed tags of the current message."\r
+ (save-excursion\r
+ (goto-char (notmuch-show-message-top))\r
+- (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)\r
+- (let ((inhibit-read-only t))\r
+- (replace-match (concat "("\r
+- (propertize (mapconcat 'identity tags " ")\r
+- 'face 'notmuch-tag-face)\r
+- ")"))))))\r
++ (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)\r
++ (let ((inhibit-read-only t))\r
++ (replace-match (propertize (mapconcat 'identity tags " ")\r
++ 'face '(notmuch-tag-face notmuch-message-summary-face))\r
++ nil nil nil 1)))))\r
+ \r
+ (defun notmuch-show-clean-address (address)\r
+ "Try to clean a single email ADDRESS for display. Return\r
+@@ -352,15 +351,26 @@ unchanged ADDRESS if parsing fails."\r
+ "Insert a notmuch style headerline based on HEADERS for a\r
+ message at DEPTH in the current thread."\r
+ (let ((start (point)))\r
+- (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth))\r
+- (notmuch-show-clean-address (plist-get headers :From))\r
+- " ("\r
+- date\r
+- ") ("\r
+- (propertize (mapconcat 'identity tags " ")\r
+- 'face 'notmuch-tag-face)\r
+- ")\n")\r
+- (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))\r
++ (insert\r
++ (propertize (concat (notmuch-show-clean-address (plist-get headers :From))\r
++ " ("\r
++ date\r
++ ") (")\r
++ 'face 'notmuch-message-summary-face)\r
++ (propertize (mapconcat 'identity tags " ")\r
++ 'face '(notmuch-tag-face notmuch-message-summary-face))\r
++ (propertize ")\n"\r
++ 'face 'notmuch-message-summary-face))\r
++\r
++ ;; Ensure that any insertions at the start of this line (usually\r
++ ;; just spaces for indentation purposes) inherit the face of the\r
++ ;; rest of the line...\r
++ (put-text-property start (1+ start)\r
++ 'front-sticky '(face))\r
++ ;; ...and that insertions at the end of this region do _not_\r
++ ;; inherit the face of the rest of this line.\r
++ (put-text-property (1- (point)) (point)\r
++ 'rear-nonsticky '(face))))\r
+ \r
+ (defun notmuch-show-insert-header (header header-value)\r
+ "Insert a single header."\r
+@@ -796,8 +806,15 @@ current buffer, if possible."\r
+ (defun notmuch-show-insert-bodypart (msg part depth)\r
+ "Insert the body part PART at depth DEPTH in the current thread."\r
+ (let ((content-type (downcase (plist-get part :content-type)))\r
+- (nth (plist-get part :id)))\r
+- (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))\r
++ (nth (plist-get part :id))\r
++ (start (point)))\r
++ (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)\r
++\r
++ ;; Ensure that face properties applied to text in the buffer by\r
++ ;; the part handler don't leak into the following text.\r
++ (put-text-property start (point-max)\r
++ 'rear-nonsticky '(face)))\r
++\r
+ ;; Some of the body part handlers leave point somewhere up in the\r
+ ;; part, so we make sure that we're down at the end.\r
+ (goto-char (point-max))\r
+@@ -888,11 +905,12 @@ current buffer, if possible."\r
+ (setq body-end (point-marker))\r
+ (setq content-end (point-marker))\r
+ \r
+- ;; Indent according to the depth in the thread.\r
+- (indent-rigidly content-start content-end (* notmuch-show-indent-messages-width depth))\r
+-\r
+ (setq message-end (point-max-marker))\r
+ \r
++ ;; Indent according to the depth in the thread.\r
++ (indent-rigidly message-start message-end\r
++ (* notmuch-show-indent-messages-width depth))\r
++\r
+ ;; Save the extents of this message over the whole text of the\r
+ ;; message.\r
+ (put-text-property message-start message-end :notmuch-message-extent (cons message-start message-end))\r
+diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
+index 56981d0..29a9d45 100644\r
+--- a/emacs/notmuch-wash.el\r
++++ b/emacs/notmuch-wash.el\r
+@@ -187,7 +187,9 @@ that PREFIX should not include a newline."\r
+ (let* ((cite-start (match-beginning 0))\r
+ (cite-end (match-end 0))\r
+ (cite-lines (count-lines cite-start cite-end)))\r
+- (overlay-put (make-overlay cite-start cite-end) 'face 'message-cited-text)\r
++ (put-text-property cite-start cite-end 'face 'message-cited-text)\r
++ ;; Ensure that the next line doesn't inherit our face.\r
++ (put-text-property (1- cite-end) cite-end 'rear-nonsticky '(face))\r
+ (when (> cite-lines (+ notmuch-wash-citation-lines-prefix\r
+ notmuch-wash-citation-lines-suffix\r
+ 1))\r
+@@ -209,7 +211,9 @@ that PREFIX should not include a newline."\r
+ (sig-end-marker (make-marker)))\r
+ (set-marker sig-start-marker sig-start)\r
+ (set-marker sig-end-marker (point-max))\r
+- (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 'message-cited-text)\r
++ (put-text-property sig-start-marker sig-end-marker 'face 'message-cited-text)\r
++ ;; Ensure that the next line doesn't inherit our face.\r
++ (put-text-property (1- sig-end-marker) sig-end-marker 'rear-nonsticky '(face))\r
+ (notmuch-wash-region-to-button\r
+ msg sig-start-marker sig-end-marker\r
+ "signature"))))))\r
+-- \r
+1.7.8.3\r
+\r