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

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

Date: Mon, 19 Aug 2013 11:38:15 +0300

To: notmuch@notmuchmail.org

Cc:

From: Jani Nikula


In reply, insert quotable parts using notmuch-show-insert-bodypart
instead of calling notmuch-mm-display-part-inline directly to render
the quoted parts as they are rendered in show view.

The notable change is that replies to text/calendar parts quote the
pretty printed output of icalendar-import-buffer rather than the ugly
raw vcalendar.
---
 emacs/notmuch-mua.el  |    7 ++++---
 emacs/notmuch-show.el |    9 ++++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 2baae5f..24b0d0f 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -130,9 +130,10 @@ list."
 (defun notmuch-mua-insert-quotable-part (message part)
   (save-restriction
     (narrow-to-region (point) (point))
-    (notmuch-mm-display-part-inline message part (plist-get part :id)
-				    (plist-get part :content-type)
-				    notmuch-show-process-crypto)
+    ;; We don't want hooks, such as notmuch-wash-*, to be run on the
+    ;; quotable part.
+    (let ((notmuch-show-insert-text/plain-hook nil))
+      (notmuch-show-insert-bodypart message part 0 nil t))
     (goto-char (point-max))))
 
 ;; There is a bug in emacs 23's message.el that results in a newline
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 82b70ba..1fb48aa 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -874,7 +874,7 @@ message at DEPTH in the current thread."
       ;; showable this returns nil.
       (notmuch-show-create-part-overlays button part-beg part-end))))
 
-(defun notmuch-show-insert-bodypart (msg part depth &optional hide)
+(defun notmuch-show-insert-bodypart (msg part depth &optional hide quote)
   "Insert the body part PART at depth DEPTH in the current thread.
 
 If HIDE is non-nil then initially hide this part."
@@ -887,8 +887,11 @@ If HIDE is non-nil then initially hide this part."
 			content-type))
 	 (nth (plist-get part :id))
 	 (beg (point))
-	 ;; We omit the part button for the first (or only) part if this is text/plain.
-	 (button (unless (and (string= mime-type "text/plain") (<= nth 1))
+	 ;; We omit the part button for the first (or only) part if
+	 ;; this is text/plain, or we're inserting the part for
+	 ;; quoting in reply.
+	 (button (unless (or quote
+			     (and (string= mime-type "text/plain") (<= nth 1)))
 		   (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))
 	 (content-beg (point)))
 
-- 
1.7.10.4


Thread: