From b6dd3d7155cb8734926c1d99e3585a1c56af897b Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 25 Mar 2025 11:45:29 +0100 Subject: [PATCH] Use better attachment defaults for *diff* buffers * lisp/gnus/mm-encode.el (mm-default-buffer-type): New defun. * lisp/gnus/mml.el (mml-attach-buffer): Use it. (cherry picked from commit 2adc912d0ec277d9ffe6485e7d81849fab98a2ea) --- lisp/gnus/mm-encode.el | 8 ++++++++ lisp/gnus/mml.el | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/gnus/mm-encode.el b/lisp/gnus/mm-encode.el index 2ac336e800f..262b1c4d21c 100644 --- a/lisp/gnus/mm-encode.el +++ b/lisp/gnus/mm-encode.el @@ -107,6 +107,14 @@ This variable should never be set directly, but bound before a call to "application/octet-stream" (mailcap-extension-to-mime (match-string 0 file)))) +(defun mm-default-buffer-type (buffer) + "Return a default content type for BUFFER, a buffer name." + (if (and (stringp buffer) + (string-match-p + (rx (| "*Diff*" "*vc-diff*" "*ediff-diff*" "*ediff-custom-diff*")) + buffer)) + "text/x-patch" "text/plain")) + (defun mm-safer-encoding (encoding &optional type) "Return an encoding similar to ENCODING but safer than it." (cond diff --git a/lisp/gnus/mml.el b/lisp/gnus/mml.el index 874fb4118d8..16c161c9853 100644 --- a/lisp/gnus/mml.el +++ b/lisp/gnus/mml.el @@ -1508,7 +1508,8 @@ FILENAME is a suggested file name for the attachment should a recipient wish to save a copy separate from the message." (interactive (let* ((buffer (read-buffer "Attach buffer: ")) - (type (mml-minibuffer-read-type buffer "text/plain")) + (type (mml-minibuffer-read-type + buffer (mm-default-buffer-type buffer))) (description (mml-minibuffer-read-description)) (disposition (mml-minibuffer-read-disposition type nil))) (list buffer type description disposition))) -- 2.39.5