Uwe Brauer wrote: >>>> "EB" == Emanuel Berg writes: > >> Uwe Brauer wrote: >>>> You could try `mailcap-file-name-to-mime-type' on the file >>>> name, and see if that gets it right often enough to >>>> be useful. >>> >>> Hm I tried (mailcap-file-name-to-mime-type (buffer-file-name >>> current-buffer)) but that did not work >>> >>> I mean >>> >>> (defun my-attach-this-buffer () >>> "Send the whole buffer, funny to note that such a function does not exist." >>> (interactive) >>> (let ((src-buf (buffer-file-name (current-buffer)))) >>> (let ((my-mime (mailcap-file-name-to-mime-type >>> (buffer-file-name current-buffer)))) >>> (gnus-summary-post-news) >>> (mail-text) >>> (mml-attach-buffer src-buf my-mime nil nil) >>> (message-goto-to)))) >>> >>> But it did not work > >> Are you kidding? :O > >> Straight gangsta! > >> (require 'gnus-msg) >> (require 'mailcap) >> (require 'message) >> (require 'mml) >> (require 'sendmail) > >> (defun mail-attach-buffer () >> (interactive) >> (let*((buf (buffer-file-name (current-buffer))) >> (mime (mailcap-file-name-to-mime-type buf)) ) >> (gnus-summary-post-news) >> (mail-text) >> (mml-attach-buffer buf mime) >> (message-goto-to) )) > > Thanks, misplaced brackets and let instead of let*, I copied that code > from another one badly. > > Strangely enough if I fire that function in a matlab file > I obtain > > #part buffer="/home/oub/Annu-Matlab2021/file.m" > #/part > > So mail-cap-file-name-to-mime-type does not work, even though > "text/x-matlab" > > Seems a recognised type. Maybe that is a bug It works here what I can see, e.g. in/from mail.el you get < #part type="application/emacs-lisp" buffer="/home/incal/.emacs.d/emacs-init/gnus/mail.el">