3 @setfilename emacs-mime-ja
4 @settitle Emacs MIME Manual
10 \e$B$3$N%U%!%$%k$O
\e(B Emacs MIME
\e$B%$%s%?!<%U%'!<%9$N5!G=$rJ8=q2=$7$?$b$N$G$9!#
\e(B
12 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
13 Free Software Foundation, Inc.
16 Permission is granted to copy, distribute and/or modify this document
17 under the terms of the GNU Free Documentation License, Version 1.1 or
18 any later version published by the Free Software Foundation; with no
19 Invariant Sections, with the Front-Cover texts being ``A GNU
20 Manual'', and with the Back-Cover Texts as in (a) below. A copy of the
21 license is included in the section entitled ``GNU Free Documentation
22 License'' in the Emacs manual.
24 \e$B$3$NJ8=q$r!"%U%j!<%=%U%H%&%'%":bCDH/9T$N
\e(B GNU
\e$B%U%j!<J8=qMxMQ5vBz7@Ls=q
\e(B
25 \e$BBh
\e(B 1.1
\e$BHG$^$?$O$=$l0J9_$NHG$,Dj$a$k>r7o$N2<$GJ#@=!"G[I[!"$"$k$$$OJQ99$9
\e(B
26 \e$B$k$3$H$r5v2D$7$^$9!#JQ99IT2DItJ,$O;XDj$7$^$;$s!#!V
\e(BA GNU Manual
\e$B!W$OI=I=;f
\e(B
27 \e$B%F%-%9%H!"0J2<$N
\e(B (a)
\e$B$ON"I=;f%F%-%9%H$G$9!#$3$NMxMQ5vBz7@Ls=q$NJ#<L$O
\e(B
28 \e$B!V
\e(BEmacs manual
\e$B!W$N!V
\e(BGNU
\e$B%U%j!<J8=qMxMQ5vBz7@Ls=q!W$H$$$&>O$K4^$^$l$F$$$^
\e(B
31 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
32 this GNU Manual, like GNU software. Copies published by the Free
33 Software Foundation raise funds for GNU development.''
35 (a) FSF
\e$B$NN"I=;f%F%-%9%H
\e(B:
\e$B!V$"$J$?$K$O$3$N
\e(B GNU Manual
\e$B$r
\e(B GNU
\e$B%=%U%H%&%'%"
\e(B
36 \e$B$N$h$&$KJ#@=$7$?$jJQ99$9$k<+M3$,$"$j$^$9!#J#@=$O%U%j!<%=%U%H%&%'%":bCD$K
\e(B
37 \e$B$h$C$F=PHG$5$l$^$7$?!#
\e(B(
\e$B%U%j!<%=%U%H%&%'%":bCD$O
\e(B) GNU
\e$B$N3+H/$N$?$a$KI,MW
\e(B
38 \e$B$J;q6b$r=8$a$F$$$^$9!#!W
\e(B
40 This document is part of a collection distributed under the GNU Free
41 Documentation License. If you want to distribute this document
42 separately from the collection, you can do so by adding a copy of the
43 license to the document, as described in section 6 of the license.
45 \e$B$3$NJ8=q$O!V
\e(BGNU
\e$B%U%j!<J8=qMxMQ5vBz7@Ls=q!W$K4p$E$$$FG[I[$5$l$?<}=8Cx:nJ*
\e(B
46 \e$B$N0lIt$G$9!#$b$7$"$J$?$,$3$NJ8=q$r<}=8Cx:nJ*$+$iJ,N%$7$FG[I[$7$?$$$H$-$O!"
\e(B
47 \e$B7@Ls=q$NBh
\e(B 6
\e$B9`$K5-=R$5$l$F$$$k$h$&$K!"J8=q$K7@Ls=q$NJ#<L$rIU2C$9$k$3$H
\e(B
48 \e$B$K$h$C$F!"9T$J$&$3$H$,$G$-$^$9!#
\e(B
54 * Emacs MIME-ja: (emacs-mime-ja). Emacs MIME de/composition library (Japanese).
59 @setchapternewpage odd
62 @title Emacs MIME Manual
64 @author by Lars Magne Ingebrigtsen
66 @vskip 0pt plus 1filll
73 \e$B$3$N%^%K%e%"%k$O
\e(B @acronym{MIME}
\e$B%a%C%;!<%8$NI=<($H:n@.$K;H$o$l$k%i%$%V%i
\e(B
74 \e$B%j!<$rJ8=q2=$7$?$b$N$G$9!#
\e(B
76 \e$B$3$N%^%K%e%"%k$O!"
\e(B@acronym{MIME}
\e$B$N%(%s%3!<%I
\e(B/
\e$B%G%3!<%I!&%W%m%;%9$N?6$kIq
\e(B
77 \e$B$$$rJQ99$7$?$$$+!"
\e(BEmacs @acronym{MIME}
\e$B%i%$%V%i%j!<$,$I$N$h$&$KF0:n$9$k
\e(B
78 \e$B$+$N$b$C$H>\:Y$JIA<L$rK>$`%f!<%6!"$*$h$S
\e(B @acronym{MIME}
\e$B$NMWAG$rA`:n$9$k
\e(B
79 \e$B4X?t$*$h$S%3%^%s%I$r=q$-$?$$?M$?$A$rBP>]$K$7$F$$$^$9!#
\e(B
81 @acronym{MIME}
\e$B$O
\e(B @dfn{Multipurpose Internet Mail Extensions}
\e$B$N>JN,I=5-
\e(B
82 \e$B$G$9!#$3$NI8=`$OB??t$N
\e(B RFC
\e$B$KJ8=q2=$5$l$F$$$F!"<g$J$b$N$O<!$NDL$j$G$9
\e(B:
83 RFC2045 (
\e$B%$%s%?!<%M%C%H!&%a%C%;!<%8K\J8$N=q<0
\e(B), RFC2046 (
\e$B%a%G%#%"%?%$%W
\e(B),
84 RFC2047 (
\e$B%a%C%;!<%8%X%C%@!<$NHs
\e(B-@acronym{ASCII}
\e$B%F%-%9%H3HD%
\e(B),
85 RFC2048 (
\e$BEPO?<jB3
\e(B), RFC2049 (
\e$BE,9g4p=`$H;vNc
\e(B)
\e$B!#
\e(B@acronym{MIME}
\e$B$K=`5r$7$?
\e(B
86 \e$B%=%U%H%&%'%"$r=q$3$&$H;W$C$F$$$k?M$OC/$G$b!">/$J$/$H
\e(B
87 \e$B$b
\e(B RFC2045
\e$B$H
\e(B RFC2047
\e$B$OFI$s$G$*$/$3$H$r6/$/4+$a$^$9!#
\e(B
90 * Decoding and Viewing::
\e$B%G%3!<%I$HI=<($N$?$a$NOHAH$_
\e(B
91 * Composing:: @acronym{MML}; @acronym{MIME}
\e$B%Q!<%H5-=RMQ8@8l
\e(B
92 * Interface Functions::
\e$B4pK\E*$J4X?t$K4X$9$kCj>]35G0
\e(B
93 * Basic Functions::
\e$B%f!<%F%#%j%F%#!<$*$h$S4pK\E*$J2r@O$N$?$a$N4X?t
\e(B
94 * Standards::
\e$B;H$o$l$F$$$k
\e(B RFC
\e$B$H:n6HJ8=q$N35N,
\e(B
95 * Index::
\e$B4X?t$*$h$SJQ?t$N:w0z
\e(B
98 @node Decoding and Viewing
99 @chapter
\e$B%G%3!<%I$HI=<(
\e(B
101 \e$B$3$N>O$O!">e0L3,AX$G$N
\e(B @acronym{MIME}
\e$B%a%C%;!<%8$N%G%3!<%I$HI=<($r07$$$^
\e(B
104 \e$B$=$N<g$JL\E*$O!":G=i$K
\e(B @acronym{MIME}
\e$B$N5-;v$r2r@O$7!"<!$K$=$N2r@O$N7k2L
\e(B
105 \e$BJV$5$l$k!V
\e(B@dfn{
\e$B%O%s%I%k
\e(B}
\e$B!W
\e(B
\e$B$N%j%9%H$K4p$E$$$F!"B>$N%W%m%0%i%`$,J*;v$r9T
\e(B
106 \e$B$J$&$3$H$r2DG=$K$9$k$3$H$G$9!#
\e(B
109 * Dissection:: @acronym{MIME}
\e$B%a%C%;!<%8$N2r@O
\e(B
110 * Non-MIME::
\e$BHs
\e(B-@acronym{MIME}
\e$B%a%C%;!<%8$N2r@O
\e(B
111 * Handles::
\e$B%O%s%I%k$N<h$j07$$
\e(B
112 * Display::
\e$B%O%s%I%k$NI=<(
\e(B
113 * Display Customization::
\e$BI=<($K1F6A$9$kJQ?t
\e(B
114 * Files and Directories::
\e$BE:IU$NJ]B8$HL?L>
\e(B
115 * New Viewers::
\e$B<+J,MQ%S%e!<%o!<$N=q$-J}
\e(B
119 @section
\e$B2rBN
\e(B
121 @code{mm-dissect-buffer}
\e$B$O
\e(B @acronym{MIME}
\e$B5-;v$N2rBN$rC4Ev$9$k4X?t$G$9!#
\e(B
122 \e$B%^%k%A%Q!<%H$N%a%C%;!<%8$,M?$($i$l$k$H!"%a%C%;!<%8$r:F5"E*$K7!$j2<$2!"9=
\e(B
123 \e$BB$$K=>$C$F!"$=$N%a%C%;!<%8$N9=B$$rIA<L$9$k
\e(B @acronym{MIME}
\e$B%O%s%I%k$NLZ9=
\e(B
124 \e$BB$$rJV$7$^$9!#
\e(B
127 @section
\e$BHs
\e(B-MIME
128 @vindex mm-uu-configure-list
130 Gnus
\e$B$O$$$/$D$+$NHs
\e(B-@acronym{MIME}
\e$B$NE:IU$bM}2r$7$^$9!#$=$l$i
\e(B
131 \e$B$O
\e(B postscript, uuencode, binhex, yenc, shar, forward, gnatsweb, pgp,
132 diff
\e$B$N$h$&$J$b$N$G$9!#$=$l$>$l$N5!G=$O
\e(B @code{mm-uu-configure-list}
\e$B$K9`
\e(B
133 \e$BL\$rDI2C$9$k$3$H$K$h$C$F!"L58z$K$9$k$3$H$,$G$-$^$9!#Nc$G$9!#
\e(B
137 (add-to-list 'mm-uu-configure-list '(pgp-signed . disabled))
143 \e$B%]%9%H%9%/%j%W%H$N%U%!%$%k!#
\e(B
147 Uuencode
\e$B$5$l$?%U%!%$%k!#
\e(B
151 Binhex
\e$B$G%(%s%3!<%I$5$l$?%U%!%$%k!#
\e(B
155 Yenc
\e$B$G%(%s%3!<%I$5$l$?%U%!%$%k!#
\e(B
159 Shar
\e$B=q8K%U%!%$%k!#
\e(B
163 \e$BHs
\e(B-@acronym{MIME}
\e$B$GE>Aw$5$l$?%a%C%;!<%8!#
\e(B
167 Gnatsweb
\e$B$NE:IU!#
\e(B
171 @acronym{PGP}
\e$B$G=pL>$5$l$?J?J8
\e(B (clear text)
\e$B!#
\e(B
174 @findex pgp-encrypted
175 @acronym{PGP}
\e$B$G0E9f2=$5$l$?J?J8
\e(B (clear text)
\e$B!#
\e(B
179 @acronym{PGP}
\e$B$N8x3+80!#
\e(B
182 @findex emacs-sources
183 @vindex mm-uu-emacs-sources-regexp
184 Emacs
\e$B$N%=!<%9%3!<%I!#$3$N9`L\$O
\e(B @code{mm-uu-emacs-sources-regexp}
\e$B$K9g
\e(B
185 \e$BCW$9$k%0%k!<%W$G$N$_F0:n$7$^$9!#
\e(B
189 @vindex mm-uu-diff-groups-regexp
190 \e$B%Q%C%A!#$3$l$O!"%3%_%C%H$5$l$?%U%!%$%k$N:9J,$,<+F0E*$KAw$i$l$k%0%k!<%W$r
\e(B
191 \e$BBP>]$K$7$?$b$N$G$9!#
\e(B@code{mm-uu-diff-groups-regexp}
\e$B$K9gCW$9$k%0%k!<%W$G
\e(B
192 \e$B$N$_F0:n$7$^$9!#
\e(B
196 @section
\e$B%O%s%I%k
\e(B
198 @acronym{MIME}
\e$B%O%s%I%k$O!"
\e(B@acronym{MIME}
\e$B$N9=@.MWAG$r40A4$K5-=R$9$k%j%9
\e(B
201 \e$B%O%s%I%k$NMWAG$r%"%/%;%9$9$k$?$a$K!"0J2<$N%^%/%m$r;H$&$3$H$,$G$-$^$9
\e(B:
204 @item mm-handle-buffer
205 @findex mm-handle-buffer
206 \e$B%G%3!<%I$5$l$F$$$J$$
\e(B @acronym{MIME}
\e$B%Q!<%H$NFbMFJ*$rJ];}$7$F$$$k%P%C%U%!
\e(B
210 @findex mm-handle-type
211 \e$B2r@O:Q$_$N!"%Q!<%H$N
\e(B @code{Content-Type}
\e$B$rJV$7$^$9!#
\e(B
213 @item mm-handle-encoding
214 @findex mm-handle-encoding
215 \e$B%Q!<%H$N
\e(B @code{Content-Transfer-Encoding}
\e$B$rJV$7$^$9!#
\e(B
217 @item mm-handle-undisplayer
218 @findex mm-handle-undisplayer
219 \e$BI=<($5$l$F$$$k%Q!<%H$r>C$9$3$H$,$G$-$k$b$N
\e(B (
\e$BLuCm
\e(B:
\e$B4X?t$J$I
\e(B)
\e$B$r
\e(B (
\e$B$=$l$,I=
\e(B
220 \e$B<($5$l$F$$$k>l9g$K
\e(B)
\e$BJV$7$^$9!#
\e(B
222 @item mm-handle-set-undisplayer
223 @findex mm-handle-set-undisplayer
224 \e$BI=<($5$l$F$$$k%Q!<%H$r>C$9$3$H$,$G$-$k$b$N
\e(B (
\e$BLuCm
\e(B:
\e$B4X?t$J$I
\e(B)
\e$B$r@_Dj$7$^$9!#
\e(B
226 @item mm-handle-disposition
227 @findex mm-handle-disposition
228 \e$B2r@O:Q$_$N!"%Q!<%H$N
\e(B @code{Content-Disposition}
\e$B$rJV$7$^$9!#
\e(B
230 @item mm-get-content-id
231 @code{Content-ID}
\e$B$G;2>H$5$l$k%O%s%I%k
\e(B (
\e$BC1?t$^$?$OJ#?t
\e(B)
\e$B$rJV$7$^$9!#
\e(B
235 @section
\e$BI=<(
\e(B
237 \e$BI=<($7!">C5n$7!"J]B8$9$k$?$a$N4X?t!#
\e(B
240 @item mm-display-part
241 @findex mm-display-part
242 \e$B%Q!<%H$rI=<($7$^$9!#
\e(B
245 @findex mm-remove-part
246 \e$B%Q!<%H$r
\e(B (
\e$B$=$l$,I=<($5$l$F$$$?$i
\e(B)
\e$B>C5n$7$^$9!#
\e(B
249 @findex mm-inlinable-p
250 @acronym{MIME}
\e$B%?%$%W$,Kd$a9~$_
\e(B (inline)
\e$B2DG=$+$I$&$+$rJV$7$^$9!#
\e(B
252 @item mm-automatic-display-p
253 @findex mm-automatic-display-p
254 @acronym{MIME}
\e$B%?%$%W$,<+F0E*$KI=<($5$l$k$Y$-$+$I$&$+$rJV$7$^$9!#
\e(B
256 @item mm-destroy-part
257 @findex mm-destroy-part
258 \e$B%Q!<%H$K$h$C$F;H$o$l$F$$$k$9$Y$F$N;q8;$r3+J|$7$^$9
\e(B (
\e$BLuCm
\e(B:
\e$B%Q!<%H$NI=<(!"
\e(B
259 \e$B$*$h$S%Q!<%H$r2rBN$7$FF@$?8D!9$NItIJ$r0l;~E*$KJ];}$7$F$$$k%P%C%U%!$d%U%!
\e(B
260 \e$B%$%k$r>C5n$7$^$9
\e(B)
\e$B!#
\e(B
264 \e$B%Q!<%H$r%U%!%$%k$KJ]B8$7$^$9!#
\e(B
268 \e$B%Q!<%H$r$"$k%W%m%;%9$K%Q%$%W$7$^$9!#
\e(B
270 @item mm-interactively-view-part
271 @findex mm-interactively-view-part
272 \e$B%Q!<%H$rI=<($9$k$?$a$K;H$&
\e(B mailcap
\e$B$N<jCJ$r?R$M$^$9!#
\e(B
275 @node Display Customization
276 @section Display Customization
280 @item mm-inline-media-tests
281 @vindex mm-inline-media-tests
282 This is an alist where the key is a @acronym{MIME} type, the second element
283 is a function to display the part @dfn{inline} (i.e., inside Emacs), and
284 the third element is a form to be @code{eval}ed to say whether the part
285 can be displayed inline.
287 This variable specifies whether a part @emph{can} be displayed inline,
288 and, if so, how to do it. It does not say whether parts are
289 @emph{actually} displayed inline.
291 @item mm-inlined-types
292 @vindex mm-inlined-types
293 This, on the other hand, says what types are to be displayed inline, if
294 they satisfy the conditions set by the variable above. It's a list of
295 @acronym{MIME} media types.
297 @item mm-automatic-display
298 @vindex mm-automatic-display
299 This is a list of types that are to be displayed ``automatically'', but
300 only if the above variable allows it. That is, only inlinable parts can
301 be displayed automatically.
303 @item mm-automatic-external-display
304 @vindex mm-automatic-external-display
305 This is a list of types that will be displayed automatically in an
308 @item mm-keep-viewer-alive-types
309 @vindex mm-keep-viewer-alive-types
310 This is a list of media types for which the external viewer will not
311 be killed when selecting a different article.
313 @item mm-attachment-override-types
314 @vindex mm-attachment-override-types
315 Some @acronym{MIME} agents create parts that have a content-disposition of
316 @samp{attachment}. This variable allows overriding that disposition and
317 displaying the part inline. (Note that the disposition is only
318 overridden if we are able to, and want to, display the part inline.)
320 @item mm-discouraged-alternatives
321 @vindex mm-discouraged-alternatives
322 List of @acronym{MIME} types that are discouraged when viewing
323 @samp{multipart/alternative}. Viewing agents are supposed to view the
324 last possible part of a message, as that is supposed to be the richest.
325 However, users may prefer other types instead, and this list says what
326 types are most unwanted. If, for instance, @samp{text/html} parts are
327 very unwanted, and @samp{text/richtext} parts are somewhat unwanted,
328 you could say something like:
331 (setq mm-discouraged-alternatives
332 '("text/html" "text/richtext")
334 (remove "text/html" mm-automatic-display))
337 @item mm-inline-large-images
338 @vindex mm-inline-large-images
339 When displaying inline images that are larger than the window, Emacs
340 does not enable scrolling, which means that you cannot see the whole
341 image. To prevent this, the library tries to determine the image size
342 before displaying it inline, and if it doesn't fit the window, the
343 library will display it externally (e.g. with @samp{ImageMagick} or
344 @samp{xv}). Setting this variable to @code{t} disables this check and
345 makes the library display all inline images as inline, regardless of
348 @item mm-inline-override-types
349 @vindex mm-inline-override-types
350 @code{mm-inlined-types} may include regular expressions, for example to
351 specify that all @samp{text/.*} parts be displayed inline. If a user
352 prefers to have a type that matches such a regular expression be treated
353 as an attachment, that can be accomplished by setting this variable to a
354 list containing that type. For example assuming @code{mm-inlined-types}
355 includes @samp{text/.*}, then including @samp{text/html} in this
356 variable will cause @samp{text/html} parts to be treated as attachments.
358 @item mm-text-html-renderer
359 @vindex mm-text-html-renderer
360 This selects the function used to render @acronym{HTML}. The predefined
361 renderers are selected by the symbols @code{w3},
362 @code{w3m}@footnote{See @uref{http://emacs-w3m.namazu.org/} for more
363 information about emacs-w3m}, @code{links}, @code{lynx},
364 @code{w3m-standalone} or @code{html2text}. If @code{nil} use an
365 external viewer. You can also specify a function, which will be
366 called with a @acronym{MIME} handle as the argument.
368 @item mm-inline-text-html-with-images
369 @vindex mm-inline-text-html-with-images
370 Some @acronym{HTML} mails might have the trick of spammers using
371 @samp{<img>} tags. It is likely to be intended to verify whether you
372 have read the mail. You can prevent your personal informations from
373 leaking by setting this option to @code{nil} (which is the default).
374 It is currently ignored by Emacs/w3. For emacs-w3m, you may use the
375 command @kbd{t} on the image anchor to show an image even if it is
376 @code{nil}.@footnote{The command @kbd{T} will load all images. If you
377 have set the option @code{w3m-key-binding} to @code{info}, use @kbd{i}
380 @item mm-w3m-safe-url-regexp
381 @vindex mm-w3m-safe-url-regexp
382 A regular expression that matches safe URL names, i.e. URLs that are
383 unlikely to leak personal information when rendering @acronym{HTML}
384 email (the default value is @samp{\\`cid:}). If @code{nil} consider
387 @item mm-inline-text-html-with-w3m-keymap
388 @vindex mm-inline-text-html-with-w3m-keymap
389 You can use emacs-w3m command keys in the inlined text/html part by
390 setting this option to non-@code{nil}. The default value is @code{t}.
392 @item mm-external-terminal-program
393 @vindex mm-external-terminal-program
394 The program used to start an external terminal.
396 @item mm-enable-external
397 @vindex mm-enable-external
398 Indicate whether external @acronym{MIME} handlers should be used.
400 If @code{t}, all defined external @acronym{MIME} handlers are used. If
401 @code{nil}, files are saved to disk (@code{mailcap-save-binary-file}).
402 If it is the symbol @code{ask}, you are prompted before the external
403 @acronym{MIME} handler is invoked.
405 When you launch an attachment through mailcap (@pxref{mailcap}) an
406 attempt is made to use a safe viewer with the safest options---this isn't
407 the case if you save it to disk and launch it in a different way
408 (command line or double-clicking). Anyhow, if you want to be sure not
409 to launch any external programs, set this variable to @code{nil} or
414 @node Files and Directories
415 @section Files and Directories
419 @item mm-default-directory
420 @vindex mm-default-directory
421 The default directory for saving attachments. If @code{nil} use
422 @code{default-directory}.
424 @item mm-tmp-directory
425 @vindex mm-tmp-directory
426 Directory for storing temporary files.
428 @item mm-file-name-rewrite-functions
429 @vindex mm-file-name-rewrite-functions
430 A list of functions used for rewriting file names of @acronym{MIME}
431 parts. Each function is applied successively to the file name.
432 Ready-made functions include
435 @item mm-file-name-delete-control
436 @findex mm-file-name-delete-control
437 Delete all control characters.
439 @item mm-file-name-delete-gotchas
440 @findex mm-file-name-delete-gotchas
441 Delete characters that could have unintended consequences when used
442 with flawed shell scripts, i.e. @samp{|}, @samp{>} and @samp{<}; and
443 @samp{-}, @samp{.} as the first character.
445 @item mm-file-name-delete-whitespace
446 @findex mm-file-name-delete-whitespace
447 Remove all whitespace.
449 @item mm-file-name-trim-whitespace
450 @findex mm-file-name-trim-whitespace
451 Remove leading and trailing whitespace.
453 @item mm-file-name-collapse-whitespace
454 @findex mm-file-name-collapse-whitespace
455 Collapse multiple whitespace characters.
457 @item mm-file-name-replace-whitespace
458 @findex mm-file-name-replace-whitespace
459 @vindex mm-file-name-replace-whitespace
460 Replace whitespace with underscores. Set the variable
461 @code{mm-file-name-replace-whitespace} to any other string if you do
462 not like underscores.
465 The standard Emacs functions @code{capitalize}, @code{downcase},
466 @code{upcase} and @code{upcase-initials} might also prove useful.
468 @item mm-path-name-rewrite-functions
469 @vindex mm-path-name-rewrite-functions
470 List of functions used for rewriting the full file names of @acronym{MIME}
471 parts. This is used when viewing parts externally, and is meant for
472 transforming the absolute name so that non-compliant programs can find
473 the file where it's saved.
480 Here's an example viewer for displaying @code{text/enriched} inline:
483 (defun mm-display-enriched-inline (handle)
486 (mm-insert-part handle)
487 (save-window-excursion
488 (enriched-decode (point-min) (point-max))
489 (setq text (buffer-string))))
490 (mm-insert-inline handle text)))
493 We see that the function takes a @acronym{MIME} handle as its parameter. It
494 then goes to a temporary buffer, inserts the text of the part, does some
495 work on the text, stores the result, goes back to the buffer it was
496 called from and inserts the result.
498 The two important helper functions here are @code{mm-insert-part} and
499 @code{mm-insert-inline}. The first function inserts the text of the
500 handle in the current buffer. It handles charset and/or content
501 transfer decoding. The second function just inserts whatever text you
502 tell it to insert, but it also sets things up so that the text can be
503 ``undisplayed'' in a convenient manner.
509 @cindex MIME Composing
511 @cindex MIME Meta Language
513 Creating a @acronym{MIME} message is boring and non-trivial. Therefore,
514 a library called @code{mml} has been defined that parses a language
515 called @acronym{MML} (@acronym{MIME} Meta Language) and generates
516 @acronym{MIME} messages.
518 @findex mml-generate-mime
519 The main interface function is @code{mml-generate-mime}. It will
520 examine the contents of the current (narrowed-to) buffer and return a
521 string containing the @acronym{MIME} message.
524 * Simple MML Example:: An example @acronym{MML} document.
525 * MML Definition:: All valid @acronym{MML} elements.
526 * Advanced MML Example:: Another example @acronym{MML} document.
527 * Encoding Customization:: Variables that affect encoding.
528 * Charset Translation:: How charsets are mapped from @sc{mule} to @acronym{MIME}.
529 * Conversion:: Going from @acronym{MIME} to @acronym{MML} and vice versa.
530 * Flowed text:: Soft and hard newlines.
534 @node Simple MML Example
535 @section Simple MML Example
537 Here's a simple @samp{multipart/alternative}:
540 <#multipart type=alternative>
541 This is a plain text part.
542 <#part type=text/enriched>
543 <center>This is a centered enriched part</center>
547 After running this through @code{mml-generate-mime}, we get this:
550 Content-Type: multipart/alternative; boundary="=-=-="
556 This is a plain text part.
559 Content-Type: text/enriched
562 <center>This is a centered enriched part</center>
569 @section MML Definition
571 The @acronym{MML} language is very simple. It looks a bit like an SGML
572 application, but it's not.
574 The main concept of @acronym{MML} is the @dfn{part}. Each part can be of a
575 different type or use a different charset. The way to delineate a part
576 is with a @samp{<#part ...>} tag. Multipart parts can be introduced
577 with the @samp{<#multipart ...>} tag. Parts are ended by the
578 @samp{<#/part>} or @samp{<#/multipart>} tags. Parts started with the
579 @samp{<#part ...>} tags are also closed by the next open tag.
581 There's also the @samp{<#external ...>} tag. These introduce
582 @samp{external/message-body} parts.
584 Each tag can contain zero or more parameters on the form
585 @samp{parameter=value}. The values may be enclosed in quotation marks,
586 but that's not necessary unless the value contains white space. So
587 @samp{filename=/home/user/#hello$^yes} is perfectly valid.
589 The following parameters have meaning in @acronym{MML}; parameters that have no
590 meaning are ignored. The @acronym{MML} parameter names are the same as the
591 @acronym{MIME} parameter names; the things in the parentheses say which
592 header it will be used in.
596 The @acronym{MIME} type of the part (@code{Content-Type}).
599 Use the contents of the file in the body of the part
600 (@code{Content-Disposition}).
603 The contents of the body of the part are to be encoded in the character
604 set specified (@code{Content-Type}). @xref{Charset Translation}.
607 Might be used to suggest a file name if the part is to be saved
608 to a file (@code{Content-Type}).
611 Valid values are @samp{inline} and @samp{attachment}
612 (@code{Content-Disposition}).
615 Valid values are @samp{7bit}, @samp{8bit}, @samp{quoted-printable} and
616 @samp{base64} (@code{Content-Transfer-Encoding}). @xref{Charset
620 A description of the part (@code{Content-Description}).
623 RFC822 date when the part was created (@code{Content-Disposition}).
625 @item modification-date
626 RFC822 date when the part was modified (@code{Content-Disposition}).
629 RFC822 date when the part was read (@code{Content-Disposition}).
632 Who to encrypt/sign the part to. This field is used to override any
633 auto-detection based on the To/CC headers.
636 Identity used to sign the part. This field is used to override the
640 The size (in octets) of the part (@code{Content-Disposition}).
643 What technology to sign this @acronym{MML} part with (@code{smime}, @code{pgp}
647 What technology to encrypt this @acronym{MML} part with (@code{smime},
648 @code{pgp} or @code{pgpmime})
652 Parameters for @samp{text/plain}:
656 Formatting parameter for the text, valid values include @samp{fixed}
657 (the default) and @samp{flowed}. Normally you do not specify this
658 manually, since it requires the textual body to be formatted in a
659 special way described in RFC 2646. @xref{Flowed text}.
662 Parameters for @samp{application/octet-stream}:
666 Type of the part; informal---meant for human readers
667 (@code{Content-Type}).
670 Parameters for @samp{message/external-body}:
674 A word indicating the supported access mechanism by which the file may
675 be obtained. Values include @samp{ftp}, @samp{anon-ftp}, @samp{tftp},
676 @samp{localfile}, and @samp{mailserver}. (@code{Content-Type}.)
679 The RFC822 date after which the file may no longer be fetched.
680 (@code{Content-Type}.)
683 The size (in octets) of the file. (@code{Content-Type}.)
686 Valid values are @samp{read} and @samp{read-write}
687 (@code{Content-Type}).
691 Parameters for @samp{sign=smime}:
696 File containing key and certificate for signer.
700 Parameters for @samp{encrypt=smime}:
705 File containing certificate for recipient.
710 @node Advanced MML Example
711 @section Advanced MML Example
713 Here's a complex multipart message. It's a @samp{multipart/mixed} that
714 contains many parts, one of which is a @samp{multipart/alternative}.
717 <#multipart type=mixed>
718 <#part type=image/jpeg filename=~/rms.jpg disposition=inline>
719 <#multipart type=alternative>
720 This is a plain text part.
721 <#part type=text/enriched name=enriched.txt>
722 <center>This is a centered enriched part</center>
724 This is a new plain text part.
725 <#part disposition=attachment>
726 This plain text part is an attachment.
730 And this is the resulting @acronym{MIME} message:
733 Content-Type: multipart/mixed; boundary="=-=-="
741 Content-Type: image/jpeg;
743 Content-Disposition: inline;
745 Content-Transfer-Encoding: base64
747 /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof
748 Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/wAALCAAwADABAREA/8QAHwAA
749 AQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQR
750 BRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RF
751 RkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ip
752 qrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/9oACAEB
753 AAA/AO/rifFHjldNuGsrDa0qcSSHkA+gHrXKw+LtWLrMb+RgTyhbr+HSug07xNqV9fQtZrNI
754 AyiaE/NuBPOOOP0rvRNE880KOC8TbXXGCv1FPqjrF4LDR7u5L7SkTFT/ALWOP1xXgTuXfc7E
755 sx6nua6rwp4IvvEM8chCxWxOdzn7wz6V9AaB4S07w9p5itow0rDLSY5Pt9K43xO66P4xs71m
756 2QXiGCbA4yOVJ9+1aYORkdK434lyNH4ahCnG66VT9Nj15JFbPdX0MS43M4VQf5/yr2vSpLnw
757 5ZW8dlCZ8KFXjOPX0/mK6rSPEGt3Angu44fNEReHYNvIH3TzXDeKNO8RX+kSX2ouZkicTIOc
758 L+g7E810ulFjpVtv3bwgB3HJyK5L4quY/C9sVxk3ij/xx6850u7t1mtp/wDlpEw3An3Jr3Dw
759 34gsbWza4nBlhC5LDsaW6+IFgupQyCF3iHH7gA7c9R9ay7zx6t7aX9jHC4smhfBkGCvHGfrm
760 tLQ7hbnRrV1GPkAP1x1/Hr+Ncr8Vzjwrbf8AX6v/AKA9eQRyYlQk8Yx9K6XTNbkgia2ciSIn
761 7p5Ga9Atte0LTLKO6it4i7dVRFJDcZ4PvXN+JvEMF9bILVGXJLSZ4zkjivRPDaeX4b08HOTC
762 pOffmua+KkbS+GLVUGT9tT/0B68eeIpIFYjB70+OOVXyoOM9+M1eaWeCLzHPyHGO/NVWvJJm
763 jQ8KGH1NfQWhXSXmh2c8eArRLwO3HSv/2Q==
766 Content-Type: multipart/alternative; boundary="==-=-="
772 This is a plain text part.
775 Content-Type: text/enriched;
779 <center>This is a centered enriched part</center>
785 This is a new plain text part.
788 Content-Disposition: attachment
791 This plain text part is an attachment.
796 @node Encoding Customization
797 @section Encoding Customization
801 @item mm-body-charset-encoding-alist
802 @vindex mm-body-charset-encoding-alist
803 Mapping from @acronym{MIME} charset to encoding to use. This variable is
804 usually used except, e.g., when other requirements force a specific
805 encoding (digitally signed messages require 7bit encodings). The
809 ((iso-2022-jp . 7bit)
810 (iso-2022-jp-2 . 7bit)
816 As an example, if you do not want to have ISO-8859-1 characters
817 quoted-printable encoded, you may add @code{(iso-8859-1 . 8bit)} to
818 this variable. You can override this setting on a per-message basis
819 by using the @code{encoding} @acronym{MML} tag (@pxref{MML Definition}).
821 @item mm-coding-system-priorities
822 @vindex mm-coding-system-priorities
823 Prioritize coding systems to use for outgoing messages. The default
824 is @code{nil}, which means to use the defaults in Emacs. It is a list of
825 coding system symbols (aliases of coding systems are also allowed, use
826 @kbd{M-x describe-coding-system} to make sure you are specifying correct
827 coding system names). For example, if you have configured Emacs
828 to prefer UTF-8, but wish that outgoing messages should be sent in
829 ISO-8859-1 if possible, you can set this variable to
830 @code{(iso-8859-1)}. You can override this setting on a per-message
831 basis by using the @code{charset} @acronym{MML} tag (@pxref{MML Definition}).
833 @item mm-content-transfer-encoding-defaults
834 @vindex mm-content-transfer-encoding-defaults
835 Mapping from @acronym{MIME} types to encoding to use. This variable is usually
836 used except, e.g., when other requirements force a safer encoding
837 (digitally signed messages require 7bit encoding). Besides the normal
838 @acronym{MIME} encodings, @code{qp-or-base64} may be used to indicate that for
839 each case the most efficient of quoted-printable and base64 should be
842 @code{qp-or-base64} has another effect. It will fold long lines so that
843 MIME parts may not be broken by MTA. So do @code{quoted-printable} and
846 Note that it affects body encoding only when a part is a raw forwarded
847 message (which will be made by @code{gnus-summary-mail-forward} with the
848 arg 2 for example) or is neither the @samp{text/*} type nor the
849 @samp{message/*} type. Even though in those cases, you can override
850 this setting on a per-message basis by using the @code{encoding}
851 @acronym{MML} tag (@pxref{MML Definition}).
853 @item mm-use-ultra-safe-encoding
854 @vindex mm-use-ultra-safe-encoding
855 When this is non-@code{nil}, it means that textual parts are encoded as
856 quoted-printable if they contain lines longer than 76 characters or
857 starting with "From " in the body. Non-7bit encodings (8bit, binary)
858 are generally disallowed. This reduce the probability that a non-8bit
859 clean MTA or MDA changes the message. This should never be set
860 directly, but bound by other functions when necessary (e.g., when
861 encoding messages that are to be digitally signed).
865 @node Charset Translation
866 @section Charset Translation
869 During translation from @acronym{MML} to @acronym{MIME}, for each
870 @acronym{MIME} part which has been composed inside Emacs, an appropriate
871 charset has to be chosen.
873 @vindex mail-parse-charset
874 If you are running a non-@sc{mule} Emacs, this process is simple: If the
875 part contains any non-@acronym{ASCII} (8-bit) characters, the @acronym{MIME} charset
876 given by @code{mail-parse-charset} (a symbol) is used. (Never set this
877 variable directly, though. If you want to change the default charset,
878 please consult the documentation of the package which you use to process
879 @acronym{MIME} messages.
880 @xref{Various Message Variables, , Various Message Variables, message,
881 Message Manual}, for example.)
882 If there are only @acronym{ASCII} characters, the @acronym{MIME} charset US-ASCII is
888 @vindex mm-mime-mule-charset-alist
889 Things are slightly more complicated when running Emacs with @sc{mule}
890 support. In this case, a list of the @sc{mule} charsets used in the
891 part is obtained, and the @sc{mule} charsets are translated to @acronym{MIME}
892 charsets by consulting the variable @code{mm-mime-mule-charset-alist}.
893 If this results in a single @acronym{MIME} charset, this is used to encode
894 the part. But if the resulting list of @acronym{MIME} charsets contains more
895 than one element, two things can happen: If it is possible to encode the
896 part via UTF-8, this charset is used. (For this, Emacs must support
897 the @code{utf-8} coding system, and the part must consist entirely of
898 characters which have Unicode counterparts.) If UTF-8 is not available
899 for some reason, the part is split into several ones, so that each one
900 can be encoded with a single @acronym{MIME} charset. The part can only be
901 split at line boundaries, though---if more than one @acronym{MIME} charset is
902 required to encode a single line, it is not possible to encode the part.
904 When running Emacs with @sc{mule} support, the preferences for which
905 coding system to use is inherited from Emacs itself. This means that
906 if Emacs is set up to prefer UTF-8, it will be used when encoding
907 messages. You can modify this by altering the
908 @code{mm-coding-system-priorities} variable though (@pxref{Encoding
911 The charset to be used can be overridden by setting the @code{charset}
912 @acronym{MML} tag (@pxref{MML Definition}) when composing the message.
914 The encoding of characters (quoted-printable, 8bit etc) is orthogonal
915 to the discussion here, and is controlled by the variables
916 @code{mm-body-charset-encoding-alist} and
917 @code{mm-content-transfer-encoding-defaults} (@pxref{Encoding
924 A (multipart) @acronym{MIME} message can be converted to @acronym{MML}
925 with the @code{mime-to-mml} function. It works on the message in the
926 current buffer, and substitutes @acronym{MML} markup for @acronym{MIME}
927 boundaries. Non-textual parts do not have their contents in the buffer,
928 but instead have the contents in separate buffers that are referred to
929 from the @acronym{MML} tags.
932 An @acronym{MML} message can be converted back to @acronym{MIME} by the
933 @code{mml-to-mime} function.
935 These functions are in certain senses ``lossy''---you will not get back
936 an identical message if you run @code{mime-to-mml} and then
937 @code{mml-to-mime}. Not only will trivial things like the order of the
938 headers differ, but the contents of the headers may also be different.
939 For instance, the original message may use base64 encoding on text,
940 while @code{mml-to-mime} may decide to use quoted-printable encoding, and
943 In essence, however, these two functions should be the inverse of each
944 other. The resulting contents of the message should remain equivalent,
950 @cindex format=flowed
952 The Emacs @acronym{MIME} library will respect the @code{use-hard-newlines}
953 variable (@pxref{Hard and Soft Newlines, ,Hard and Soft Newlines,
954 emacs, Emacs Manual}) when encoding a message, and the
955 ``format=flowed'' Content-Type parameter when decoding a message.
957 On encoding text, regardless of @code{use-hard-newlines}, lines
958 terminated by soft newline characters are filled together and wrapped
959 after the column decided by @code{fill-flowed-encode-column}.
960 Quotation marks (matching @samp{^>* ?}) are respected. The variable
961 controls how the text will look in a client that does not support
962 flowed text, the default is to wrap after 66 characters. If hard
963 newline characters are not present in the buffer, no flow encoding
966 On decoding flowed text, lines with soft newline characters are filled
967 together and wrapped after the column decided by
968 @code{fill-flowed-display-column}. The default is to wrap after
973 @vindex mm-fill-flowed
974 If non-@code{nil} a format=flowed article will be displayed flowed.
978 @node Interface Functions
979 @chapter Interface Functions
980 @cindex interface functions
983 The @code{mail-parse} library is an abstraction over the actual
984 low-level libraries that are described in the next chapter.
986 Standards change, and so programs have to change to fit in the new
987 mold. For instance, RFC2045 describes a syntax for the
988 @code{Content-Type} header that only allows @acronym{ASCII} characters in the
989 parameter list. RFC2231 expands on RFC2045 syntax to provide a scheme
990 for continuation headers and non-@acronym{ASCII} characters.
992 The traditional way to deal with this is just to update the library
993 functions to parse the new syntax. However, this is sometimes the wrong
994 thing to do. In some instances it may be vital to be able to understand
995 both the old syntax as well as the new syntax, and if there is only one
996 library, one must choose between the old version of the library and the
997 new version of the library.
999 The Emacs @acronym{MIME} library takes a different tack. It defines a
1000 series of low-level libraries (@file{rfc2047.el}, @file{rfc2231.el}
1001 and so on) that parses strictly according to the corresponding
1002 standard. However, normal programs would not use the functions
1003 provided by these libraries directly, but instead use the functions
1004 provided by the @code{mail-parse} library. The functions in this
1005 library are just aliases to the corresponding functions in the latest
1006 low-level libraries. Using this scheme, programs get a consistent
1007 interface they can use, and library developers are free to create
1008 write code that handles new standards.
1010 The following functions are defined by this library:
1013 @item mail-header-parse-content-type
1014 @findex mail-header-parse-content-type
1015 Parse a @code{Content-Type} header and return a list on the following
1020 (attribute1 . value1)
1021 (attribute2 . value2)
1028 (mail-header-parse-content-type
1029 "image/gif; name=\"b980912.gif\"")
1030 @result{} ("image/gif" (name . "b980912.gif"))
1033 @item mail-header-parse-content-disposition
1034 @findex mail-header-parse-content-disposition
1035 Parse a @code{Content-Disposition} header and return a list on the same
1036 format as the function above.
1038 @item mail-content-type-get
1039 @findex mail-content-type-get
1040 Takes two parameters---a list on the format above, and an attribute.
1041 Returns the value of the attribute.
1044 (mail-content-type-get
1045 '("image/gif" (name . "b980912.gif")) 'name)
1046 @result{} "b980912.gif"
1049 @item mail-header-encode-parameter
1050 @findex mail-header-encode-parameter
1051 Takes a parameter string and returns an encoded version of the string.
1052 This is used for parameters in headers like @code{Content-Type} and
1053 @code{Content-Disposition}.
1055 @item mail-header-remove-comments
1056 @findex mail-header-remove-comments
1057 Return a comment-free version of a header.
1060 (mail-header-remove-comments
1061 "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
1062 @result{} "Gnus/5.070027 "
1065 @item mail-header-remove-whitespace
1066 @findex mail-header-remove-whitespace
1067 Remove linear white space from a header. Space inside quoted strings
1068 and comments is preserved.
1071 (mail-header-remove-whitespace
1072 "image/gif; name=\"Name with spaces\"")
1073 @result{} "image/gif;name=\"Name with spaces\""
1076 @item mail-header-get-comment
1077 @findex mail-header-get-comment
1078 Return the last comment in a header.
1081 (mail-header-get-comment
1082 "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
1083 @result{} "Finnish Landrace"
1086 @item mail-header-parse-address
1087 @findex mail-header-parse-address
1088 Parse an address and return a list containing the mailbox and the
1092 (mail-header-parse-address
1093 "Hrvoje Niksic <hniksic@@srce.hr>")
1094 @result{} ("hniksic@@srce.hr" . "Hrvoje Niksic")
1097 @item mail-header-parse-addresses
1098 @findex mail-header-parse-addresses
1099 Parse a string with list of addresses and return a list of elements like
1100 the one described above.
1103 (mail-header-parse-addresses
1104 "Hrvoje Niksic <hniksic@@srce.hr>, Steinar Bang <sb@@metis.no>")
1105 @result{} (("hniksic@@srce.hr" . "Hrvoje Niksic")
1106 ("sb@@metis.no" . "Steinar Bang"))
1109 @item mail-header-parse-date
1110 @findex mail-header-parse-date
1111 Parse a date string and return an Emacs time structure.
1113 @item mail-narrow-to-head
1114 @findex mail-narrow-to-head
1115 Narrow the buffer to the header section of the buffer. Point is placed
1116 at the beginning of the narrowed buffer.
1118 @item mail-header-narrow-to-field
1119 @findex mail-header-narrow-to-field
1120 Narrow the buffer to the header under point. Understands continuation
1123 @item mail-header-fold-field
1124 @findex mail-header-fold-field
1125 Fold the header under point.
1127 @item mail-header-unfold-field
1128 @findex mail-header-unfold-field
1129 Unfold the header under point.
1131 @item mail-header-field-value
1132 @findex mail-header-field-value
1133 Return the value of the field under point.
1135 @item mail-encode-encoded-word-region
1136 @findex mail-encode-encoded-word-region
1137 Encode the non-@acronym{ASCII} words in the region. For instance,
1138 @samp{Na@"{@dotless{i}}ve} is encoded as @samp{=?iso-8859-1?q?Na=EFve?=}.
1140 @item mail-encode-encoded-word-buffer
1141 @findex mail-encode-encoded-word-buffer
1142 Encode the non-@acronym{ASCII} words in the current buffer. This function is
1143 meant to be called narrowed to the headers of a message.
1145 @item mail-encode-encoded-word-string
1146 @findex mail-encode-encoded-word-string
1147 Encode the words that need encoding in a string, and return the result.
1150 (mail-encode-encoded-word-string
1151 "This is na@"{@dotless{i}}ve, baby")
1152 @result{} "This is =?iso-8859-1?q?na=EFve,?= baby"
1155 @item mail-decode-encoded-word-region
1156 @findex mail-decode-encoded-word-region
1157 Decode the encoded words in the region.
1159 @item mail-decode-encoded-word-string
1160 @findex mail-decode-encoded-word-string
1161 Decode the encoded words in the string and return the result.
1164 (mail-decode-encoded-word-string
1165 "This is =?iso-8859-1?q?na=EFve,?= baby")
1166 @result{} "This is na@"{@dotless{i}}ve, baby"
1171 Currently, @code{mail-parse} is an abstraction over @code{ietf-drums},
1172 @code{rfc2047}, @code{rfc2045} and @code{rfc2231}. These are documented
1173 in the subsequent sections.
1177 @node Basic Functions
1178 @chapter Basic Functions
1180 This chapter describes the basic, ground-level functions for parsing and
1181 handling. Covered here is parsing @code{From} lines, removing comments
1182 from header lines, decoding encoded words, parsing date headers and so
1183 on. High-level functionality is dealt with in the next chapter
1184 (@pxref{Decoding and Viewing}).
1187 * rfc2045:: Encoding @code{Content-Type} headers.
1188 * rfc2231:: Parsing @code{Content-Type} headers.
1189 * ietf-drums:: Handling mail headers defined by RFC822bis.
1190 * rfc2047:: En/decoding encoded words in headers.
1191 * time-date:: Functions for parsing dates and manipulating time.
1192 * qp:: Quoted-Printable en/decoding.
1193 * base64:: Base64 en/decoding.
1194 * binhex:: Binhex decoding.
1195 * uudecode:: Uuencode decoding.
1196 * yenc:: Yenc decoding.
1197 * rfc1843:: Decoding HZ-encoded text.
1198 * mailcap:: How parts are displayed is specified by the @file{.mailcap} file
1205 RFC2045 is the ``main'' @acronym{MIME} document, and as such, one would
1206 imagine that there would be a lot to implement. But there isn't, since
1207 most of the implementation details are delegated to the subsequent
1210 So @file{rfc2045.el} has only a single function:
1213 @item rfc2045-encode-string
1214 @findex rfc2045-encode-string
1215 Takes a parameter and a value and returns a @samp{PARAM=VALUE} string.
1216 @var{value} will be quoted if there are non-safe characters in it.
1223 RFC2231 defines a syntax for the @code{Content-Type} and
1224 @code{Content-Disposition} headers. Its snappy name is @dfn{MIME
1225 Parameter Value and Encoded Word Extensions: Character Sets, Languages,
1228 In short, these headers look something like this:
1231 Content-Type: application/x-stuff;
1232 title*0*=us-ascii'en'This%20is%20even%20more%20;
1233 title*1*=%2A%2A%2Afun%2A%2A%2A%20;
1237 They usually aren't this bad, though.
1239 The following functions are defined by this library:
1242 @item rfc2231-parse-string
1243 @findex rfc2231-parse-string
1244 Parse a @code{Content-Type} header and return a list describing its
1248 (rfc2231-parse-string
1249 "application/x-stuff;
1250 title*0*=us-ascii'en'This%20is%20even%20more%20;
1251 title*1*=%2A%2A%2Afun%2A%2A%2A%20;
1252 title*2=\"isn't it!\"")
1253 @result{} ("application/x-stuff"
1254 (title . "This is even more ***fun*** isn't it!"))
1257 @item rfc2231-get-value
1258 @findex rfc2231-get-value
1259 Takes one of the lists on the format above and returns
1260 the value of the specified attribute.
1262 @item rfc2231-encode-string
1263 @findex rfc2231-encode-string
1264 Encode a parameter in headers likes @code{Content-Type} and
1265 @code{Content-Disposition}.
1273 @dfn{drums} is an IETF working group that is working on the replacement
1276 The functions provided by this library include:
1279 @item ietf-drums-remove-comments
1280 @findex ietf-drums-remove-comments
1281 Remove the comments from the argument and return the results.
1283 @item ietf-drums-remove-whitespace
1284 @findex ietf-drums-remove-whitespace
1285 Remove linear white space from the string and return the results.
1286 Spaces inside quoted strings and comments are left untouched.
1288 @item ietf-drums-get-comment
1289 @findex ietf-drums-get-comment
1290 Return the last most comment from the string.
1292 @item ietf-drums-parse-address
1293 @findex ietf-drums-parse-address
1294 Parse an address string and return a list that contains the mailbox and
1295 the plain text name.
1297 @item ietf-drums-parse-addresses
1298 @findex ietf-drums-parse-addresses
1299 Parse a string that contains any number of comma-separated addresses and
1300 return a list that contains mailbox/plain text pairs.
1302 @item ietf-drums-parse-date
1303 @findex ietf-drums-parse-date
1304 Parse a date string and return an Emacs time structure.
1306 @item ietf-drums-narrow-to-header
1307 @findex ietf-drums-narrow-to-header
1308 Narrow the buffer to the header section of the current buffer.
1316 RFC2047 (Message Header Extensions for Non-@acronym{ASCII} Text) specifies how
1317 non-@acronym{ASCII} text in headers are to be encoded. This is actually rather
1318 complicated, so a number of variables are necessary to tweak what this
1321 The following variables are tweakable:
1324 @item rfc2047-header-encoding-alist
1325 @vindex rfc2047-header-encoding-alist
1326 This is an alist of header / encoding-type pairs. Its main purpose is
1327 to prevent encoding of certain headers.
1329 The keys can either be header regexps, or @code{t}.
1331 The values can be @code{nil}, in which case the header(s) in question
1332 won't be encoded, @code{mime}, which means that they will be encoded, or
1333 @code{address-mime}, which means the header(s) will be encoded carefully
1334 assuming they contain addresses.
1336 @item rfc2047-charset-encoding-alist
1337 @vindex rfc2047-charset-encoding-alist
1338 RFC2047 specifies two forms of encoding---@code{Q} (a
1339 Quoted-Printable-like encoding) and @code{B} (base64). This alist
1340 specifies which charset should use which encoding.
1342 @item rfc2047-encode-function-alist
1343 @vindex rfc2047-encode-function-alist
1344 This is an alist of encoding / function pairs. The encodings are
1345 @code{Q}, @code{B} and @code{nil}.
1347 @item rfc2047-encoded-word-regexp
1348 @vindex rfc2047-encoded-word-regexp
1349 When decoding words, this library looks for matches to this regexp.
1351 @item rfc2047-encode-encoded-words
1352 @vindex rfc2047-encode-encoded-words
1353 The boolean variable specifies whether encoded words
1354 (e.g. @samp{=?hello?=}) should be encoded again.
1358 Those were the variables, and these are this functions:
1361 @item rfc2047-narrow-to-field
1362 @findex rfc2047-narrow-to-field
1363 Narrow the buffer to the header on the current line.
1365 @item rfc2047-encode-message-header
1366 @findex rfc2047-encode-message-header
1367 Should be called narrowed to the header of a message. Encodes according
1368 to @code{rfc2047-header-encoding-alist}.
1370 @item rfc2047-encode-region
1371 @findex rfc2047-encode-region
1372 Encodes all encodable words in the region specified.
1374 @item rfc2047-encode-string
1375 @findex rfc2047-encode-string
1376 Encode a string and return the results.
1378 @item rfc2047-decode-region
1379 @findex rfc2047-decode-region
1380 Decode the encoded words in the region.
1382 @item rfc2047-decode-string
1383 @findex rfc2047-decode-string
1384 Decode a string and return the results.
1386 @item rfc2047-encode-parameter
1387 @findex rfc2047-encode-parameter
1388 Encode a parameter in the RFC2047-like style. This is a replacement for
1389 the @code{rfc2231-encode-string} function. @xref{rfc2231}.
1391 When attaching files as @acronym{MIME} parts, we should use the RFC2231
1392 encoding to specify the file names containing non-@acronym{ASCII}
1393 characters. However, many mail softwares don't support it in practice
1394 and recipients won't be able to extract files with correct names.
1395 Instead, the RFC2047-like encoding is acceptable generally. This
1396 function provides the very RFC2047-like encoding, resigning to such a
1397 regrettable trend. To use it, put the following line in your
1398 @file{~/.gnus.el} file:
1401 (defalias 'mail-header-encode-parameter 'rfc2047-encode-parameter)
1410 While not really a part of the @acronym{MIME} library, it is convenient to
1411 document this library here. It deals with parsing @code{Date} headers
1412 and manipulating time. (Not by using tesseracts, though, I'm sorry to
1415 These functions convert between five formats: A date string, an Emacs
1416 time structure, a decoded time list, a second number, and a day number.
1418 Here's a bunch of time/date/second/day examples:
1421 (parse-time-string "Sat Sep 12 12:21:54 1998 +0200")
1422 @result{} (54 21 12 12 9 1998 6 nil 7200)
1424 (date-to-time "Sat Sep 12 12:21:54 1998 +0200")
1425 @result{} (13818 19266)
1427 (time-to-seconds '(13818 19266))
1428 @result{} 905595714.0
1430 (seconds-to-time 905595714.0)
1431 @result{} (13818 19266 0)
1433 (time-to-days '(13818 19266))
1436 (days-to-time 729644)
1437 @result{} (961933 65536)
1439 (time-since '(13818 19266))
1442 (time-less-p '(13818 19266) '(13818 19145))
1445 (subtract-time '(13818 19266) '(13818 19145))
1448 (days-between "Sat Sep 12 12:21:54 1998 +0200"
1449 "Sat Sep 07 12:21:54 1998 +0200")
1452 (date-leap-year-p 2000)
1455 (time-to-day-in-year '(13818 19266))
1458 (time-to-number-of-days
1460 (date-to-time "Mon, 01 Jan 2001 02:22:26 GMT")))
1461 @result{} 4.146122685185185
1464 And finally, we have @code{safe-date-to-time}, which does the same as
1465 @code{date-to-time}, but returns a zero time if the date is
1466 syntactically malformed.
1468 The five data representations used are the following:
1472 An RFC822 (or similar) date string. For instance: @code{"Sat Sep 12
1473 12:21:54 1998 +0200"}.
1476 An internal Emacs time. For instance: @code{(13818 26466)}.
1479 A floating point representation of the internal Emacs time. For
1480 instance: @code{905595714.0}.
1483 An integer number representing the number of days since 00000101. For
1484 instance: @code{729644}.
1487 A list of decoded time. For instance: @code{(54 21 12 12 9 1998 6 t
1491 All the examples above represent the same moment.
1493 These are the functions available:
1497 Take a date and return a time.
1499 @item time-to-seconds
1500 Take a time and return seconds.
1502 @item seconds-to-time
1503 Take seconds and return a time.
1506 Take a time and return days.
1509 Take days and return a time.
1512 Take a date and return days.
1514 @item time-to-number-of-days
1515 Take a time and return the number of days that represents.
1517 @item safe-date-to-time
1518 Take a date and return a time. If the date is not syntactically valid,
1519 return a ``zero'' date.
1522 Take two times and say whether the first time is less (i. e., earlier)
1523 than the second time.
1526 Take a time and return a time saying how long it was since that time.
1529 Take two times and subtract the second from the first. I. e., return
1530 the time between the two times.
1533 Take two days and return the number of days between those two days.
1535 @item date-leap-year-p
1536 Take a year number and say whether it's a leap year.
1538 @item time-to-day-in-year
1539 Take a time and return the day number within the year that the time is
1548 This library deals with decoding and encoding Quoted-Printable text.
1550 Very briefly explained, qp encoding means translating all 8-bit
1551 characters (and lots of control characters) into things that look like
1552 @samp{=EF}; that is, an equal sign followed by the byte encoded as a hex
1555 The following functions are defined by the library:
1558 @item quoted-printable-decode-region
1559 @findex quoted-printable-decode-region
1560 QP-decode all the encoded text in the specified region.
1562 @item quoted-printable-decode-string
1563 @findex quoted-printable-decode-string
1564 Decode the QP-encoded text in a string and return the results.
1566 @item quoted-printable-encode-region
1567 @findex quoted-printable-encode-region
1568 QP-encode all the encodable characters in the specified region. The third
1569 optional parameter @var{fold} specifies whether to fold long lines.
1570 (Long here means 72.)
1572 @item quoted-printable-encode-string
1573 @findex quoted-printable-encode-string
1574 QP-encode all the encodable characters in a string and return the
1584 Base64 is an encoding that encodes three bytes into four characters,
1585 thereby increasing the size by about 33%. The alphabet used for
1586 encoding is very resistant to mangling during transit.
1588 The following functions are defined by this library:
1591 @item base64-encode-region
1592 @findex base64-encode-region
1593 base64 encode the selected region. Return the length of the encoded
1594 text. Optional third argument @var{no-line-break} means do not break
1595 long lines into shorter lines.
1597 @item base64-encode-string
1598 @findex base64-encode-string
1599 base64 encode a string and return the result.
1601 @item base64-decode-region
1602 @findex base64-decode-region
1603 base64 decode the selected region. Return the length of the decoded
1604 text. If the region can't be decoded, return @code{nil} and don't
1607 @item base64-decode-string
1608 @findex base64-decode-string
1609 base64 decode a string and return the result. If the string can't be
1610 decoded, @code{nil} is returned.
1621 @code{binhex} is an encoding that originated in Macintosh environments.
1622 The following function is supplied to deal with these:
1625 @item binhex-decode-region
1626 @findex binhex-decode-region
1627 Decode the encoded text in the region. If given a third parameter, only
1628 decode the @code{binhex} header and return the filename.
1637 @code{uuencode} is probably still the most popular encoding of binaries
1638 used on Usenet, although @code{base64} rules the mail world.
1640 The following function is supplied by this package:
1643 @item uudecode-decode-region
1644 @findex uudecode-decode-region
1645 Decode the text in the region.
1653 @code{yenc} is used for encoding binaries on Usenet. The following
1654 function is supplied by this package:
1657 @item yenc-decode-region
1658 @findex yenc-decode-region
1659 Decode the encoded text in the region.
1670 RFC1843 deals with mixing Chinese and @acronym{ASCII} characters in messages. In
1671 essence, RFC1843 switches between @acronym{ASCII} and Chinese by doing this:
1674 This sentence is in @acronym{ASCII}.
1675 The next sentence is in GB.~@{<:Ky2;S@{#,NpJ)l6HK!#~@}Bye.
1678 Simple enough, and widely used in China.
1680 The following functions are available to handle this encoding:
1683 @item rfc1843-decode-region
1684 Decode HZ-encoded text in the region.
1686 @item rfc1843-decode-string
1687 Decode a HZ-encoded string and return the result.
1695 The @file{~/.mailcap} file is parsed by most @acronym{MIME}-aware message
1696 handlers and describes how elements are supposed to be displayed.
1697 Here's an example file:
1701 audio/wav; wavplayer %s
1702 application/msword; catdoc %s ; copiousoutput ; nametemplate=%s.doc
1705 This says that all image files should be displayed with @code{gimp},
1706 that WAVE audio files should be played by @code{wavplayer}, and that
1707 MS-WORD files should be inlined by @code{catdoc}.
1709 The @code{mailcap} library parses this file, and provides functions for
1713 @item mailcap-mime-data
1714 @vindex mailcap-mime-data
1715 This variable is an alist of alists containing backup viewing rules.
1719 Interface functions:
1722 @item mailcap-parse-mailcaps
1723 @findex mailcap-parse-mailcaps
1724 Parse the @file{~/.mailcap} file.
1726 @item mailcap-mime-info
1727 Takes a @acronym{MIME} type as its argument and returns the matching viewer.
1737 The Emacs @acronym{MIME} library implements handling of various elements
1738 according to a (somewhat) large number of RFCs, drafts and standards
1739 documents. This chapter lists the relevant ones. They can all be
1740 fetched from @uref{http://quimby.gnus.org/notes/}.
1745 Standard for the Format of ARPA Internet Text Messages.
1748 Standard for Interchange of USENET Messages
1751 Format of Internet Message Bodies
1757 Message Header Extensions for Non-@acronym{ASCII} Text
1760 Registration Procedures
1763 Conformance Criteria and Examples
1766 @acronym{MIME} Parameter Value and Encoded Word Extensions: Character Sets,
1767 Languages, and Continuations
1770 HZ - A Data Format for Exchanging Files of Arbitrarily Mixed Chinese and
1771 @acronym{ASCII} characters
1773 @item draft-ietf-drums-msg-fmt-05.txt
1774 Draft for the successor of RFC822
1777 The @acronym{MIME} Multipart/Related Content-type
1780 The Multipart/Report Content Type for the Reporting of Mail System
1781 Administrative Messages
1784 Communicating Presentation Information in Internet Messages: The
1785 Content-Disposition Header Field
1788 Documentation of the text/plain format parameter for flowed text.
1802 @c coding: iso-2022-7bit
1805 @c use-kuten-for-period: t
1806 @c use-touten-for-comma: t