If the variable vm-display-using-mime
is non-nil
VM will display
messages using Multipurpose Internet Mail Extensions (MIME). MIME
is a set of extensions to the standard Internet message format that
allows reliable transmission of arbitrary data including
images, audio and video, as well as ordinary text. A non-nil
value for
this variable means that VM will recognize MIME encoded messages and
display them as specified by the various MIME standards specifications.
A nil value means VM will display MIME messages as plain text messages.
At its most basic MIME is a set of transfer encodings used to ensure
error free transport, and a set of content types. VM understands the
two standard MIME transport encodings, Quoted-Printable and BASE64, and
will decode messages that use them as necessary. VM also will
try to recognize and decode messages using the UNIX ``uuencode''
encoding system. While this is not an official MIME transfer
encoding and never will be, enough old mailers still use it
that it is worthwile to attempt to decode it.
VM has Emacs-Lisp based Quoted-Printable and BASE64 encoders and
decoders, but you can have VM use external programs to peform
these tasks and the process will almost certainly be faster.
The variables vm-mime-qp-decoder-program
,
vm-mime-qp-decoder-switches
,
vm-mime-qp-encoder-program
,
vm-mime-qp-encoder-switches
,
vm-mime-base64-decoder-switches
,
vm-mime-base64-encoder-switches
,
vm-mime-base64-decoder-program
,
vm-mime-base64-encoder-program
,
tell VM which programs to use
and what command line switches to pass to them. There are C
programs at VM's distribution sites on the Internet to handle BASE64
and Quoted-Printable. VM does not have a builtin ``uuencode''
decoder, so vm-mime-uuencode-decoder-program
must be set
non-nil
for VM to decode uuencoded MIME objects.
By default VM will display as many content types as possible within Emacs. For FSF Emacs version 19.34 this means textual types only. If you're using XEmacs, images and audio are also supported if support for images and audio has been compiled in. Types that cannot be displayed internally within Emacs can be displayed using an external viewer.
The first step in displaying a MIME message is decoding it to
determine what object types it contains. The variable
vm-auto-decode-mime-messages
controls when this happens.
A value of t
means VM should decode the message as soon as
the message body is exposed, or during previewing if
vm-mime-decode-for-preview
is also set non-nil
. A
nil
value means wait until decoding is explicitly
requested. Type D (vm-decode-mime-message
) to
manually initiate MIME decoding.
After decoding you will see either the decoded MIME objects or
button lines that must be activated to attempt display of the
MIME object. The variable
vm-auto-displayed-mime-content-types
specifies the types
that are displayed immediately. Its value should be a list of
MIME content types that should be displayed immediately after
decoding. Other types will be displayed as a button that you
must activate to display the object. To activate a button,
either click the middle mouse button over it, or move the cursor
to the line and press RET. If you are running under a window
system, you can use the right mouse button over an MIME button to
display a menu of actions you can take on the MIME object. If
you prefer using keyboard commands, you can save the MIME object
with $ s, print it with $ p, or pipe it to a shell
command with $ |. If you want to display the object with
its characters displayed using Emacs' default face, use $ RET.
To display the object using an external viewer, type $ e.
Sometimes MIME objects are large and you may not want to save
them along with the message that contains them. If so, use
$ d (vm-delete-mime-object
while the cursor is on
the MIME button. The object will be deleted and replaced with
an object that indicated what the old object was and the fact
that it is gone. This is not an undoable operation, so use this
command with care. If you inadvertently delete an object, the
only way to get it back is to quit visiting the current folder
without saving and then revisit the folder. This works because
the object isn't removed from the disk copy of the folder until
you save the folder. By default VM will ask if you're sure
about deleting an object before doing the deletion. You can
make VM not ask this question by setting
vm-mime-confirm-delete
to nil
.
A value of t for vm-auto-displayed-mime-content-types
means that
all types should be displayed immediately. A nil value means
never display MIME objects immediately; only use buttons. If
the value of vm-auto-displayed-mime-content-types
is a list, it
should be a list of strings, which should all be MIME types or
type/subtype pairs. Example:
(setq vm-auto-displayed-mime-content-types '("text" "image/jpeg"))
If a top-level type is listed without a subtype, all subtypes of that type are assumed to be included. The example above specifies that all text types are displayed immediately, but only JPEG images are displayed this way.
The variable vm-auto-displayed-mime-content-type-exceptions
should be a list of MIME content types that should not be
displayed immediately after decoding. This variable acts as
an exception list for vm-auto-displayed-mime-content-types
;
all types listed there will be auto-displayed except those in
the exception list.
The value of vm-auto-displayed-mime-content-type-exceptions
should be either nil or a list of strings. The strings should
all be types or type/subtype pairs. Example:
(setq vm-auto-displayed-mime-content-type-exceptions '("text/html"))
Again, if a top-level type is listed without a subtype, all subtypes of that type are assumed to be included.
The variable vm-mime-internal-content-types
specifies
which types should be displayed internally within Emacs. Like
vm-auto-displayed-mime-content-types
its value should be a
list of MIME content types. A value of t means that VM
should always display an object internally if possible. VM
knows which object types can be displayed internally, so you
can specify the types you want without worrying about errors
if Emacs can't handle them. A nil
value means never
display MIME objects internally, which means VM will have to
run an external viewer to display all MIME objects.
If the value is a list, it should be a list of strings. Example:
(setq vm-mime-internal-content-types '("text" "image/jpeg"))
If a top-level type is listed without a subtype, all subtypes of that type are assumed to be included. Note that multipart types are always handled internally regardless of the setting of this variable.
The variable vm-mime-internal-content-type-exceptions
serves as
the exception list for vm-mime-internal-content-types
. Its value
should be a list of types that should not be displayed internally.
For types that you want displayed externally, set the value
of vm-mime-external-content-types-alist
to specify external
viewers for the types. The value of this variable should be an
associative list of MIME content types and the external programs
used to display them. If VM cannot display a type internally or
a type is not listed in vm-mime-internal-content-types
VM will
try to launch an external program to display that type.
The alist format is a list of lists, each sublist having the form
(TYPE PROGRAM ARG ARG ... )
or
(TYPE COMMAND-LINE)
TYPE is a string specifying a MIME type or type/subtype pair. For example ``text'' or ``image/jpeg''. If a top-level type is listed without a subtype, all subtypes of that type are assumed to be included.
In the first form, PROGRAM is a string naming a program to
run to display an object. Any ARGs will be passed to the
program as arguments. The octets that compose the object will be
written into a temporary file and the name of the file can be
inserted into an ARG string by writing `%f
' in the
ARG string. In earlier versions of VM the filename was
always added as the last argument; as of VM 6.49 this is only done
if `%f
' does not appear in any of the ARG strings.
If the COMMAND-LINE form is used, the program and its
arguments are specified as a single string and that string is
passed to the shell ("sh -c" typically) for execution. Since
the command line will be passed to the shell, you can use shell
variables and input/output redirection if needed. As with the
PROGRAM/ARGS form, the name of the temporary file that
contains the MIME object will be appended to the command line if
`%f
' does not appear in the command line string.
In either the PROGRAM/ARG or COMMAND-LINE forms, all the
program and argument strings will have any %-specifiers in
them expanded as described in the documentation for the
variable vm-mime-button-format-alist
. The only difference
is that `%f
' refers to the temporary file VM creates to store
the object to be displayed, not the filename that the sender
may have associated with the attachment.
Example:
(setq vm-mime-external-content-types-alist '( ("text/html" "netscape") ("image/gif" "xv") ("image/jpeg" "xv") ("video/mpeg" "mpeg_play") ("video" "xanim") ) )
The first matching list element will be used.
No multipart message will ever be sent to an external viewer.
External viewer processes are normally killed when you select a
a new message in the current folder. If you want viewer
processes to not be killed, set
vm-mime-delete-viewer-processes
to a non-nil
value.
Any type that cannot be displayed internally or externally will be displayed as a button that allows you to save the body to a file.
As with the internal type list, there is an exception list that
you can use to specify types that you do not want displayed
externally. When VM is considering whether it should
automatically launch an external viewer, it will consult the
variable vm-mime-external-content-type-exceptions
. If the
type to be displayed is listed, VM will not launch a viewer.
This allows you to setup viewers for types that ordinarily you
would not want VM to display or for types that you norally want
to convert to some other type using vm-mime-type-converter-alist
.
You can still display such a type with anexternal viewer by using
$ e.
For text type messages, MIME also requires that a character set be specified, so that the recipient's mail reader knows what character glyphs to use to display each character code. To display a message properly VM needs to know how to choose a font for a given character set.
The variable vm-mime-default-face-charsets
tells VM what character
sets your default face can display. For most American and European
users using X windows, Emacs' default face displays the ISO-8859-1
and US-ASCII characters, US-ASCII being a subset of ISO-8859-1. The
value of vm-mime-default-face-charsets
must be a list of strings
specifying the character sets that your default face can display.
This variable is useful for making bogus, unregistered character sets
that are slight variants of US-ASCII and ISO-8859-1 visible.
Example:
(add-to-list 'vm-mime-default-face-charsets "Windows-1251") (add-to-list 'vm-mime-default-face-charsets "Windows-1252") (add-to-list 'vm-mime-default-face-charsets "Windows-1257")
Messages sent using such character sets would normally be considered undisplayable by VM, and a button would be displayed that offers to save the message body to a file.
The variable vm-mime-charset-font-alist
tells VM what font to use
to display a character set that cannot be displayed using
the default face. The value of this variable should be an
assoc list of character sets and fonts that can be used to display
them. The format of the list is:
( (CHARSET . FONT) ...)
CHARSET is a string naming a MIME registered character set such
as `"iso-8859-5"
'.
FONT is a string naming a font that can be used to display CHARSET.
An example setup might be:
(setq vm-mime-charset-font-alist '( ("iso-8859-7" . "-*-*-medium-r-normal-*-16-160-72-72-c-80-iso8859-7") ) )
This variable is only useful for character sets whose characters can all be encoded in single 8-bit bytes. Also multiple fonts can only be displayed if you're running under a window system e.g. X windows. So this variable will have no effect if you're running Emacs on a tty.
Note that under FSF Emacs 20.4 and any earlier Emacs release, any fonts you use must be the same height as your default font. XEmacs does not have this limitation.
MIME allows a message to be sent with its content encoded in multiple formats, simultaneously, in the same message. Such message have a content type of multipart/alternative. The idea is that the sender might have different MIME decoding or display capabilities than some of his recipients. For instance, the sender may be able to compose a message using fancy text formatting constructs like tables, italics and equations but some of the recipients may only be able to display plain text. The multipart/alternative type message is the solution to this dilemma. Such a message would contain at least two text subparts, one in plaintext and the other in the full featured text formatting language that the sender used.
To control how VM displays multipart/alternative messages, you must
set the variable vm-mime-alternative-select-method
. Its value must be
a symbol. A value of best
tells VM to display the message
using the subpart closest in appearance to what the sender used to
compose the message. In the example above this would mean displaying
the fully featured text subpart, if VM knows how to display that type.
VM will display the type using either internally or externally. A
value of best-internal
tells VM to use the closest subpart that
it can display internally. External viewers won't be used in this
case.
Some mailers incorrectly use the generic
`application/octet-stream
' type when sending files that
really have a specific MIME type. For example, a JPEG image
might be sent using `application/octet-stream
' type instead
of `image/jpeg
', which would be the correct type. In many
cases the filename sent along with the mistyped file
(e.g. `foo.jpg
') suggests the correct type. If the variable
vm-infer-mime-types
is set non-nil
, VM will attempt to use
the filename sent with a MIME attachment to guess an attachment's
type if the attachment is of type `application/octet-stream
'.