emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 748bf7b: Allow using `mm-inline-message' from other mail clients


From: Lars Ingebrigtsen
Subject: master 748bf7b: Allow using `mm-inline-message' from other mail clients than Gnus
Date: Tue, 6 Jul 2021 10:34:30 -0400 (EDT)

branch: master
commit 748bf7b93edcfd1707fa3f593a330979e280eb49
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Allow using `mm-inline-message' from other mail clients than Gnus
    
    * lisp/gnus/mm-view.el (mm-inline-message-prepare-function): New
    variable (bug#49380).
    (mm-inline-message): Use it to separate out the Gnus-specific code.
    * lisp/gnus/gnus-art.el (gnus-mime-display-single): ... which has
    been moved here.
---
 lisp/gnus/gnus-art.el | 23 ++++++++++++++++++++++-
 lisp/gnus/mm-view.el  | 27 +++++++++------------------
 2 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index f2ec946..b989446 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -6039,7 +6039,28 @@ If nil, don't show those extra buttons."
        (ignored gnus-ignored-mime-types)
        (mm-inline-font-lock (gnus-visual-p 'article-highlight 'highlight))
        (not-attachment t)
-       display text)
+        ;; 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
       (progn
        (while ignored
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el
index 3e36d67..2ec75a0 100644
--- a/lisp/gnus/mm-view.el
+++ b/lisp/gnus/mm-view.el
@@ -418,16 +418,18 @@ This is only used if `mm-inline-large-images' is set to
   (fundamental-mode)
   (goto-char (point-min)))
 
-(defvar gnus-original-article-buffer)
-(defvar gnus-article-prepare-hook)
-(defvar gnus-displaying-mime)
+(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.")
 
 (defun mm-inline-message (handle)
+  "Insert HANDLE (a message/rfc822 part) into the current buffer.
+This function will call `mm-inline-message-prepare-function'
+after inserting the part."
   (let ((b (point))
        (bolp (bolp))
        (charset (mail-content-type-get
-                 (mm-handle-type handle) 'charset))
-       gnus-displaying-mime handles)
+                 (mm-handle-type handle) 'charset)))
     (when (and charset
               (stringp charset))
       (setq charset (intern (downcase charset)))
@@ -437,16 +439,8 @@ This is only used if `mm-inline-large-images' is set to
       (save-restriction
        (narrow-to-region b b)
        (mm-insert-part handle)
-       (let (gnus-article-mime-handles
-             ;; disable prepare hook
-             gnus-article-prepare-hook
-             (gnus-newsgroup-charset
-              (unless (eq charset 'gnus-decoded) ;; mm-uu might set it.
-                (or charset gnus-newsgroup-charset))))
-         (let ((gnus-original-article-buffer (mm-handle-buffer handle)))
-           (run-hooks 'gnus-article-decode-hook))
-         (gnus-article-prepare-display)
-         (setq handles gnus-article-mime-handles))
+        (when mm-inline-message-prepare-function
+         (funcall mm-inline-message-prepare-function charset))
        (goto-char (point-min))
        (unless bolp
          (insert "\n"))
@@ -454,9 +448,6 @@ This is only used if `mm-inline-large-images' is set to
        (unless (bolp)
          (insert "\n"))
        (insert "----------\n\n")
-       (when handles
-         (setq gnus-article-mime-handles
-               (mm-merge-handles gnus-article-mime-handles handles)))
        (mm-handle-set-undisplayer
         handle
         (let ((beg (point-min-marker))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]