[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter deals with decoding and viewing MIME messages on a higher level.
The main idea is to first analyze a MIME article, and then allow other programs to do things based on the list of handles that are returned as a result of this analysis.
1.1 Dissection | Analyzing a MIME message. | |
1.2 Non-MIME | Analyzing a non-MIME message. | |
1.3 Handles | Handle manipulations. | |
1.4 Display | Displaying handles. | |
1.5 Display Customization | Variables that affect display. | |
1.6 Files and Directories | Saving and naming attachments. | |
1.7 New Viewers | How to write your own viewers. |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The mm-dissect-buffer
is the function responsible for dissecting
a MIME article. If given a multipart message, it will recursively
descend the message, following the structure, and return a tree of
MIME handles that describes the structure of the message.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Gnus also understands some non-MIME attachments, such as
postscript, uuencode, binhex, yenc, shar, forward, gnatsweb, pgp,
diff. Each of these features can be disabled by add an item into
mm-uu-configure-list
. For example,
(require 'mm-uu) (add-to-list 'mm-uu-configure-list '(pgp-signed . disabled)) |
postscript
uu
binhex
yenc
shar
forward
gnatsweb
pgp-signed
pgp-encrypted
pgp-key
emacs-sources
mm-uu-emacs-sources-regexp
.
diff
mm-uu-diff-groups-regexp
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A MIME handle is a list that fully describes a MIME component.
The following macros can be used to access elements in a handle:
mm-handle-buffer
mm-handle-type
Content-Type
of the part.
mm-handle-encoding
Content-Transfer-Encoding
of the part.
mm-handle-undisplayer
mm-handle-set-undisplayer
mm-handle-disposition
Content-Disposition
of the part.
mm-get-content-id
Content-ID
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Functions for displaying, removing and saving.
mm-display-part
mm-remove-part
mm-inlinable-p
mm-automatic-display-p
mm-destroy-part
mm-save-part
mm-pipe-part
mm-interactively-view-part
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
mm-inline-media-tests
eval
ed to say whether the part
can be displayed inline.
This variable specifies whether a part can be displayed inline, and, if so, how to do it. It does not say whether parts are actually displayed inline.
mm-inlined-types
mm-automatic-display
mm-automatic-external-display
mm-keep-viewer-alive-types
mm-attachment-override-types
mm-discouraged-alternatives
(setq mm-discouraged-alternatives '("text/html" "text/richtext") mm-automatic-display (remove "text/html" mm-automatic-display)) |
Adding "image/.*"
might also be useful. Spammers use images as
the prefered part of `multipart/alternative' messages, so you might
not notice there are other parts. See also
gnus-buttonized-mime-types
, section `MIME Commands' in Gnus Manual. After adding "multipart/alternative"
to
gnus-buttonized-mime-types
you can choose manually which
alternative you'd like to view. For example, you can set those
variables like:
(setq gnus-buttonized-mime-types '("multipart/alternative" "multipart/signed") mm-discouraged-alternatives '("text/html" "image/.*")) |
In this case, Gnus will display radio buttons for such a kind of spam message as follows:
1. (*) multipart/alternative ( ) image/gif 2. (*) text/plain ( ) text/html |
mm-inline-large-images
t
disables this check and
makes the library display all inline images as inline, regardless of
their size.
mm-inline-override-types
mm-inlined-types
may include regular expressions, for example to
specify that all `text/.*' parts be displayed inline. If a user
prefers to have a type that matches such a regular expression be treated
as an attachment, that can be accomplished by setting this variable to a
list containing that type. For example assuming mm-inlined-types
includes `text/.*', then including `text/html' in this
variable will cause `text/html' parts to be treated as attachments.
mm-text-html-renderer
w3
,
w3m
(1), links
, lynx
,
w3m-standalone
or html2text
. If nil
use an
external viewer. You can also specify a function, which will be
called with a MIME handle as the argument.
mm-inline-text-html-with-images
nil
(which is the default).
It is currently ignored by Emacs/w3. For emacs-w3m, you may use the
command t on the image anchor to show an image even if it is
nil
.(2)
mm-w3m-safe-url-regexp
nil
consider
all URLs safe.
mm-inline-text-html-with-w3m-keymap
nil
. The default value is t
.
mm-external-terminal-program
mm-enable-external
If t
, all defined external MIME handlers are used. If
nil
, files are saved to disk (mailcap-save-binary-file
).
If it is the symbol ask
, you are prompted before the external
MIME handler is invoked.
When you launch an attachment through mailcap (see section 4.12 mailcap) an
attempt is made to use a safe viewer with the safest options--this isn't
the case if you save it to disk and launch it in a different way
(command line or double-clicking). Anyhow, if you want to be sure not
to launch any external programs, set this variable to nil
or
ask
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
mm-default-directory
nil
use
default-directory
.
mm-tmp-directory
mm-file-name-rewrite-functions
mm-file-name-delete-control
mm-file-name-delete-gotchas
mm-file-name-delete-whitespace
mm-file-name-trim-whitespace
mm-file-name-collapse-whitespace
mm-file-name-replace-whitespace
mm-file-name-replace-whitespace
to any other string if you do
not like underscores.
The standard Emacs functions capitalize
, downcase
,
upcase
and upcase-initials
might also prove useful.
mm-path-name-rewrite-functions
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here's an example viewer for displaying text/enriched
inline:
(defun mm-display-enriched-inline (handle) (let (text) (with-temp-buffer (mm-insert-part handle) (save-window-excursion (enriched-decode (point-min) (point-max)) (setq text (buffer-string)))) (mm-insert-inline handle text))) |
We see that the function takes a MIME handle as its parameter. It then goes to a temporary buffer, inserts the text of the part, does some work on the text, stores the result, goes back to the buffer it was called from and inserts the result.
The two important helper functions here are mm-insert-part
and
mm-insert-inline
. The first function inserts the text of the
handle in the current buffer. It handles charset and/or content
transfer decoding. The second function just inserts whatever text you
tell it to insert, but it also sets things up so that the text can be
"undisplayed" in a convenient manner.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by XEmacs shared group account on December, 19 2009
using texi2html 1.65.