]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch-mua.el
emacs: Correctly quote non-text/plain parts in reply
[notmuch] / emacs / notmuch-mua.el
index 87bd88d33184a9157e4309776d83b9e42fda6fbe..fc7ae0732803200456af198feebe060ef62e2583 100644 (file)
@@ -21,6 +21,7 @@
 
 (require 'json)
 (require 'message)
+(require 'mm-view)
 (require 'format-spec)
 
 (require 'notmuch-lib)
@@ -90,6 +91,14 @@ list."
        else if (notmuch-match-content-type (plist-get part :content-type) "text/*")
          collect part))
 
+(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)
+    (goto-char (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
 ;; is concatenated to the end of it. This function fixes the problem,
@@ -169,11 +178,7 @@ list."
        ;; Get the parts of the original message that should be quoted; this includes
        ;; all the text parts, except the non-preferred ones in a multipart/alternative.
        (let ((quotable-parts (notmuch-mua-get-quotable-parts (plist-get original :body))))
-         (mapc (lambda (part)
-                 (insert (notmuch-get-bodypart-content original part
-                                                       (plist-get part :id)
-                                                       notmuch-show-process-crypto)))
-               quotable-parts))
+         (mapc (apply-partially 'notmuch-mua-insert-quotable-part original) quotable-parts))
 
        (set-mark (point))
        (goto-char start)