mailcap
=======
As specified by RFC 1524, MIME-aware message handlers parse
"mailcap" files from a default list, which can be overridden by the
`MAILCAP' environment variable. These describe how elements are
supposed to be displayed. Here's an example file:
image/*; gimp -8 %s
audio/wav; wavplayer %s
This says that all image files should be displayed with `gimp', and
that WAVE audio files should be played by `wavplayer'.
The `mailcap' library parses such files, and provides functions for
matching types.
- Variable: mailcap-mime-data
This variable is an alist of alists containing backup viewing
rules for MIME types. These are overridden by rules for a type
found in mailcap files. The outer alist is keyed on the major
content-type and the inner alists are keyed on the minor
content-type (which can be a regular expression).
For example:
(("application"
("octet-stream"
(viewer . mailcap-save-binary-file)
(non-viewer . t)
(type . "application/octet-stream"))
("plain"
(viewer . view-mode)
(test fboundp 'view-mode)
(type . "text/plain")))
- User Option: mailcap-default-mime-data
This variable is the default value of `mailcap-mime-data'. It
exists to allow setting the value using Custom. It is merged with
values from mailcap files by `mailcap-parse-mailcaps'.
Although it is not specified by the RFC, MIME tools normally use a
common means of associating file extensions with defualt MIME types in
the absence of other information about the type of a file. The
information is found in per-user files `~/.mime.types' and system
`mime.types' files found in quasi-standard places. Here is an example:
application/x-dvi dvi
audio/mpeg mpga mpega mp2 mp3
image/jpeg jpeg jpg jpe
- Variable: mailcap-mime-extensions
This variable is an alist MIME types keyed by file extensions.
This is overridden by entries found in `mime.types' files.
- User Option: mailcap-default-mime-extensions
This variable is the default value of `mailcap-mime-extensions'.
It exists to allow setting the value using Custom. It is merged
with values from mailcap files by `mailcap-parse-mimetypes'.
Interface functions:
- Function: mailcap-parse-mailcaps &optional path force
Parse all the mailcap files specified in a path string PATH and
merge them with the values from `mailcap-mime-data'. Components of
PATH are separated by the `path-separator' character appropriate
for the system. If FORCE is non-`nil', the files are re-parsed
even if they have been parsed already. If PATH is omitted, use
the value of environment variable `MAILCAPS' if it is set;
otherwise (on GNU and Unix) use the path defined in RFC 1524, plus
`/usr/local/etc/mailcap'.
- Function: mailcap-parse-mimetypes &optional path force
Parse all the mimetypes specified in a path string PATH and merge
them with the values from `mailcap-mime-extensions'. Components
of PATH are separated by the `path-separator' character
appropriate for the system. If PATH is omitted, use the value of
environment variable `MIMETYPES' if set; otherwise use a default
path consistent with that used by `mailcap-parse-mailcaps'. If
FORCE is non-`nil', the files are re-parsed even if they have been
parsed already.
- Function: mailcap-mime-info string &optional request
Gets the viewer command for content-type STRING. `nil' is
returned if none is found. Expects STRING to be a complete
content-type header line.
If REQUEST is non-`nil' it specifies what information to return.
If it is nil or the empty string, the viewer (second field of the
mailcap entry) will be returned. If it is a string, then the
mailcap field corresponding to that string will be returned
(`print', `description', whatever). If it is a number, all the
information for this viewer is returned. If it is `all', then all
possible viewers for this type is returned.
- Function: mailcap-mime-types
This function returns a list of all the defined media types.
- Function: mailcap-extension-to-mime extension
This function returns the content type defined for a file with the
given EXTENSION.