* default mime for attaching files @ 2007-02-09 0:52 Sebastian P. Luque 2007-02-09 2:00 ` Katsumi Yamaoka 0 siblings, 1 reply; 11+ messages in thread From: Sebastian P. Luque @ 2007-02-09 0:52 UTC (permalink / raw) To: ding Hi, I often need to attach tar.gz archives in messages, and noticed that whenever I do 'C-c C-a' (mml-attach-file), I'm faced with the default "application/octet-stream". I don't understand much about mime-types, but I gather that tar.gz files should be specified as "application/x-gzip". Browsing 'M-x customize-group mime' I can't find some relevant variable to set a default (and possibly other files) for files suffixed *.tar.gz. Any suggestions would be welcome. Cheers, -- Seb ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default mime for attaching files 2007-02-09 0:52 default mime for attaching files Sebastian P. Luque @ 2007-02-09 2:00 ` Katsumi Yamaoka 2007-02-09 5:22 ` Sebastian P. Luque 0 siblings, 1 reply; 11+ messages in thread From: Katsumi Yamaoka @ 2007-02-09 2:00 UTC (permalink / raw) To: ding >>>>> In <87zm7op2y1.fsf@patagonia.sebmags.homelinux.org> >>>>> Sebastian P. Luque wrote: > I often need to attach tar.gz archives in messages, and noticed that > whenever I do 'C-c C-a' (mml-attach-file), I'm faced with the default > "application/octet-stream". I don't understand much about mime-types, but > I gather that tar.gz files should be specified as "application/x-gzip". > Browsing 'M-x customize-group mime' I can't find some relevant variable to > set a default (and possibly other files) for files suffixed *.tar.gz. Any > suggestions would be welcome. First of all, application/octet-stream for *.gz files is not so bad choice. OTOH, types beginning with x- are non-standard, it suggests not all mailers support them. In Gnus, the default type for a certain file name is determined according to the value of the `mailcap-mime-extensions' variable. The value of `mailcap-mime-extensions' defined in mailcap.el is just a default value. It will be overridden if you have the file specified by the MIMETYPES environment variable or there are the files ~/.mime.types, /etc/mime.types, /usr/etc/mime.types, etc. in your system. If you prefer application/x-gzip for *.gz files, create the file named "~/.mime.types" with the following contents, for example: --8<---------------cut here---------------start------------->8--- application/x-gzip gz application/x-tar tar ... --8<---------------cut here---------------end--------------->8--- If you customize it while Gnus is running, you need to perform `C-u M-x mailcap-parse-mimetypes RET' after saving the file. In addition, you may possibly need to set the MIMETYPES environment variable to the file name. To do it for only Emacs, add this line to the ~/.emacs file: --8<---------------cut here---------------start------------->8--- (setenv "MIMETYPES" "~/.mime.types") --8<---------------cut here---------------end--------------->8--- Regards, ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default mime for attaching files 2007-02-09 2:00 ` Katsumi Yamaoka @ 2007-02-09 5:22 ` Sebastian P. Luque 2007-02-09 5:47 ` Katsumi Yamaoka 0 siblings, 1 reply; 11+ messages in thread From: Sebastian P. Luque @ 2007-02-09 5:22 UTC (permalink / raw) To: ding On Fri, 09 Feb 2007 11:00:27 +0900, Katsumi Yamaoka <yamaoka@jpl.org> wrote: [...] > If you customize it while Gnus is running, you need to perform `C-u M-x > mailcap-parse-mimetypes RET' after saving the file. In addition, you > may possibly need to set the MIMETYPES environment variable to the file > name. To do it for only Emacs, add this line to the ~/.emacs file: > (setenv "MIMETYPES" "~/.mime.types") Thanks Katsumi, this was very instructive. I realize I do have both a /etc/mime.types _and_ ~/.mime.types (the first installed by Debian testing and the second by crossover¹). Your line for specifying the tar type was already in /etc/mime.types, so I just added: application/x-gzip gz to ~/.mime.types and reparsed as you suggested. It does what I was looking for. The reason I wanted to do this is that people I've sent *.tar.gz files with the default application/octet-stream complained that they couldn't "open them" well in their systems (I couldn't get more details than that). So I came across this: http://en.wikipedia.org/wiki/Gzip Is this incorrect? Thanks, +---- *Footnotes* ----+ ¹ The Windoze emulator -- Seb ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default mime for attaching files 2007-02-09 5:22 ` Sebastian P. Luque @ 2007-02-09 5:47 ` Katsumi Yamaoka 2007-02-17 23:46 ` Sebastian P. Luque 0 siblings, 1 reply; 11+ messages in thread From: Katsumi Yamaoka @ 2007-02-09 5:47 UTC (permalink / raw) To: ding >>>>> In <87lkj7q506.fsf@patagonia.sebmags.homelinux.org> >>>>> Sebastian P. Luque wrote: > The reason I wanted to do this is that people I've sent *.tar.gz files > with the default application/octet-stream complained that they couldn't > "open them" well in their systems (I couldn't get more details than > that). So I came across this: > http://en.wikipedia.org/wiki/Gzip > Is this incorrect? application/x-gzip for .gz files seems to be the de-facto standard nowadays. While I don't have the personal mime.types file, Fedora Core 6 Linux that I use assigns it to gz and tgz in the /etc/mime.types file. So, such files I send will be all labeled with application/x-gzip actually. ;-) Regards, ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default mime for attaching files 2007-02-09 5:47 ` Katsumi Yamaoka @ 2007-02-17 23:46 ` Sebastian P. Luque 2007-02-18 0:34 ` Katsumi Yamaoka 0 siblings, 1 reply; 11+ messages in thread From: Sebastian P. Luque @ 2007-02-17 23:46 UTC (permalink / raw) To: ding Hi again, I had a quick followup question about this same issue. How can the default disposition for a certain mime-type be specified? For instance, all *.csv files I attach have a default "inline" disposition, but I would like to change this to "attachment". Thanks for any further advice. Cheers, -- Seb ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default mime for attaching files 2007-02-17 23:46 ` Sebastian P. Luque @ 2007-02-18 0:34 ` Katsumi Yamaoka 2007-02-18 3:32 ` Miles Bader 0 siblings, 1 reply; 11+ messages in thread From: Katsumi Yamaoka @ 2007-02-18 0:34 UTC (permalink / raw) To: ding >>>>> In <878xewfiue.fsf@patagonia.sebmags.homelinux.org> >>>>> "Sebastian P. Luque" <spluque@gmail.com> wrote: > I had a quick followup question about this same issue. How can the > default disposition for a certain mime-type be specified? For instance, > all *.csv files I attach have a default "inline" disposition, but I would > like to change this to "attachment". Thanks for any further advice. By default, Gnus uses the "inline" disposition for an attachment of which the MIME type is text/* except text/rtf[1]. So, the reason seems to be that the text/* MIME type is specified in your system for *.csv files. You know how to customize it already. ;-) [1] The `mml-minibuffer-read-disposition' function does it. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default mime for attaching files 2007-02-18 0:34 ` Katsumi Yamaoka @ 2007-02-18 3:32 ` Miles Bader 2007-02-19 12:22 ` Katsumi Yamaoka 0 siblings, 1 reply; 11+ messages in thread From: Miles Bader @ 2007-02-18 3:32 UTC (permalink / raw) To: ding Katsumi Yamaoka <yamaoka@jpl.org> writes: > By default, Gnus uses the "inline" disposition for an attachment of > which the MIME type is text/* except text/rtf[1]. So, the reason > seems to be that the text/* MIME type is specified in your system > for *.csv files. You know how to customize it already. ;-) Actually I've always thought that this behavior of Gnus was sort of dumb -- I don't think it really makes sense to inline random text/ sub-types. Glancing through the list of text/ sub-types in /etc/mime.types, most look like the sort of thing I wouldn't want inline; in practice I also find that I usually have to override the default (the one which annoys most often is text/x-diff). Instead I think Gnus should default to "attach", and have a list of text/ sub-types which _should_ be inlined (bonus for making it a real configurable list, not hardwired in the code...). Thanks, -Miles -- Fast, small, soon; pick any 2. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default mime for attaching files 2007-02-18 3:32 ` Miles Bader @ 2007-02-19 12:22 ` Katsumi Yamaoka 2007-02-19 19:49 ` Reiner Steib 0 siblings, 1 reply; 11+ messages in thread From: Katsumi Yamaoka @ 2007-02-19 12:22 UTC (permalink / raw) To: ding [-- Attachment #1: Type: text/plain, Size: 2285 bytes --] >>>>> In <877iug6szc.fsf@catnip.gol.com> Miles Bader wrote: > Katsumi Yamaoka <yamaoka@jpl.org> writes: >> By default, Gnus uses the "inline" disposition for an attachment of >> which the MIME type is text/* except text/rtf[1]. So, the reason >> seems to be that the text/* MIME type is specified in your system >> for *.csv files. You know how to customize it already. ;-) > Actually I've always thought that this behavior of Gnus was sort of dumb > -- I don't think it really makes sense to inline random text/ sub-types. > Glancing through the list of text/ sub-types in /etc/mime.types, most > look like the sort of thing I wouldn't want inline; in practice I also > find that I usually have to override the default (the one which annoys > most often is text/x-diff). > Instead I think Gnus should default to "attach", and have a list of > text/ sub-types which _should_ be inlined (bonus for making it a real > configurable list, not hardwired in the code...). I made such one for a trial. Is this worth implementing in Gnus? --8<---------------cut here---------------start------------->8--- mml-content-disposition-alist is a variable defined in `mml.el'. Its value is ((text (rtf . "attachment") (t . "inline")) (t . "attachment")) Documentation: Alist of MIME types or regexps matching file names and default dispositions. Each element should be one of the following three forms: (REGEXP . DISPOSITION) (TYPE (SUBTYPE . DISPOSITION) (SUBTYPE . DISPOSITION)...) (TYPE . DISPOSITION) Where REGEXP is a string which matches the file name (if any) of an attachment, TYPE is a MIME type and SUBTYPE is a MIME subtype of an attachment, and DISPOSITION should be either "attachment" or "inline". The value t for TYPE or SUBTYPE matches any MIME types or MIME subtypes. The first match found will be used. --8<---------------cut here---------------end--------------->8--- I did set the default value so as not to change the present behavior of Gnus. For instance, Sebastian may want to use the following: --8<---------------cut here---------------start------------->8--- (add-to-list 'mml-content-disposition-alist '("\\.csv\\'" . "attachment")) --8<---------------cut here---------------end--------------->8--- Here's a patch to the Gnus CVS trunk: [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: Type: text/x-patch, Size: 5289 bytes --] --- mml.el~ 2007-01-24 07:13:23 +0000 +++ mml.el 2007-02-19 12:19:12 +0000 @@ -70,6 +70,51 @@ :type '(repeat (symbol :tag "Parameter")) :group 'message) +(defcustom mml-content-disposition-alist + '((text (rtf . "attachment") (t . "inline")) + (t . "attachment")) + "Alist of MIME types or regexps matching file names and default dispositions. +Each element should be one of the following three forms: + + (REGEXP . DISPOSITION) + (TYPE (SUBTYPE . DISPOSITION) (SUBTYPE . DISPOSITION)...) + (TYPE . DISPOSITION) + +Where REGEXP is a string which matches the file name (if any) of an +attachment, TYPE is a MIME type and SUBTYPE is a MIME subtype of an +attachment, and DISPOSITION should be either \"attachment\" or \"inline\". +The value t for TYPE or SUBTYPE matches any MIME types or MIME +subtypes. The first match found will be used." + :version "23.0" ;; No Gnus + :type (let ((dispositions '(radio :format "DISPOSITION: %v" + :value "attachment" + (const :format "\"%v\" " "attachment") + (const :format "\"%v\" " "inline") + (const :format "\"\"\n" "")))) + `(repeat + :offset 0 + (choice :format "%[Value Menu%]%v" + (cons :tag "(REGEXP . DISPOSITION)" + :extra-offset 4 + (regexp :tag "REGEXP" :value ".*") + ,dispositions) + (cons :tag "(TYPE (SUBTYPE . DISPOSITION)...)" + :indent 0 + (symbol :tag " TYPE" :value text) + (repeat :format "%v%i\n" + :extra-offset 4 + :offset 0 + (cons :format "%v" + :extra-offset 5 + (symbol :tag "SUBTYPE" + :value t) + ,dispositions))) + (cons :tag "(TYPE . DISPOSITION)" + :extra-offset 4 + (symbol :tag "TYPE" :value t) + ,dispositions)))) + :group 'message) + (defcustom mml-insert-mime-headers-always nil "If non-nil, always put Content-Type: text/plain at top of empty parts. It is necessary to work against a bug in certain clients." @@ -667,6 +712,30 @@ "") mml-base-boundary)) +(defun mml-content-disposition (type &optional filename) + "Return a default disposition name suitable to TYPE or FILENAME." + (let ((defs mml-content-disposition-alist) + disposition def types) + (while (and (not disposition) defs) + (setq def (pop defs)) + (cond ((stringp (car def)) + (when (and filename + (string-match (car def) filename)) + (setq disposition (cdr def)))) + ((consp (cdr def)) + (when (string= (car (setq types (split-string type "/"))) + (car def)) + (setq type (cadr types) + types (cdr def)) + (while (and (not disposition) types) + (setq def (pop types)) + (when (or (eq (car def) t) (string= type (car def))) + (setq disposition (cdr def)))))) + (t + (when (or (eq (car def) t) (string= type (car def))) + (setq disposition (cdr def)))))) + disposition)) + (defun mml-insert-mime-headers (cont type charset encoding flowed) (let (parameters id disposition description) (setq parameters @@ -697,7 +766,9 @@ cont mml-content-disposition-parameters)) (when (or (setq disposition (cdr (assq 'disposition cont))) parameters) - (insert "Content-Disposition: " (or disposition "inline")) + (insert "Content-Disposition: " + (or disposition + (mml-content-disposition type (cdr (assq 'filename cont))))) (when parameters (mml-insert-parameter-string cont mml-content-disposition-parameters)) @@ -1056,16 +1127,13 @@ (setq description nil)) description)) -(defun mml-minibuffer-read-disposition (type &optional default) - (unless default (setq default - (if (and (string-match "\\`text/" type) - (not (string-match "\\`text/rtf\\'" type))) - "inline" - "attachment"))) +(defun mml-minibuffer-read-disposition (type &optional default filename) + (unless default + (setq default (mml-content-disposition type filename))) (let ((disposition (completing-read - (format "Disposition (default %s): " default) - '(("attachment") ("inline") ("")) - nil t nil nil default))) + (format "Disposition (default %s): " default) + '(("attachment") ("inline") ("")) + nil t nil nil default))) (if (not (equal disposition "")) disposition default))) @@ -1157,7 +1225,7 @@ (let* ((file (mml-minibuffer-read-file "Attach file: ")) (type (mml-minibuffer-read-type file)) (description (mml-minibuffer-read-description)) - (disposition (mml-minibuffer-read-disposition type))) + (disposition (mml-minibuffer-read-disposition type nil file))) (list file type description disposition))) (save-excursion (unless (message-in-body-p) (goto-char (point-max))) @@ -1188,7 +1256,7 @@ (when (memq 'description mml-dnd-attach-options) (setq description (mml-minibuffer-read-description))) (when (memq 'disposition mml-dnd-attach-options) - (setq disposition (mml-minibuffer-read-disposition type))) + (setq disposition (mml-minibuffer-read-disposition type nil file))) (mml-attach-file file type description disposition))))) (defun mml-attach-buffer (buffer &optional type description) ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default mime for attaching files 2007-02-19 12:22 ` Katsumi Yamaoka @ 2007-02-19 19:49 ` Reiner Steib 2007-02-19 23:27 ` Katsumi Yamaoka 0 siblings, 1 reply; 11+ messages in thread From: Reiner Steib @ 2007-02-19 19:49 UTC (permalink / raw) To: ding On Mon, Feb 19 2007, Katsumi Yamaoka wrote: > mml-content-disposition-alist is a variable defined in `mml.el'. [...] > Documentation: > Alist of MIME types or regexps matching file names and default dispositions. > Each element should be one of the following three forms: > > (REGEXP . DISPOSITION) > (TYPE (SUBTYPE . DISPOSITION) (SUBTYPE . DISPOSITION)...) > (TYPE . DISPOSITION) > > Where REGEXP is a string which matches the file name (if any) of an > attachment, TYPE is a MIME type and SUBTYPE is a MIME subtype of an > attachment, and DISPOSITION should be either "attachment" or "inline". > The value t for TYPE or SUBTYPE matches any MIME types or MIME > subtypes. The first match found will be used. Nice. Bye, Reiner. -- ,,, (o o) ---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default mime for attaching files 2007-02-19 19:49 ` Reiner Steib @ 2007-02-19 23:27 ` Katsumi Yamaoka 2007-02-19 23:49 ` Sebastian P. Luque 0 siblings, 1 reply; 11+ messages in thread From: Katsumi Yamaoka @ 2007-02-19 23:27 UTC (permalink / raw) To: ding >>>>> In <v9k5yedj2q.fsf@marauder.physik.uni-ulm.de> >>>>> Reiner Steib wrote: > On Mon, Feb 19 2007, Katsumi Yamaoka wrote: >> mml-content-disposition-alist is a variable defined in `mml.el'. > [...] >> Documentation: >> Alist of MIME types or regexps matching file names and default dispositions. [...] > Nice. Thanks. I've committed it (with a slight fix) in the trunk. Sebastian, it will probably be the best way to specify the default disposition of *.csv files to "attachment" if they are categorized into some text/* type which is considered human readable. > (add-to-list 'mml-content-disposition-alist > '("\\.csv\\'" . "attachment")) ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: default mime for attaching files 2007-02-19 23:27 ` Katsumi Yamaoka @ 2007-02-19 23:49 ` Sebastian P. Luque 0 siblings, 0 replies; 11+ messages in thread From: Sebastian P. Luque @ 2007-02-19 23:49 UTC (permalink / raw) To: ding On Tue, 20 Feb 2007 08:27:45 +0900, Katsumi Yamaoka <yamaoka@jpl.org> wrote: [...] > Thanks. I've committed it (with a slight fix) in the trunk. Sebastian, > it will probably be the best way to specify the default disposition of > *.csv files to "attachment" if they are categorized into some text/* > type which is considered human readable. Yes, I would agree with Miles in that whenever I attach some text/whatever file I really mean "attachment" disposition, with only some exceptions. mml-content-disposition-alist is neat! Thanks, -- Seb ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-02-19 23:49 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2007-02-09 0:52 default mime for attaching files Sebastian P. Luque 2007-02-09 2:00 ` Katsumi Yamaoka 2007-02-09 5:22 ` Sebastian P. Luque 2007-02-09 5:47 ` Katsumi Yamaoka 2007-02-17 23:46 ` Sebastian P. Luque 2007-02-18 0:34 ` Katsumi Yamaoka 2007-02-18 3:32 ` Miles Bader 2007-02-19 12:22 ` Katsumi Yamaoka 2007-02-19 19:49 ` Reiner Steib 2007-02-19 23:27 ` Katsumi Yamaoka 2007-02-19 23:49 ` Sebastian P. Luque
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).