3 @setfilename emacs-mime-ja
4 @settitle Emacs MIME Manual
10 This file documents the Emacs MIME interface functionality.
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: (emacs-mime-ja). Emacs MIME de/composition library.
59 @setchapternewpage odd
62 @title Emacs MIME Manual
64 @author by Lars Magne Ingebrigtsen
66 @vskip 0pt plus 1filll
73 This manual documents the libraries used to compose and display
74 @acronym{MIME} messages.
76 This manual is directed at users who want to modify the behavior of
77 the @acronym{MIME} encoding/decoding process or want a more detailed
78 picture of how the Emacs @acronym{MIME} library works, and people who want
79 to write functions and commands that manipulate @acronym{MIME} elements.
81 @acronym{MIME} is short for @dfn{Multipurpose Internet Mail Extensions}.
82 This standard is documented in a number of RFCs; mainly RFC2045 (Format
83 of Internet Message Bodies), RFC2046 (Media Types), RFC2047 (Message
84 Header Extensions for Non-@acronym{ASCII} Text), RFC2048 (Registration
85 Procedures), RFC2049 (Conformance Criteria and Examples). It is highly
86 recommended that anyone who intends writing @acronym{MIME}-compliant software
87 read at least RFC2045 and RFC2047.
90 * Decoding and Viewing:: A framework for decoding and viewing.
91 * Composing:: @acronym{MML}; a language for describing @acronym{MIME} parts.
92 * Interface Functions:: An abstraction over the basic functions.
93 * Basic Functions:: Utility and basic parsing functions.
94 * Standards:: A summary of RFCs and working documents used.
95 * Index:: Function and variable index.
99 @node Decoding and Viewing
100 @chapter Decoding and Viewing
102 This chapter deals with decoding and viewing @acronym{MIME} messages on a
105 The main idea is to first analyze a @acronym{MIME} article, and then allow
106 other programs to do things based on the list of @dfn{handles} that are
107 returned as a result of this analysis.
110 * Dissection:: Analyzing a @acronym{MIME} message.
111 * Non-MIME:: Analyzing a non-@acronym{MIME} message.
112 * Handles:: Handle manipulations.
113 * Display:: Displaying handles.
114 * Display Customization:: Variables that affect display.
115 * Files and Directories:: Saving and naming attachments.
116 * New Viewers:: How to write your own viewers.
123 The @code{mm-dissect-buffer} is the function responsible for dissecting
124 a @acronym{MIME} article. If given a multipart message, it will recursively
125 descend the message, following the structure, and return a tree of
126 @acronym{MIME} handles that describes the structure of the message.
130 @vindex mm-uu-configure-list
132 Gnus also understands some non-@acronym{MIME} attachments, such as
133 postscript, uuencode, binhex, yenc, shar, forward, gnatsweb, pgp,
134 diff. Each of these features can be disabled by add an item into
135 @code{mm-uu-configure-list}. For example,
139 (add-to-list 'mm-uu-configure-list '(pgp-signed . disabled))
165 Non-@acronym{MIME} forwarded message.
173 @acronym{PGP} signed clear text.
176 @findex pgp-encrypted
177 @acronym{PGP} encrypted clear text.
181 @acronym{PGP} public keys.
184 @findex emacs-sources
185 @vindex mm-uu-emacs-sources-regexp
186 Emacs source code. This item works only in the groups matching
187 @code{mm-uu-emacs-sources-regexp}.
191 @vindex mm-uu-diff-groups-regexp
192 Patches. This is intended for groups where diffs of committed files
193 are automatically sent to. It only works in groups matching
194 @code{mm-uu-diff-groups-regexp}.
201 A @acronym{MIME} handle is a list that fully describes a @acronym{MIME}
204 The following macros can be used to access elements in a handle:
207 @item mm-handle-buffer
208 @findex mm-handle-buffer
209 Return the buffer that holds the contents of the undecoded @acronym{MIME}
213 @findex mm-handle-type
214 Return the parsed @code{Content-Type} of the part.
216 @item mm-handle-encoding
217 @findex mm-handle-encoding
218 Return the @code{Content-Transfer-Encoding} of the part.
220 @item mm-handle-undisplayer
221 @findex mm-handle-undisplayer
222 Return the object that can be used to remove the displayed part (if it
225 @item mm-handle-set-undisplayer
226 @findex mm-handle-set-undisplayer
227 Set the undisplayer object.
229 @item mm-handle-disposition
230 @findex mm-handle-disposition
231 Return the parsed @code{Content-Disposition} of the part.
233 @item mm-handle-disposition
234 @findex mm-handle-disposition
235 Return the description of the part.
237 @item mm-get-content-id
238 Returns the handle(s) referred to by @code{Content-ID}.
246 Functions for displaying, removing and saving.
249 @item mm-display-part
250 @findex mm-display-part
254 @findex mm-remove-part
255 Remove the part (if it has been displayed).
258 @findex mm-inlinable-p
259 Say whether a @acronym{MIME} type can be displayed inline.
261 @item mm-automatic-display-p
262 @findex mm-automatic-display-p
263 Say whether a @acronym{MIME} type should be displayed automatically.
265 @item mm-destroy-part
266 @findex mm-destroy-part
267 Free all resources occupied by a part.
271 Offer to save the part in a file.
275 Offer to pipe the part to some process.
277 @item mm-interactively-view-part
278 @findex mm-interactively-view-part
279 Prompt for a mailcap method to use to view the part.
284 @node Display Customization
285 @section Display Customization
289 @item mm-inline-media-tests
290 @vindex mm-inline-media-tests
291 This is an alist where the key is a @acronym{MIME} type, the second element
292 is a function to display the part @dfn{inline} (i.e., inside Emacs), and
293 the third element is a form to be @code{eval}ed to say whether the part
294 can be displayed inline.
296 This variable specifies whether a part @emph{can} be displayed inline,
297 and, if so, how to do it. It does not say whether parts are
298 @emph{actually} displayed inline.
300 @item mm-inlined-types
301 @vindex mm-inlined-types
302 This, on the other hand, says what types are to be displayed inline, if
303 they satisfy the conditions set by the variable above. It's a list of
304 @acronym{MIME} media types.
306 @item mm-automatic-display
307 @vindex mm-automatic-display
308 This is a list of types that are to be displayed ``automatically'', but
309 only if the above variable allows it. That is, only inlinable parts can
310 be displayed automatically.
312 @item mm-automatic-external-display
313 @vindex mm-automatic-external-display
314 This is a list of types that will be displayed automatically in an
317 @item mm-keep-viewer-alive-types
318 @vindex mm-keep-viewer-alive-types
319 This is a list of media types for which the external viewer will not
320 be killed when selecting a different article.
322 @item mm-attachment-override-types
323 @vindex mm-attachment-override-types
324 Some @acronym{MIME} agents create parts that have a content-disposition of
325 @samp{attachment}. This variable allows overriding that disposition and
326 displaying the part inline. (Note that the disposition is only
327 overridden if we are able to, and want to, display the part inline.)
329 @item mm-discouraged-alternatives
330 @vindex mm-discouraged-alternatives
331 List of @acronym{MIME} types that are discouraged when viewing
332 @samp{multipart/alternative}. Viewing agents are supposed to view the
333 last possible part of a message, as that is supposed to be the richest.
334 However, users may prefer other types instead, and this list says what
335 types are most unwanted. If, for instance, @samp{text/html} parts are
336 very unwanted, and @samp{text/richtext} parts are somewhat unwanted,
337 you could say something like:
340 (setq mm-discouraged-alternatives
341 '("text/html" "text/richtext")
343 (remove "text/html" mm-automatic-display))
346 @item mm-inline-large-images
347 @vindex mm-inline-large-images
348 When displaying inline images that are larger than the window, Emacs
349 does not enable scrolling, which means that you cannot see the whole
350 image. To prevent this, the library tries to determine the image size
351 before displaying it inline, and if it doesn't fit the window, the
352 library will display it externally (e.g. with @samp{ImageMagick} or
353 @samp{xv}). Setting this variable to @code{t} disables this check and
354 makes the library display all inline images as inline, regardless of
357 @item mm-inline-override-types
358 @vindex mm-inline-override-types
359 @code{mm-inlined-types} may include regular expressions, for example to
360 specify that all @samp{text/.*} parts be displayed inline. If a user
361 prefers to have a type that matches such a regular expression be treated
362 as an attachment, that can be accomplished by setting this variable to a
363 list containing that type. For example assuming @code{mm-inlined-types}
364 includes @samp{text/.*}, then including @samp{text/html} in this
365 variable will cause @samp{text/html} parts to be treated as attachments.
367 @item mm-text-html-renderer
368 @vindex mm-text-html-renderer
369 This selects the function used to render @acronym{HTML}. The predefined
370 renderers are selected by the symbols @code{w3},
371 @code{w3m}@footnote{See @uref{http://emacs-w3m.namazu.org/} for more
372 information about emacs-w3m}, @code{links}, @code{lynx},
373 @code{w3m-standalone} or @code{html2text}. If @code{nil} use an
374 external viewer. You can also specify a function, which will be
375 called with a @acronym{MIME} handle as the argument.
377 @item mm-inline-text-html-with-images
378 @vindex mm-inline-text-html-with-images
379 Some @acronym{HTML} mails might have the trick of spammers using
380 @samp{<img>} tags. It is likely to be intended to verify whether you
381 have read the mail. You can prevent your personal informations from
382 leaking by setting this option to @code{nil} (which is the default).
383 It is currently ignored by Emacs/w3. For emacs-w3m, you may use the
384 command @kbd{t} on the image anchor to show an image even if it is
385 @code{nil}.@footnote{The command @kbd{T} will load all images. If you
386 have set the option @code{w3m-key-binding} to @code{info}, use @kbd{i}
389 @item mm-w3m-safe-url-regexp
390 @vindex mm-w3m-safe-url-regexp
391 A regular expression that matches safe URL names, i.e. URLs that are
392 unlikely to leak personal information when rendering @acronym{HTML}
393 email (the default value is @samp{\\`cid:}). If @code{nil} consider
396 @item mm-inline-text-html-with-w3m-keymap
397 @vindex mm-inline-text-html-with-w3m-keymap
398 You can use emacs-w3m command keys in the inlined text/html part by
399 setting this option to non-@code{nil}. The default value is @code{t}.
401 @item mm-external-terminal-program
402 @vindex mm-external-terminal-program
403 The program used to start an external terminal.
405 @item mm-enable-external
406 @vindex mm-enable-external
407 Indicate whether external @acronym{MIME} handlers should be used.
409 If @code{t}, all defined external @acronym{MIME} handlers are used. If
410 @code{nil}, files are saved to disk (@code{mailcap-save-binary-file}).
411 If it is the symbol @code{ask}, you are prompted before the external
412 @acronym{MIME} handler is invoked.
414 When you launch an attachment through mailcap (@pxref{mailcap}) an
415 attempt is made to use a safe viewer with the safest options---this isn't
416 the case if you save it to disk and launch it in a different way
417 (command line or double-clicking). Anyhow, if you want to be sure not
418 to launch any external programs, set this variable to @code{nil} or
423 @node Files and Directories
424 @section Files and Directories
428 @item mm-default-directory
429 @vindex mm-default-directory
430 The default directory for saving attachments. If @code{nil} use
431 @code{default-directory}.
433 @item mm-tmp-directory
434 @vindex mm-tmp-directory
435 Directory for storing temporary files.
437 @item mm-file-name-rewrite-functions
438 @vindex mm-file-name-rewrite-functions
439 A list of functions used for rewriting file names of @acronym{MIME}
440 parts. Each function is applied successively to the file name.
441 Ready-made functions include
444 @item mm-file-name-delete-control
445 @findex mm-file-name-delete-control
446 Delete all control characters.
448 @item mm-file-name-delete-gotchas
449 @findex mm-file-name-delete-gotchas
450 Delete characters that could have unintended consequences when used
451 with flawed shell scripts, i.e. @samp{|}, @samp{>} and @samp{<}; and
452 @samp{-}, @samp{.} as the first character.
454 @item mm-file-name-delete-whitespace
455 @findex mm-file-name-delete-whitespace
456 Remove all whitespace.
458 @item mm-file-name-trim-whitespace
459 @findex mm-file-name-trim-whitespace
460 Remove leading and trailing whitespace.
462 @item mm-file-name-collapse-whitespace
463 @findex mm-file-name-collapse-whitespace
464 Collapse multiple whitespace characters.
466 @item mm-file-name-replace-whitespace
467 @findex mm-file-name-replace-whitespace
468 @vindex mm-file-name-replace-whitespace
469 Replace whitespace with underscores. Set the variable
470 @code{mm-file-name-replace-whitespace} to any other string if you do
471 not like underscores.
474 The standard Emacs functions @code{capitalize}, @code{downcase},
475 @code{upcase} and @code{upcase-initials} might also prove useful.
477 @item mm-path-name-rewrite-functions
478 @vindex mm-path-name-rewrite-functions
479 List of functions used for rewriting the full file names of @acronym{MIME}
480 parts. This is used when viewing parts externally, and is meant for
481 transforming the absolute name so that non-compliant programs can find
482 the file where it's saved.
489 Here's an example viewer for displaying @code{text/enriched} inline:
492 (defun mm-display-enriched-inline (handle)
495 (mm-insert-part handle)
496 (save-window-excursion
497 (enriched-decode (point-min) (point-max))
498 (setq text (buffer-string))))
499 (mm-insert-inline handle text)))
502 We see that the function takes a @acronym{MIME} handle as its parameter. It
503 then goes to a temporary buffer, inserts the text of the part, does some
504 work on the text, stores the result, goes back to the buffer it was
505 called from and inserts the result.
507 The two important helper functions here are @code{mm-insert-part} and
508 @code{mm-insert-inline}. The first function inserts the text of the
509 handle in the current buffer. It handles charset and/or content
510 transfer decoding. The second function just inserts whatever text you
511 tell it to insert, but it also sets things up so that the text can be
512 ``undisplayed'' in a convenient manner.
518 @cindex MIME Composing
520 @cindex MIME Meta Language
522 Creating a @acronym{MIME} message is boring and non-trivial. Therefore,
523 a library called @code{mml} has been defined that parses a language
524 called @acronym{MML} (@acronym{MIME} Meta Language) and generates
525 @acronym{MIME} messages.
527 @findex mml-generate-mime
528 The main interface function is @code{mml-generate-mime}. It will
529 examine the contents of the current (narrowed-to) buffer and return a
530 string containing the @acronym{MIME} message.
533 * Simple MML Example:: An example @acronym{MML} document.
534 * MML Definition:: All valid @acronym{MML} elements.
535 * Advanced MML Example:: Another example @acronym{MML} document.
536 * Encoding Customization:: Variables that affect encoding.
537 * Charset Translation:: How charsets are mapped from @sc{mule} to @acronym{MIME}.
538 * Conversion:: Going from @acronym{MIME} to @acronym{MML} and vice versa.
539 * Flowed text:: Soft and hard newlines.
543 @node Simple MML Example
544 @section Simple MML Example
546 Here's a simple @samp{multipart/alternative}:
549 <#multipart type=alternative>
550 This is a plain text part.
551 <#part type=text/enriched>
552 <center>This is a centered enriched part</center>
556 After running this through @code{mml-generate-mime}, we get this:
559 Content-Type: multipart/alternative; boundary="=-=-="
565 This is a plain text part.
568 Content-Type: text/enriched
571 <center>This is a centered enriched part</center>
578 @section MML Definition
580 The @acronym{MML} language is very simple. It looks a bit like an SGML
581 application, but it's not.
583 The main concept of @acronym{MML} is the @dfn{part}. Each part can be of a
584 different type or use a different charset. The way to delineate a part
585 is with a @samp{<#part ...>} tag. Multipart parts can be introduced
586 with the @samp{<#multipart ...>} tag. Parts are ended by the
587 @samp{<#/part>} or @samp{<#/multipart>} tags. Parts started with the
588 @samp{<#part ...>} tags are also closed by the next open tag.
590 There's also the @samp{<#external ...>} tag. These introduce
591 @samp{external/message-body} parts.
593 Each tag can contain zero or more parameters on the form
594 @samp{parameter=value}. The values may be enclosed in quotation marks,
595 but that's not necessary unless the value contains white space. So
596 @samp{filename=/home/user/#hello$^yes} is perfectly valid.
598 The following parameters have meaning in @acronym{MML}; parameters that have no
599 meaning are ignored. The @acronym{MML} parameter names are the same as the
600 @acronym{MIME} parameter names; the things in the parentheses say which
601 header it will be used in.
605 The @acronym{MIME} type of the part (@code{Content-Type}).
608 Use the contents of the file in the body of the part
609 (@code{Content-Disposition}).
612 The contents of the body of the part are to be encoded in the character
613 set specified (@code{Content-Type}). @xref{Charset Translation}.
616 Might be used to suggest a file name if the part is to be saved
617 to a file (@code{Content-Type}).
620 Valid values are @samp{inline} and @samp{attachment}
621 (@code{Content-Disposition}).
624 Valid values are @samp{7bit}, @samp{8bit}, @samp{quoted-printable} and
625 @samp{base64} (@code{Content-Transfer-Encoding}). @xref{Charset
629 A description of the part (@code{Content-Description}).
632 RFC822 date when the part was created (@code{Content-Disposition}).
634 @item modification-date
635 RFC822 date when the part was modified (@code{Content-Disposition}).
638 RFC822 date when the part was read (@code{Content-Disposition}).
641 Who to encrypt/sign the part to. This field is used to override any
642 auto-detection based on the To/CC headers.
645 Identity used to sign the part. This field is used to override the
649 The size (in octets) of the part (@code{Content-Disposition}).
652 What technology to sign this @acronym{MML} part with (@code{smime}, @code{pgp}
656 What technology to encrypt this @acronym{MML} part with (@code{smime},
657 @code{pgp} or @code{pgpmime})
661 Parameters for @samp{text/plain}:
665 Formatting parameter for the text, valid values include @samp{fixed}
666 (the default) and @samp{flowed}. Normally you do not specify this
667 manually, since it requires the textual body to be formatted in a
668 special way described in RFC 2646. @xref{Flowed text}.
671 Parameters for @samp{application/octet-stream}:
675 Type of the part; informal---meant for human readers
676 (@code{Content-Type}).
679 Parameters for @samp{message/external-body}:
683 A word indicating the supported access mechanism by which the file may
684 be obtained. Values include @samp{ftp}, @samp{anon-ftp}, @samp{tftp},
685 @samp{localfile}, and @samp{mailserver}. (@code{Content-Type}.)
688 The RFC822 date after which the file may no longer be fetched.
689 (@code{Content-Type}.)
692 The size (in octets) of the file. (@code{Content-Type}.)
695 Valid values are @samp{read} and @samp{read-write}
696 (@code{Content-Type}).
700 Parameters for @samp{sign=smime}:
705 File containing key and certificate for signer.
709 Parameters for @samp{encrypt=smime}:
714 File containing certificate for recipient.
719 @node Advanced MML Example
720 @section Advanced MML Example
722 Here's a complex multipart message. It's a @samp{multipart/mixed} that
723 contains many parts, one of which is a @samp{multipart/alternative}.
726 <#multipart type=mixed>
727 <#part type=image/jpeg filename=~/rms.jpg disposition=inline>
728 <#multipart type=alternative>
729 This is a plain text part.
730 <#part type=text/enriched name=enriched.txt>
731 <center>This is a centered enriched part</center>
733 This is a new plain text part.
734 <#part disposition=attachment>
735 This plain text part is an attachment.
739 And this is the resulting @acronym{MIME} message:
742 Content-Type: multipart/mixed; boundary="=-=-="
750 Content-Type: image/jpeg;
752 Content-Disposition: inline;
754 Content-Transfer-Encoding: base64
756 /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof
757 Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/wAALCAAwADABAREA/8QAHwAA
758 AQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQR
759 BRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RF
760 RkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ip
761 qrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/9oACAEB
762 AAA/AO/rifFHjldNuGsrDa0qcSSHkA+gHrXKw+LtWLrMb+RgTyhbr+HSug07xNqV9fQtZrNI
763 AyiaE/NuBPOOOP0rvRNE880KOC8TbXXGCv1FPqjrF4LDR7u5L7SkTFT/ALWOP1xXgTuXfc7E
764 sx6nua6rwp4IvvEM8chCxWxOdzn7wz6V9AaB4S07w9p5itow0rDLSY5Pt9K43xO66P4xs71m
765 2QXiGCbA4yOVJ9+1aYORkdK434lyNH4ahCnG66VT9Nj15JFbPdX0MS43M4VQf5/yr2vSpLnw
766 5ZW8dlCZ8KFXjOPX0/mK6rSPEGt3Angu44fNEReHYNvIH3TzXDeKNO8RX+kSX2ouZkicTIOc
767 L+g7E810ulFjpVtv3bwgB3HJyK5L4quY/C9sVxk3ij/xx6850u7t1mtp/wDlpEw3An3Jr3Dw
768 34gsbWza4nBlhC5LDsaW6+IFgupQyCF3iHH7gA7c9R9ay7zx6t7aX9jHC4smhfBkGCvHGfrm
769 tLQ7hbnRrV1GPkAP1x1/Hr+Ncr8Vzjwrbf8AX6v/AKA9eQRyYlQk8Yx9K6XTNbkgia2ciSIn
770 7p5Ga9Atte0LTLKO6it4i7dVRFJDcZ4PvXN+JvEMF9bILVGXJLSZ4zkjivRPDaeX4b08HOTC
771 pOffmua+KkbS+GLVUGT9tT/0B68eeIpIFYjB70+OOVXyoOM9+M1eaWeCLzHPyHGO/NVWvJJm
772 jQ8KGH1NfQWhXSXmh2c8eArRLwO3HSv/2Q==
775 Content-Type: multipart/alternative; boundary="==-=-="
781 This is a plain text part.
784 Content-Type: text/enriched;
788 <center>This is a centered enriched part</center>
794 This is a new plain text part.
797 Content-Disposition: attachment
800 This plain text part is an attachment.
805 @node Encoding Customization
806 @section Encoding Customization
810 @item mm-body-charset-encoding-alist
811 @vindex mm-body-charset-encoding-alist
812 Mapping from @acronym{MIME} charset to encoding to use. This variable is
813 usually used except, e.g., when other requirements force a specific
814 encoding (digitally signed messages require 7bit encodings). The
818 ((iso-2022-jp . 7bit)
819 (iso-2022-jp-2 . 7bit)
825 As an example, if you do not want to have ISO-8859-1 characters
826 quoted-printable encoded, you may add @code{(iso-8859-1 . 8bit)} to
827 this variable. You can override this setting on a per-message basis
828 by using the @code{encoding} @acronym{MML} tag (@pxref{MML Definition}).
830 @item mm-coding-system-priorities
831 @vindex mm-coding-system-priorities
832 Prioritize coding systems to use for outgoing messages. The default
833 is @code{nil}, which means to use the defaults in Emacs. It is a list of
834 coding system symbols (aliases of coding systems are also allowed, use
835 @kbd{M-x describe-coding-system} to make sure you are specifying correct
836 coding system names). For example, if you have configured Emacs
837 to prefer UTF-8, but wish that outgoing messages should be sent in
838 ISO-8859-1 if possible, you can set this variable to
839 @code{(iso-8859-1)}. You can override this setting on a per-message
840 basis by using the @code{charset} @acronym{MML} tag (@pxref{MML Definition}).
842 @item mm-content-transfer-encoding-defaults
843 @vindex mm-content-transfer-encoding-defaults
844 Mapping from @acronym{MIME} types to encoding to use. This variable is usually
845 used except, e.g., when other requirements force a safer encoding
846 (digitally signed messages require 7bit encoding). Besides the normal
847 @acronym{MIME} encodings, @code{qp-or-base64} may be used to indicate that for
848 each case the most efficient of quoted-printable and base64 should be
851 @code{qp-or-base64} has another effect. It will fold long lines so that
852 MIME parts may not be broken by MTA. So do @code{quoted-printable} and
855 Note that it affects body encoding only when a part is a raw forwarded
856 message (which will be made by @code{gnus-summary-mail-forward} with the
857 arg 2 for example) or is neither the @samp{text/*} type nor the
858 @samp{message/*} type. Even though in those cases, you can override
859 this setting on a per-message basis by using the @code{encoding}
860 @acronym{MML} tag (@pxref{MML Definition}).
862 @item mm-use-ultra-safe-encoding
863 @vindex mm-use-ultra-safe-encoding
864 When this is non-@code{nil}, it means that textual parts are encoded as
865 quoted-printable if they contain lines longer than 76 characters or
866 starting with "From " in the body. Non-7bit encodings (8bit, binary)
867 are generally disallowed. This reduce the probability that a non-8bit
868 clean MTA or MDA changes the message. This should never be set
869 directly, but bound by other functions when necessary (e.g., when
870 encoding messages that are to be digitally signed).
874 @node Charset Translation
875 @section Charset Translation
878 During translation from @acronym{MML} to @acronym{MIME}, for each
879 @acronym{MIME} part which has been composed inside Emacs, an appropriate
880 charset has to be chosen.
882 @vindex mail-parse-charset
883 If you are running a non-@sc{mule} Emacs, this process is simple: If the
884 part contains any non-@acronym{ASCII} (8-bit) characters, the @acronym{MIME} charset
885 given by @code{mail-parse-charset} (a symbol) is used. (Never set this
886 variable directly, though. If you want to change the default charset,
887 please consult the documentation of the package which you use to process
888 @acronym{MIME} messages.
889 @xref{Various Message Variables, , Various Message Variables, message,
890 Message Manual}, for example.)
891 If there are only @acronym{ASCII} characters, the @acronym{MIME} charset US-ASCII is
897 @vindex mm-mime-mule-charset-alist
898 Things are slightly more complicated when running Emacs with @sc{mule}
899 support. In this case, a list of the @sc{mule} charsets used in the
900 part is obtained, and the @sc{mule} charsets are translated to @acronym{MIME}
901 charsets by consulting the variable @code{mm-mime-mule-charset-alist}.
902 If this results in a single @acronym{MIME} charset, this is used to encode
903 the part. But if the resulting list of @acronym{MIME} charsets contains more
904 than one element, two things can happen: If it is possible to encode the
905 part via UTF-8, this charset is used. (For this, Emacs must support
906 the @code{utf-8} coding system, and the part must consist entirely of
907 characters which have Unicode counterparts.) If UTF-8 is not available
908 for some reason, the part is split into several ones, so that each one
909 can be encoded with a single @acronym{MIME} charset. The part can only be
910 split at line boundaries, though---if more than one @acronym{MIME} charset is
911 required to encode a single line, it is not possible to encode the part.
913 When running Emacs with @sc{mule} support, the preferences for which
914 coding system to use is inherited from Emacs itself. This means that
915 if Emacs is set up to prefer UTF-8, it will be used when encoding
916 messages. You can modify this by altering the
917 @code{mm-coding-system-priorities} variable though (@pxref{Encoding
920 The charset to be used can be overridden by setting the @code{charset}
921 @acronym{MML} tag (@pxref{MML Definition}) when composing the message.
923 The encoding of characters (quoted-printable, 8bit etc) is orthogonal
924 to the discussion here, and is controlled by the variables
925 @code{mm-body-charset-encoding-alist} and
926 @code{mm-content-transfer-encoding-defaults} (@pxref{Encoding
933 A (multipart) @acronym{MIME} message can be converted to @acronym{MML}
934 with the @code{mime-to-mml} function. It works on the message in the
935 current buffer, and substitutes @acronym{MML} markup for @acronym{MIME}
936 boundaries. Non-textual parts do not have their contents in the buffer,
937 but instead have the contents in separate buffers that are referred to
938 from the @acronym{MML} tags.
941 An @acronym{MML} message can be converted back to @acronym{MIME} by the
942 @code{mml-to-mime} function.
944 These functions are in certain senses ``lossy''---you will not get back
945 an identical message if you run @code{mime-to-mml} and then
946 @code{mml-to-mime}. Not only will trivial things like the order of the
947 headers differ, but the contents of the headers may also be different.
948 For instance, the original message may use base64 encoding on text,
949 while @code{mml-to-mime} may decide to use quoted-printable encoding, and
952 In essence, however, these two functions should be the inverse of each
953 other. The resulting contents of the message should remain equivalent,
959 @cindex format=flowed
961 The Emacs @acronym{MIME} library will respect the @code{use-hard-newlines}
962 variable (@pxref{Hard and Soft Newlines, ,Hard and Soft Newlines,
963 emacs, Emacs Manual}) when encoding a message, and the
964 ``format=flowed'' Content-Type parameter when decoding a message.
966 On encoding text, regardless of @code{use-hard-newlines}, lines
967 terminated by soft newline characters are filled together and wrapped
968 after the column decided by @code{fill-flowed-encode-column}.
969 Quotation marks (matching @samp{^>* ?}) are respected. The variable
970 controls how the text will look in a client that does not support
971 flowed text, the default is to wrap after 66 characters. If hard
972 newline characters are not present in the buffer, no flow encoding
975 On decoding flowed text, lines with soft newline characters are filled
976 together and wrapped after the column decided by
977 @code{fill-flowed-display-column}. The default is to wrap after
982 @vindex mm-fill-flowed
983 If non-@code{nil} a format=flowed article will be displayed flowed.
987 @node Interface Functions
988 @chapter Interface Functions
989 @cindex interface functions
992 The @code{mail-parse} library is an abstraction over the actual
993 low-level libraries that are described in the next chapter.
995 Standards change, and so programs have to change to fit in the new
996 mold. For instance, RFC2045 describes a syntax for the
997 @code{Content-Type} header that only allows @acronym{ASCII} characters in the
998 parameter list. RFC2231 expands on RFC2045 syntax to provide a scheme
999 for continuation headers and non-@acronym{ASCII} characters.
1001 The traditional way to deal with this is just to update the library
1002 functions to parse the new syntax. However, this is sometimes the wrong
1003 thing to do. In some instances it may be vital to be able to understand
1004 both the old syntax as well as the new syntax, and if there is only one
1005 library, one must choose between the old version of the library and the
1006 new version of the library.
1008 The Emacs @acronym{MIME} library takes a different tack. It defines a
1009 series of low-level libraries (@file{rfc2047.el}, @file{rfc2231.el}
1010 and so on) that parses strictly according to the corresponding
1011 standard. However, normal programs would not use the functions
1012 provided by these libraries directly, but instead use the functions
1013 provided by the @code{mail-parse} library. The functions in this
1014 library are just aliases to the corresponding functions in the latest
1015 low-level libraries. Using this scheme, programs get a consistent
1016 interface they can use, and library developers are free to create
1017 write code that handles new standards.
1019 The following functions are defined by this library:
1022 @item mail-header-parse-content-type
1023 @findex mail-header-parse-content-type
1024 Parse a @code{Content-Type} header and return a list on the following
1029 (attribute1 . value1)
1030 (attribute2 . value2)
1037 (mail-header-parse-content-type
1038 "image/gif; name=\"b980912.gif\"")
1039 @result{} ("image/gif" (name . "b980912.gif"))
1042 @item mail-header-parse-content-disposition
1043 @findex mail-header-parse-content-disposition
1044 Parse a @code{Content-Disposition} header and return a list on the same
1045 format as the function above.
1047 @item mail-content-type-get
1048 @findex mail-content-type-get
1049 Takes two parameters---a list on the format above, and an attribute.
1050 Returns the value of the attribute.
1053 (mail-content-type-get
1054 '("image/gif" (name . "b980912.gif")) 'name)
1055 @result{} "b980912.gif"
1058 @item mail-header-encode-parameter
1059 @findex mail-header-encode-parameter
1060 Takes a parameter string and returns an encoded version of the string.
1061 This is used for parameters in headers like @code{Content-Type} and
1062 @code{Content-Disposition}.
1064 @item mail-header-remove-comments
1065 @findex mail-header-remove-comments
1066 Return a comment-free version of a header.
1069 (mail-header-remove-comments
1070 "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
1071 @result{} "Gnus/5.070027 "
1074 @item mail-header-remove-whitespace
1075 @findex mail-header-remove-whitespace
1076 Remove linear white space from a header. Space inside quoted strings
1077 and comments is preserved.
1080 (mail-header-remove-whitespace
1081 "image/gif; name=\"Name with spaces\"")
1082 @result{} "image/gif;name=\"Name with spaces\""
1085 @item mail-header-get-comment
1086 @findex mail-header-get-comment
1087 Return the last comment in a header.
1090 (mail-header-get-comment
1091 "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
1092 @result{} "Finnish Landrace"
1095 @item mail-header-parse-address
1096 @findex mail-header-parse-address
1097 Parse an address and return a list containing the mailbox and the
1101 (mail-header-parse-address
1102 "Hrvoje Niksic <hniksic@@srce.hr>")
1103 @result{} ("hniksic@@srce.hr" . "Hrvoje Niksic")
1106 @item mail-header-parse-addresses
1107 @findex mail-header-parse-addresses
1108 Parse a string with list of addresses and return a list of elements like
1109 the one described above.
1112 (mail-header-parse-addresses
1113 "Hrvoje Niksic <hniksic@@srce.hr>, Steinar Bang <sb@@metis.no>")
1114 @result{} (("hniksic@@srce.hr" . "Hrvoje Niksic")
1115 ("sb@@metis.no" . "Steinar Bang"))
1118 @item mail-header-parse-date
1119 @findex mail-header-parse-date
1120 Parse a date string and return an Emacs time structure.
1122 @item mail-narrow-to-head
1123 @findex mail-narrow-to-head
1124 Narrow the buffer to the header section of the buffer. Point is placed
1125 at the beginning of the narrowed buffer.
1127 @item mail-header-narrow-to-field
1128 @findex mail-header-narrow-to-field
1129 Narrow the buffer to the header under point. Understands continuation
1132 @item mail-header-fold-field
1133 @findex mail-header-fold-field
1134 Fold the header under point.
1136 @item mail-header-unfold-field
1137 @findex mail-header-unfold-field
1138 Unfold the header under point.
1140 @item mail-header-field-value
1141 @findex mail-header-field-value
1142 Return the value of the field under point.
1144 @item mail-encode-encoded-word-region
1145 @findex mail-encode-encoded-word-region
1146 Encode the non-@acronym{ASCII} words in the region. For instance,
1147 @samp{Na@"{@dotless{i}}ve} is encoded as @samp{=?iso-8859-1?q?Na=EFve?=}.
1149 @item mail-encode-encoded-word-buffer
1150 @findex mail-encode-encoded-word-buffer
1151 Encode the non-@acronym{ASCII} words in the current buffer. This function is
1152 meant to be called narrowed to the headers of a message.
1154 @item mail-encode-encoded-word-string
1155 @findex mail-encode-encoded-word-string
1156 Encode the words that need encoding in a string, and return the result.
1159 (mail-encode-encoded-word-string
1160 "This is na@"{@dotless{i}}ve, baby")
1161 @result{} "This is =?iso-8859-1?q?na=EFve,?= baby"
1164 @item mail-decode-encoded-word-region
1165 @findex mail-decode-encoded-word-region
1166 Decode the encoded words in the region.
1168 @item mail-decode-encoded-word-string
1169 @findex mail-decode-encoded-word-string
1170 Decode the encoded words in the string and return the result.
1173 (mail-decode-encoded-word-string
1174 "This is =?iso-8859-1?q?na=EFve,?= baby")
1175 @result{} "This is na@"{@dotless{i}}ve, baby"
1180 Currently, @code{mail-parse} is an abstraction over @code{ietf-drums},
1181 @code{rfc2047}, @code{rfc2045} and @code{rfc2231}. These are documented
1182 in the subsequent sections.
1186 @node Basic Functions
1187 @chapter Basic Functions
1189 This chapter describes the basic, ground-level functions for parsing and
1190 handling. Covered here is parsing @code{From} lines, removing comments
1191 from header lines, decoding encoded words, parsing date headers and so
1192 on. High-level functionality is dealt with in the next chapter
1193 (@pxref{Decoding and Viewing}).
1196 * rfc2045:: Encoding @code{Content-Type} headers.
1197 * rfc2231:: Parsing @code{Content-Type} headers.
1198 * ietf-drums:: Handling mail headers defined by RFC822bis.
1199 * rfc2047:: En/decoding encoded words in headers.
1200 * time-date:: Functions for parsing dates and manipulating time.
1201 * qp:: Quoted-Printable en/decoding.
1202 * base64:: Base64 en/decoding.
1203 * binhex:: Binhex decoding.
1204 * uudecode:: Uuencode decoding.
1205 * yenc:: Yenc decoding.
1206 * rfc1843:: Decoding HZ-encoded text.
1207 * mailcap:: How parts are displayed is specified by the @file{.mailcap} file
1214 RFC2045 is the ``main'' @acronym{MIME} document, and as such, one would
1215 imagine that there would be a lot to implement. But there isn't, since
1216 most of the implementation details are delegated to the subsequent
1219 So @file{rfc2045.el} has only a single function:
1222 @item rfc2045-encode-string
1223 @findex rfc2045-encode-string
1224 Takes a parameter and a value and returns a @samp{PARAM=VALUE} string.
1225 @var{value} will be quoted if there are non-safe characters in it.
1232 RFC2231 defines a syntax for the @code{Content-Type} and
1233 @code{Content-Disposition} headers. Its snappy name is @dfn{MIME
1234 Parameter Value and Encoded Word Extensions: Character Sets, Languages,
1237 In short, these headers look something like this:
1240 Content-Type: application/x-stuff;
1241 title*0*=us-ascii'en'This%20is%20even%20more%20;
1242 title*1*=%2A%2A%2Afun%2A%2A%2A%20;
1246 They usually aren't this bad, though.
1248 The following functions are defined by this library:
1251 @item rfc2231-parse-string
1252 @findex rfc2231-parse-string
1253 Parse a @code{Content-Type} header and return a list describing its
1257 (rfc2231-parse-string
1258 "application/x-stuff;
1259 title*0*=us-ascii'en'This%20is%20even%20more%20;
1260 title*1*=%2A%2A%2Afun%2A%2A%2A%20;
1261 title*2=\"isn't it!\"")
1262 @result{} ("application/x-stuff"
1263 (title . "This is even more ***fun*** isn't it!"))
1266 @item rfc2231-get-value
1267 @findex rfc2231-get-value
1268 Takes one of the lists on the format above and returns
1269 the value of the specified attribute.
1271 @item rfc2231-encode-string
1272 @findex rfc2231-encode-string
1273 Encode a parameter in headers likes @code{Content-Type} and
1274 @code{Content-Disposition}.
1282 @dfn{drums} is an IETF working group that is working on the replacement
1285 The functions provided by this library include:
1288 @item ietf-drums-remove-comments
1289 @findex ietf-drums-remove-comments
1290 Remove the comments from the argument and return the results.
1292 @item ietf-drums-remove-whitespace
1293 @findex ietf-drums-remove-whitespace
1294 Remove linear white space from the string and return the results.
1295 Spaces inside quoted strings and comments are left untouched.
1297 @item ietf-drums-get-comment
1298 @findex ietf-drums-get-comment
1299 Return the last most comment from the string.
1301 @item ietf-drums-parse-address
1302 @findex ietf-drums-parse-address
1303 Parse an address string and return a list that contains the mailbox and
1304 the plain text name.
1306 @item ietf-drums-parse-addresses
1307 @findex ietf-drums-parse-addresses
1308 Parse a string that contains any number of comma-separated addresses and
1309 return a list that contains mailbox/plain text pairs.
1311 @item ietf-drums-parse-date
1312 @findex ietf-drums-parse-date
1313 Parse a date string and return an Emacs time structure.
1315 @item ietf-drums-narrow-to-header
1316 @findex ietf-drums-narrow-to-header
1317 Narrow the buffer to the header section of the current buffer.
1325 RFC2047 (Message Header Extensions for Non-@acronym{ASCII} Text) specifies how
1326 non-@acronym{ASCII} text in headers are to be encoded. This is actually rather
1327 complicated, so a number of variables are necessary to tweak what this
1330 The following variables are tweakable:
1333 @item rfc2047-header-encoding-alist
1334 @vindex rfc2047-header-encoding-alist
1335 This is an alist of header / encoding-type pairs. Its main purpose is
1336 to prevent encoding of certain headers.
1338 The keys can either be header regexps, or @code{t}.
1340 The values can be @code{nil}, in which case the header(s) in question
1341 won't be encoded, @code{mime}, which means that they will be encoded, or
1342 @code{address-mime}, which means the header(s) will be encoded carefully
1343 assuming they contain addresses.
1345 @item rfc2047-charset-encoding-alist
1346 @vindex rfc2047-charset-encoding-alist
1347 RFC2047 specifies two forms of encoding---@code{Q} (a
1348 Quoted-Printable-like encoding) and @code{B} (base64). This alist
1349 specifies which charset should use which encoding.
1351 @item rfc2047-encode-function-alist
1352 @vindex rfc2047-encode-function-alist
1353 This is an alist of encoding / function pairs. The encodings are
1354 @code{Q}, @code{B} and @code{nil}.
1356 @item rfc2047-encoded-word-regexp
1357 @vindex rfc2047-encoded-word-regexp
1358 When decoding words, this library looks for matches to this regexp.
1360 @item rfc2047-encode-encoded-words
1361 @vindex rfc2047-encode-encoded-words
1362 The boolean variable specifies whether encoded words
1363 (e.g. @samp{=?hello?=}) should be encoded again.
1367 Those were the variables, and these are this functions:
1370 @item rfc2047-narrow-to-field
1371 @findex rfc2047-narrow-to-field
1372 Narrow the buffer to the header on the current line.
1374 @item rfc2047-encode-message-header
1375 @findex rfc2047-encode-message-header
1376 Should be called narrowed to the header of a message. Encodes according
1377 to @code{rfc2047-header-encoding-alist}.
1379 @item rfc2047-encode-region
1380 @findex rfc2047-encode-region
1381 Encodes all encodable words in the region specified.
1383 @item rfc2047-encode-string
1384 @findex rfc2047-encode-string
1385 Encode a string and return the results.
1387 @item rfc2047-decode-region
1388 @findex rfc2047-decode-region
1389 Decode the encoded words in the region.
1391 @item rfc2047-decode-string
1392 @findex rfc2047-decode-string
1393 Decode a string and return the results.
1395 @item rfc2047-encode-parameter
1396 @findex rfc2047-encode-parameter
1397 Encode a parameter in the RFC2047-like style. This is a replacement for
1398 the @code{rfc2231-encode-string} function. @xref{rfc2231}.
1400 When attaching files as @acronym{MIME} parts, we should use the RFC2231
1401 encoding to specify the file names containing non-@acronym{ASCII}
1402 characters. However, many mail softwares don't support it in practice
1403 and recipients won't be able to extract files with correct names.
1404 Instead, the RFC2047-like encoding is acceptable generally. This
1405 function provides the very RFC2047-like encoding, resigning to such a
1406 regrettable trend. To use it, put the following line in your
1407 @file{~/.gnus.el} file:
1410 (defalias 'mail-header-encode-parameter 'rfc2047-encode-parameter)
1419 While not really a part of the @acronym{MIME} library, it is convenient to
1420 document this library here. It deals with parsing @code{Date} headers
1421 and manipulating time. (Not by using tesseracts, though, I'm sorry to
1424 These functions convert between five formats: A date string, an Emacs
1425 time structure, a decoded time list, a second number, and a day number.
1427 Here's a bunch of time/date/second/day examples:
1430 (parse-time-string "Sat Sep 12 12:21:54 1998 +0200")
1431 @result{} (54 21 12 12 9 1998 6 nil 7200)
1433 (date-to-time "Sat Sep 12 12:21:54 1998 +0200")
1434 @result{} (13818 19266)
1436 (time-to-seconds '(13818 19266))
1437 @result{} 905595714.0
1439 (seconds-to-time 905595714.0)
1440 @result{} (13818 19266 0)
1442 (time-to-days '(13818 19266))
1445 (days-to-time 729644)
1446 @result{} (961933 65536)
1448 (time-since '(13818 19266))
1451 (time-less-p '(13818 19266) '(13818 19145))
1454 (subtract-time '(13818 19266) '(13818 19145))
1457 (days-between "Sat Sep 12 12:21:54 1998 +0200"
1458 "Sat Sep 07 12:21:54 1998 +0200")
1461 (date-leap-year-p 2000)
1464 (time-to-day-in-year '(13818 19266))
1467 (time-to-number-of-days
1469 (date-to-time "Mon, 01 Jan 2001 02:22:26 GMT")))
1470 @result{} 4.146122685185185
1473 And finally, we have @code{safe-date-to-time}, which does the same as
1474 @code{date-to-time}, but returns a zero time if the date is
1475 syntactically malformed.
1477 The five data representations used are the following:
1481 An RFC822 (or similar) date string. For instance: @code{"Sat Sep 12
1482 12:21:54 1998 +0200"}.
1485 An internal Emacs time. For instance: @code{(13818 26466)}.
1488 A floating point representation of the internal Emacs time. For
1489 instance: @code{905595714.0}.
1492 An integer number representing the number of days since 00000101. For
1493 instance: @code{729644}.
1496 A list of decoded time. For instance: @code{(54 21 12 12 9 1998 6 t
1500 All the examples above represent the same moment.
1502 These are the functions available:
1506 Take a date and return a time.
1508 @item time-to-seconds
1509 Take a time and return seconds.
1511 @item seconds-to-time
1512 Take seconds and return a time.
1515 Take a time and return days.
1518 Take days and return a time.
1521 Take a date and return days.
1523 @item time-to-number-of-days
1524 Take a time and return the number of days that represents.
1526 @item safe-date-to-time
1527 Take a date and return a time. If the date is not syntactically valid,
1528 return a ``zero'' date.
1531 Take two times and say whether the first time is less (i. e., earlier)
1532 than the second time.
1535 Take a time and return a time saying how long it was since that time.
1538 Take two times and subtract the second from the first. I. e., return
1539 the time between the two times.
1542 Take two days and return the number of days between those two days.
1544 @item date-leap-year-p
1545 Take a year number and say whether it's a leap year.
1547 @item time-to-day-in-year
1548 Take a time and return the day number within the year that the time is
1557 This library deals with decoding and encoding Quoted-Printable text.
1559 Very briefly explained, qp encoding means translating all 8-bit
1560 characters (and lots of control characters) into things that look like
1561 @samp{=EF}; that is, an equal sign followed by the byte encoded as a hex
1564 The following functions are defined by the library:
1567 @item quoted-printable-decode-region
1568 @findex quoted-printable-decode-region
1569 QP-decode all the encoded text in the specified region.
1571 @item quoted-printable-decode-string
1572 @findex quoted-printable-decode-string
1573 Decode the QP-encoded text in a string and return the results.
1575 @item quoted-printable-encode-region
1576 @findex quoted-printable-encode-region
1577 QP-encode all the encodable characters in the specified region. The third
1578 optional parameter @var{fold} specifies whether to fold long lines.
1579 (Long here means 72.)
1581 @item quoted-printable-encode-string
1582 @findex quoted-printable-encode-string
1583 QP-encode all the encodable characters in a string and return the
1593 Base64 is an encoding that encodes three bytes into four characters,
1594 thereby increasing the size by about 33%. The alphabet used for
1595 encoding is very resistant to mangling during transit.
1597 The following functions are defined by this library:
1600 @item base64-encode-region
1601 @findex base64-encode-region
1602 base64 encode the selected region. Return the length of the encoded
1603 text. Optional third argument @var{no-line-break} means do not break
1604 long lines into shorter lines.
1606 @item base64-encode-string
1607 @findex base64-encode-string
1608 base64 encode a string and return the result.
1610 @item base64-decode-region
1611 @findex base64-decode-region
1612 base64 decode the selected region. Return the length of the decoded
1613 text. If the region can't be decoded, return @code{nil} and don't
1616 @item base64-decode-string
1617 @findex base64-decode-string
1618 base64 decode a string and return the result. If the string can't be
1619 decoded, @code{nil} is returned.
1630 @code{binhex} is an encoding that originated in Macintosh environments.
1631 The following function is supplied to deal with these:
1634 @item binhex-decode-region
1635 @findex binhex-decode-region
1636 Decode the encoded text in the region. If given a third parameter, only
1637 decode the @code{binhex} header and return the filename.
1646 @code{uuencode} is probably still the most popular encoding of binaries
1647 used on Usenet, although @code{base64} rules the mail world.
1649 The following function is supplied by this package:
1652 @item uudecode-decode-region
1653 @findex uudecode-decode-region
1654 Decode the text in the region.
1662 @code{yenc} is used for encoding binaries on Usenet. The following
1663 function is supplied by this package:
1666 @item yenc-decode-region
1667 @findex yenc-decode-region
1668 Decode the encoded text in the region.
1679 RFC1843 deals with mixing Chinese and @acronym{ASCII} characters in messages. In
1680 essence, RFC1843 switches between @acronym{ASCII} and Chinese by doing this:
1683 This sentence is in @acronym{ASCII}.
1684 The next sentence is in GB.~@{<:Ky2;S@{#,NpJ)l6HK!#~@}Bye.
1687 Simple enough, and widely used in China.
1689 The following functions are available to handle this encoding:
1692 @item rfc1843-decode-region
1693 Decode HZ-encoded text in the region.
1695 @item rfc1843-decode-string
1696 Decode a HZ-encoded string and return the result.
1704 The @file{~/.mailcap} file is parsed by most @acronym{MIME}-aware message
1705 handlers and describes how elements are supposed to be displayed.
1706 Here's an example file:
1710 audio/wav; wavplayer %s
1711 application/msword; catdoc %s ; copiousoutput ; nametemplate=%s.doc
1714 This says that all image files should be displayed with @code{gimp},
1715 that WAVE audio files should be played by @code{wavplayer}, and that
1716 MS-WORD files should be inlined by @code{catdoc}.
1718 The @code{mailcap} library parses this file, and provides functions for
1722 @item mailcap-mime-data
1723 @vindex mailcap-mime-data
1724 This variable is an alist of alists containing backup viewing rules.
1728 Interface functions:
1731 @item mailcap-parse-mailcaps
1732 @findex mailcap-parse-mailcaps
1733 Parse the @file{~/.mailcap} file.
1735 @item mailcap-mime-info
1736 Takes a @acronym{MIME} type as its argument and returns the matching viewer.
1746 The Emacs @acronym{MIME} library implements handling of various elements
1747 according to a (somewhat) large number of RFCs, drafts and standards
1748 documents. This chapter lists the relevant ones. They can all be
1749 fetched from @uref{http://quimby.gnus.org/notes/}.
1754 Standard for the Format of ARPA Internet Text Messages.
1757 Standard for Interchange of USENET Messages
1760 Format of Internet Message Bodies
1766 Message Header Extensions for Non-@acronym{ASCII} Text
1769 Registration Procedures
1772 Conformance Criteria and Examples
1775 @acronym{MIME} Parameter Value and Encoded Word Extensions: Character Sets,
1776 Languages, and Continuations
1779 HZ - A Data Format for Exchanging Files of Arbitrarily Mixed Chinese and
1780 @acronym{ASCII} characters
1782 @item draft-ietf-drums-msg-fmt-05.txt
1783 Draft for the successor of RFC822
1786 The @acronym{MIME} Multipart/Related Content-type
1789 The Multipart/Report Content Type for the Reporting of Mail System
1790 Administrative Messages
1793 Communicating Presentation Information in Internet Messages: The
1794 Content-Disposition Header Field
1797 Documentation of the text/plain format parameter for flowed text.
1811 @c coding: iso-2022-7bit
1814 @c use-kuten-for-period: t
1815 @c use-touten-for-comma: t