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 201f64eb654..e53d35146e8 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)))