]> git.eshelyaron.com Git - emacs.git/commitdiff
Make message/rfc822 on buttons work again in Gnus
authorLars Ingebrigtsen <larsi@gnus.org>
Fri, 29 Oct 2021 15:26:53 +0000 (17:26 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Fri, 29 Oct 2021 15:26:53 +0000 (17:26 +0200)
* lisp/gnus/gnus-art.el (gnus-article-mode): Set
mm-inline-message-prepare-function buffer-locally so that it works
both when inlining rfc822 and hitting the MIME button (bug#51388).
(gnus-mime--inline-message): Factor out into own function.
(gnus-mime-display-single): From here.

lisp/gnus/gnus-art.el
lisp/gnus/mm-view.el

index 930c739a735b55815fa54d9bee78e5622598a25f..6b33680871a3761ff2e289bd2ece3d580f37e33b 100644 (file)
@@ -4506,6 +4506,10 @@ commands:
   (gnus-set-default-directory)
   (buffer-disable-undo)
   (setq show-trailing-whitespace nil)
+  ;; Arrange a callback from `mm-inline-message' if we're
+  ;; displaying a message/rfc822 part.
+  (setq-local mm-inline-message-prepare-function
+              #'gnus-mime--inline-message-function)
   (mm-enable-multibyte))
 
 (defun gnus-article-setup-buffer ()
@@ -6041,31 +6045,29 @@ If nil, don't show those extra buttons."
 (defun gnus-mime-display-mixed (handles)
   (mapcar #'gnus-mime-display-part handles))
 
+(defun gnus-mime--inline-message-function (handle charset)
+  (let ((handles
+         (let (gnus-article-mime-handles
+              ;; disable prepare hook
+              gnus-article-prepare-hook
+              (gnus-newsgroup-charset
+                ;; mm-uu might set it.
+               (unless (eq charset 'gnus-decoded)
+                 (or charset gnus-newsgroup-charset))))
+          (let ((gnus-original-article-buffer
+                  (mm-handle-buffer handle)))
+            (run-hooks 'gnus-article-decode-hook))
+          (gnus-article-prepare-display)
+           gnus-article-mime-handles)))
+    (when handles
+      (setq gnus-article-mime-handles
+           (mm-merge-handles gnus-article-mime-handles handles)))))
+
 (defun gnus-mime-display-single (handle)
   (let ((type (mm-handle-media-type handle))
        (ignored gnus-ignored-mime-types)
        (mm-inline-font-lock (gnus-visual-p 'article-highlight 'highlight))
        (not-attachment t)
-        ;; Arrange a callback from `mm-inline-message' if we're
-        ;; displaying a message/rfc822 part.
-        (mm-inline-message-prepare-function
-         (lambda (charset)
-           (let ((handles
-                  (let (gnus-article-mime-handles
-                       ;; disable prepare hook
-                       gnus-article-prepare-hook
-                       (gnus-newsgroup-charset
-                         ;; mm-uu might set it.
-                        (unless (eq charset 'gnus-decoded)
-                          (or charset gnus-newsgroup-charset))))
-                   (let ((gnus-original-article-buffer
-                           (mm-handle-buffer handle)))
-                     (run-hooks 'gnus-article-decode-hook))
-                   (gnus-article-prepare-display)
-                    gnus-article-mime-handles)))
-            (when handles
-              (setq gnus-article-mime-handles
-                    (mm-merge-handles gnus-article-mime-handles handles))))))
        display text
         gnus-displaying-mime)
     (catch 'ignored
index 56d05c8fa939fcfc6d72acf51c93577f2fd8db7d..d2a6d2cf5d31aa62aa45dfdc4bc005aaf3ad35fd 100644 (file)
@@ -451,7 +451,7 @@ This is only used if `mm-inline-large-images' is set to
 
 (defvar mm-inline-message-prepare-function nil
   "Function called by `mm-inline-message' to do client specific setup.
-It is called with one parameter -- the charset.")
+It is called with two parameters -- the MIME handle and the charset.")
 
 (defun mm-inline-message (handle)
   "Insert HANDLE (a message/rfc822 part) into the current buffer.
@@ -471,7 +471,7 @@ after inserting the part."
        (narrow-to-region b b)
        (mm-insert-part handle)
         (when mm-inline-message-prepare-function
-         (funcall mm-inline-message-prepare-function charset))
+         (funcall mm-inline-message-prepare-function handle charset))
        (goto-char (point-min))
        (unless bolp
          (insert "\n"))