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.
This commit is contained in:
Michael Albinus 2025-03-25 11:45:29 +01:00
parent d6c7a77465
commit 2adc912d0e
2 changed files with 10 additions and 1 deletions

View file

@ -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

View file

@ -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)))