Re: [PATCH v2] emacs: insert quotable parts in reply as they are displayed in show view

Subject: Re: [PATCH v2] emacs: insert quotable parts in reply as they are displayed in show view

Date: Sun, 01 Sep 2013 15:54:27 +0100

To: Jani Nikula, notmuch@notmuchmail.org

Cc: Tomi Ollila

From: Mark Walters


Here is a slightly better (I think) version of this. If we use a
temp-buffer we don't need the narrowing or point movement as the insert
buffer-string should get that right.

Best wishes

Mark

>From d0925d374411cf5031832f4d72b6fb5d21a45b21 Mon Sep 17 00:00:00 2001
From: Mark Walters <markwalters1009@gmail.com>
Date: Fri, 30 Aug 2013 17:43:46 +0100
Subject: [PATCH] tweak

---
 emacs/notmuch-mua.el |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index e7cc94e..ff8149b 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -130,14 +130,15 @@ list."
 	  collect part))
 
 (defun notmuch-mua-insert-quotable-part (message part)
-  (save-restriction
-    (narrow-to-region (point-min) (point))
-    ;; We don't want hooks, such as notmuch-wash-*, to be run on the
-    ;; quotable part.
-    (let ((notmuch-show-insert-text/plain-hook nil))
-      ;; Show the part but do not add buttons.
-      (notmuch-show-insert-bodypart message part 0 'no-buttons))
-    (goto-char (point-max))))
+  ;; We don't want text properties leaking from the show renderer into
+  ;; the reply so we use a temp buffer. Also we don't want hooks, such
+  ;; as notmuch-wash-*, to be run on the quotable part so we set
+  ;; notmuch-show-insert-text/plain-hook to nil.
+  (insert (with-temp-buffer
+	    (let ((notmuch-show-insert-text/plain-hook nil))
+	      ;; Show the part but do not add buttons.
+	      (notmuch-show-insert-bodypart message part 0 'no-buttons))
+	    (buffer-substring-no-properties (point-min) (point-max)))))
 
 ;; There is a bug in emacs 23's message.el that results in a newline
 ;; not being inserted after the References header, so the next header
-- 
1.7.9.1


Thread: