]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Correctly quote non-text/plain parts in reply
authorAdam Wolfe Gordon <awg+notmuch@xvx.ca>
Sat, 5 May 2012 19:30:37 +0000 (13:30 -0600)
committerDavid Bremner <bremner@debian.org>
Sun, 6 May 2012 11:48:11 +0000 (08:48 -0300)
Quote non-text parts nicely by displaying them with mm-display-part
before calling message-cite-original to quote them. HTML-only emails
can now be quoted correctly. We re-use some code from notmuch-show
(notmuch-show-mm-display-part-inline), which has been moved to
notmuch-lib.el.

Mark the test for this feature as not broken.

emacs/notmuch-lib.el
emacs/notmuch-mua.el
emacs/notmuch-show.el
test/emacs

index 6907a5f910b4e33b8efc9f6d65bee3708a1a2c82..7fa441af30a5ba17ca6881689febe5cfc9ec30f2 100644 (file)
@@ -21,6 +21,8 @@
 
 ;; This is an part of an emacs-based interface to the notmuch mail system.
 
+(require 'mm-view)
+(require 'mm-decode)
 (eval-when-compile (require 'cl))
 
 (defvar notmuch-command "notmuch"
@@ -237,6 +239,23 @@ the given type."
   (or (plist-get part :content)
       (notmuch-get-bodypart-internal (notmuch-id-to-query (plist-get msg :id)) nth process-crypto)))
 
+(defun notmuch-mm-display-part-inline (msg part nth content-type process-crypto)
+  "Use the mm-decode/mm-view functions to display a part in the
+current buffer, if possible."
+  (let ((display-buffer (current-buffer)))
+    (with-temp-buffer
+      (let* ((charset (plist-get part :content-charset))
+            (handle (mm-make-handle (current-buffer) `(,content-type (charset . ,charset)))))
+       ;; If the user wants the part inlined, insert the content and
+       ;; test whether we are able to inline it (which includes both
+       ;; capability and suitability tests).
+       (when (mm-inlined-p handle)
+         (insert (notmuch-get-bodypart-content msg part nth process-crypto))
+         (when (mm-inlinable-p handle)
+           (set-buffer display-buffer)
+           (mm-display-part handle)
+           t))))))
+
 ;; Converts a plist of headers to an alist of headers. The input plist should
 ;; have symbols of the form :Header as keys, and the resulting alist will have
 ;; symbols of the form 'Header as keys.
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)
index 37f0ebb337ae656812b8a472baa3f95b6e99cebf..d318430cdc842c71acf8acab6262c46d066d732b 100644 (file)
@@ -524,23 +524,6 @@ message at DEPTH in the current thread."
     (let ((handle (mm-make-handle (current-buffer) (list content-type))))
       (mm-interactively-view-part handle))))
 
-(defun notmuch-show-mm-display-part-inline (msg part nth content-type)
-  "Use the mm-decode/mm-view functions to display a part in the
-current buffer, if possible."
-  (let ((display-buffer (current-buffer)))
-    (with-temp-buffer
-      (let* ((charset (plist-get part :content-charset))
-            (handle (mm-make-handle (current-buffer) `(,content-type (charset . ,charset)))))
-       ;; If the user wants the part inlined, insert the content and
-       ;; test whether we are able to inline it (which includes both
-       ;; capability and suitability tests).
-       (when (mm-inlined-p handle)
-         (insert (notmuch-get-bodypart-content msg part nth notmuch-show-process-crypto))
-         (when (mm-inlinable-p handle)
-           (set-buffer display-buffer)
-           (mm-display-part handle)
-           t))))))
-
 (defun notmuch-show-multipart/*-to-list (part)
   (mapcar (lambda (inner-part) (plist-get inner-part :content-type))
          (plist-get part :content)))
@@ -785,7 +768,7 @@ current buffer, if possible."
 (defun notmuch-show-insert-part-*/* (msg part content-type nth depth declared-type)
   ;; This handler _must_ succeed - it is the handler of last resort.
   (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename))
-  (notmuch-show-mm-display-part-inline msg part nth content-type)
+  (notmuch-mm-display-part-inline msg part nth content-type notmuch-show-process-crypto)
   t)
 
 ;; Functions for determining how to handle MIME parts.
index 5f238d9a1aff09e2f9812f55e57018e9bf959301..a615b3982787a82bc63c9847f1913cbcb0db001f 100755 (executable)
@@ -445,7 +445,6 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "Reply within emacs to an html-only message"
-test_subtest_known_broken
 add_message '[content-type]="text/html"' \
            '[body]="Hi,<br />This is an <b>HTML</b> test message.<br /><br />OK?"'
 test_emacs "(let ((message-hidden-headers '()))