From 9423212fa0eab015541880227237a6d9fc7b30d8 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Fri, 12 Mar 2021 22:26:26 +0200 Subject: [PATCH] mu4e: improve mu4e-view-message-text Attempt to take the Content-Type into consideration when decoding. --- mu4e/mu4e-view-gnus.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mu4e/mu4e-view-gnus.el b/mu4e/mu4e-view-gnus.el index 3ca8d82b..11592b5d 100644 --- a/mu4e/mu4e-view-gnus.el +++ b/mu4e/mu4e-view-gnus.el @@ -384,15 +384,23 @@ Gnus' article-mode." (mu4e~view-mode-body)) (defun mu4e-view-message-text (msg) - "Return the message to display (as a string)." + "Return the message as a string, for replying/forwarding etc.." (with-temp-buffer (let ((path (mu4e-message-field msg :path)) (inhibit-read-only t) - (mm-decrypt-option 'known) + (mm-decrypt-option 'never) (gnus-article-emulate-mime t)) (buffer-disable-undo) (insert-file-contents-literally path nil nil nil t) (mm-enable-multibyte) + (let* ((ct (mail-fetch-field "Content-Type")) + (ct (and ct (mail-header-parse-content-type ct))) + (charset (mail-content-type-get ct 'charset)) + (charset (and charset (intern charset))) + (gnus-newsgroup-charset + (if (and charset (coding-system-p charset)) charset + (detect-coding-region (point-min) (point-max) t)))) + (run-hooks 'gnus-article-decode-hook)) (gnus-article-prepare-display) (buffer-string))))