Importing Oort Gnus v0.06.
[elisp/gnus.git-] / texi / emacs-mime.texi
1 \input texinfo
2
3 @setfilename emacs-mime
4 @settitle Emacs MIME Manual
5 @synindex fn cp
6 @synindex vr cp
7 @synindex pg cp
8 @dircategory Emacs
9 @direntry
10 * Emacs MIME: (emacs-mime).   The MIME de/composition library.
11 @end direntry
12 @iftex
13 @finalout
14 @end iftex
15 @setchapternewpage odd
16
17 @ifnottex
18
19 This file documents the Emacs MIME interface functionality.
20
21 Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
22
23 Permission is granted to copy, distribute and/or modify this document
24 under the terms of the GNU Free Documentation License, Version 1.1 or
25 any later version published by the Free Software Foundation; with no
26 Invariant Sections, with the Front-Cover texts being ``A GNU
27 Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the
28 license is included in the section entitled ``GNU Free Documentation
29 License'' in the Emacs manual.
30
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.''
34
35 This document is part of a collection distributed under the GNU Free
36 Documentation License.  If you want to distribute this document
37 separately from the collection, you can do so by adding a copy of the
38 license to the document, as described in section 6 of the license.
39 @end ifnottex
40
41 @tex
42
43 @titlepage
44 @title Emacs MIME Manual
45
46 @author by Lars Magne Ingebrigtsen
47 @page
48
49 @vskip 0pt plus 1filll
50 Copyright @copyright{} 1998, 1999, 2000, 2001, 2002 Free Software
51 Foundation, Inc.
52
53 Permission is granted to copy, distribute and/or modify this document
54 under the terms of the GNU Free Documentation License, Version 1.1 or
55 any later version published by the Free Software Foundation; with the
56 Invariant Sections being none, with the Front-Cover texts being ``A GNU
57 Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the
58 license is included in the section entitled ``GNU Free Documentation
59 License'' in the Emacs manual.
60
61 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
62 this GNU Manual, like GNU software.  Copies published by the Free
63 Software Foundation raise funds for GNU development.''
64
65 This document is part of a collection distributed under the GNU Free
66 Documentation License.  If you want to distribute this document
67 separately from the collection, you can do so by adding a copy of the
68 license to the document, as described in section 6 of the license.
69 @end titlepage
70 @page
71
72 @end tex
73
74 @node Top
75 @top Emacs MIME
76
77 This manual documents the libraries used to compose and display
78 @sc{mime} messages.
79
80 This is not a manual meant for users; it's a manual directed at people
81 who want to write functions and commands that manipulate @sc{mime}
82 elements.
83
84 @sc{mime} is short for @dfn{Multipurpose Internet Mail Extensions}.
85 This standard is documented in a number of RFCs; mainly RFC2045 (Format
86 of Internet Message Bodies), RFC2046 (Media Types), RFC2047 (Message
87 Header Extensions for Non-ASCII Text), RFC2048 (Registration
88 Procedures), RFC2049 (Conformance Criteria and Examples).  It is highly
89 recommended that anyone who intends writing @sc{mime}-compliant software
90 read at least RFC2045 and RFC2047.
91
92 @menu
93 * Interface Functions::   An abstraction over the basic functions.
94 * Basic Functions::       Utility and basic parsing functions.
95 * Decoding and Viewing::  A framework for decoding and viewing.
96 * Composing::             MML; a language for describing @sc{mime} parts.
97 * Standards::             A summary of RFCs and working documents used.
98 * Index::                 Function and variable index.
99 @end menu
100
101
102 @node Interface Functions
103 @chapter Interface Functions
104 @cindex interface functions
105 @cindex mail-parse
106
107 The @code{mail-parse} library is an abstraction over the actual
108 low-level libraries that are described in the next chapter.
109
110 Standards change, and so programs have to change to fit in the new
111 mold.  For instance, RFC2045 describes a syntax for the
112 @code{Content-Type} header that only allows ASCII characters in the
113 parameter list.  RFC2231 expands on RFC2045 syntax to provide a scheme
114 for continuation headers and non-ASCII characters.
115
116 The traditional way to deal with this is just to update the library
117 functions to parse the new syntax.  However, this is sometimes the wrong
118 thing to do.  In some instances it may be vital to be able to understand
119 both the old syntax as well as the new syntax, and if there is only one
120 library, one must choose between the old version of the library and the
121 new version of the library.
122
123 The Emacs @sc{mime} library takes a different tack.  It defines a
124 series of low-level libraries (@file{rfc2047.el}, @file{rfc2231.el}
125 and so on) that parses strictly according to the corresponding
126 standard.  However, normal programs would not use the functions
127 provided by these libraries directly, but instead use the functions
128 provided by the @code{mail-parse} library.  The functions in this
129 library are just aliases to the corresponding functions in the latest
130 low-level libraries.  Using this scheme, programs get a consistent
131 interface they can use, and library developers are free to create
132 write code that handles new standards.
133
134 The following functions are defined by this library:
135
136 @table @code
137 @item mail-header-parse-content-type
138 @findex mail-header-parse-content-type
139 Parse a @code{Content-Type} header and return a list on the following
140 format:
141
142 @lisp
143 ("type/subtype"
144  (attribute1 . value1)
145  (attribute2 . value2)
146  ...)
147 @end lisp
148
149 Here's an example:
150
151 @example
152 (mail-header-parse-content-type
153  "image/gif; name=\"b980912.gif\"")
154 @result{} ("image/gif" (name . "b980912.gif"))
155 @end example
156
157 @item mail-header-parse-content-disposition
158 @findex mail-header-parse-content-disposition
159 Parse a @code{Content-Disposition} header and return a list on the same
160 format as the function above.
161
162 @item mail-content-type-get
163 @findex mail-content-type-get
164 Takes two parameters---a list on the format above, and an attribute.
165 Returns the value of the attribute.
166
167 @example
168 (mail-content-type-get
169  '("image/gif" (name . "b980912.gif")) 'name)
170 @result{} "b980912.gif"
171 @end example
172
173 @item mail-header-encode-parameter
174 @findex mail-header-encode-parameter
175 Takes a parameter string and returns an encoded version of the string.
176 This is used for parameters in headers like @code{Content-Type} and
177 @code{Content-Disposition}.
178
179 @item mail-header-remove-comments
180 @findex mail-header-remove-comments
181 Return a comment-free version of a header.
182
183 @example
184 (mail-header-remove-comments
185  "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
186 @result{} "Gnus/5.070027  "
187 @end example
188
189 @item mail-header-remove-whitespace
190 @findex mail-header-remove-whitespace
191 Remove linear white space from a header.  Space inside quoted strings
192 and comments is preserved.
193
194 @example
195 (mail-header-remove-whitespace
196  "image/gif; name=\"Name with spaces\"")
197 @result{} "image/gif;name=\"Name with spaces\""
198 @end example
199
200 @item mail-header-get-comment
201 @findex mail-header-get-comment
202 Return the last comment in a header.
203
204 @example
205 (mail-header-get-comment
206  "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
207 @result{} "Finnish Landrace"
208 @end example
209
210 @item mail-header-parse-address
211 @findex mail-header-parse-address
212 Parse an address and return a list containing the mailbox and the
213 plaintext name.
214
215 @example
216 (mail-header-parse-address
217  "Hrvoje Niksic <hniksic@@srce.hr>")
218 @result{} ("hniksic@@srce.hr" . "Hrvoje Niksic")
219 @end example
220
221 @item mail-header-parse-addresses
222 @findex mail-header-parse-addresses
223 Parse a string with list of addresses and return a list of elements like
224 the one described above.
225
226 @example
227 (mail-header-parse-addresses
228  "Hrvoje Niksic <hniksic@@srce.hr>, Steinar Bang <sb@@metis.no>")
229 @result{} (("hniksic@@srce.hr" . "Hrvoje Niksic")
230      ("sb@@metis.no" . "Steinar Bang"))
231 @end example
232
233 @item mail-header-parse-date
234 @findex mail-header-parse-date
235 Parse a date string and return an Emacs time structure.
236
237 @item mail-narrow-to-head
238 @findex mail-narrow-to-head
239 Narrow the buffer to the header section of the buffer.  Point is placed
240 at the beginning of the narrowed buffer.
241
242 @item mail-header-narrow-to-field
243 @findex mail-header-narrow-to-field
244 Narrow the buffer to the header under point.  Understands continuation
245 headers.
246
247 @item mail-header-fold-field
248 @findex mail-header-fold-field
249 Fold the header under point.
250
251 @item mail-header-unfold-field
252 @findex mail-header-unfold-field
253 Unfold the header under point.
254
255 @item mail-header-field-value
256 @findex mail-header-field-value
257 Return the value of the field under point.
258
259 @item mail-encode-encoded-word-region
260 @findex mail-encode-encoded-word-region
261 Encode the non-ASCII words in the region.  For instance,
262 @samp{Naïve} is encoded as @samp{=?iso-8859-1?q?Na=EFve?=}.
263
264 @item mail-encode-encoded-word-buffer
265 @findex mail-encode-encoded-word-buffer
266 Encode the non-ASCII words in the current buffer.  This function is
267 meant to be called narrowed to the headers of a message.
268
269 @item mail-encode-encoded-word-string
270 @findex mail-encode-encoded-word-string
271 Encode the words that need encoding in a string, and return the result.
272
273 @example
274 (mail-encode-encoded-word-string
275  "This is naïve, baby")
276 @result{} "This is =?iso-8859-1?q?na=EFve,?= baby"
277 @end example
278
279 @item mail-decode-encoded-word-region
280 @findex mail-decode-encoded-word-region
281 Decode the encoded words in the region.
282
283 @item mail-decode-encoded-word-string
284 @findex mail-decode-encoded-word-string
285 Decode the encoded words in the string and return the result.
286
287 @example
288 (mail-decode-encoded-word-string
289  "This is =?iso-8859-1?q?na=EFve,?= baby")
290 @result{} "This is naïve, baby"
291 @end example
292
293 @end table
294
295 Currently, @code{mail-parse} is an abstraction over @code{ietf-drums},
296 @code{rfc2047}, @code{rfc2045} and @code{rfc2231}.  These are documented
297 in the subsequent sections.
298
299
300
301 @node Basic Functions
302 @chapter Basic Functions
303
304 This chapter describes the basic, ground-level functions for parsing and
305 handling.  Covered here is parsing @code{From} lines, removing comments
306 from header lines, decoding encoded words, parsing date headers and so
307 on.  High-level functionality is dealt with in the next chapter
308 (@pxref{Decoding and Viewing}).
309
310 @menu
311 * rfc2045::      Encoding @code{Content-Type} headers.
312 * rfc2231::      Parsing @code{Content-Type} headers.
313 * ietf-drums::   Handling mail headers defined by RFC822bis.
314 * rfc2047::      En/decoding encoded words in headers.
315 * time-date::    Functions for parsing dates and manipulating time.
316 * qp::           Quoted-Printable en/decoding.
317 * base64::       Base64 en/decoding.
318 * binhex::       Binhex decoding.
319 * uudecode::     Uuencode decoding.
320 * rfc1843::      Decoding HZ-encoded text.
321 * mailcap::      How parts are displayed is specified by the @file{.mailcap} file
322 @end menu
323
324
325 @node rfc2045
326 @section rfc2045
327
328 RFC2045 is the ``main'' @sc{mime} document, and as such, one would
329 imagine that there would be a lot to implement.  But there isn't, since
330 most of the implementation details are delegated to the subsequent
331 RFCs.
332
333 So @file{rfc2045.el} has only a single function:
334
335 @table @code
336 @item rfc2045-encode-string
337 @findex rfc2045-encode-string
338 Takes a parameter and a value and returns a @samp{PARAM=VALUE} string.
339 @var{value} will be quoted if there are non-safe characters in it.
340 @end table
341
342
343 @node rfc2231
344 @section rfc2231
345
346 RFC2231 defines a syntax for the @code{Content-Type} and
347 @code{Content-Disposition} headers.  Its snappy name is @dfn{MIME
348 Parameter Value and Encoded Word Extensions: Character Sets, Languages,
349 and Continuations}.
350
351 In short, these headers look something like this:
352
353 @example
354 Content-Type: application/x-stuff;
355  title*0*=us-ascii'en'This%20is%20even%20more%20;
356  title*1*=%2A%2A%2Afun%2A%2A%2A%20;
357  title*2="isn't it!"
358 @end example
359
360 They usually aren't this bad, though.
361
362 The following functions are defined by this library:
363
364 @table @code
365 @item rfc2231-parse-string
366 @findex rfc2231-parse-string
367 Parse a @code{Content-Type} header and return a list describing its
368 elements.
369
370 @example
371 (rfc2231-parse-string
372  "application/x-stuff;
373  title*0*=us-ascii'en'This%20is%20even%20more%20;
374  title*1*=%2A%2A%2Afun%2A%2A%2A%20;
375  title*2=\"isn't it!\"")
376 @result{} ("application/x-stuff"
377     (title . "This is even more ***fun*** isn't it!"))
378 @end example
379
380 @item rfc2231-get-value
381 @findex rfc2231-get-value
382 Takes one of the lists on the format above and returns
383 the value of the specified attribute.
384
385 @item rfc2231-encode-string
386 @findex rfc2231-encode-string
387 Encode a parameter in headers likes @code{Content-Type} and
388 @code{Content-Disposition}.
389
390 @end table
391
392
393 @node ietf-drums
394 @section ietf-drums
395
396 @dfn{drums} is an IETF working group that is working on the replacement
397 for RFC822.
398
399 The functions provided by this library include:
400
401 @table @code
402 @item ietf-drums-remove-comments
403 @findex ietf-drums-remove-comments
404 Remove the comments from the argument and return the results.
405
406 @item ietf-drums-remove-whitespace
407 @findex ietf-drums-remove-whitespace
408 Remove linear white space from the string and return the results.
409 Spaces inside quoted strings and comments are left untouched.
410
411 @item ietf-drums-get-comment
412 @findex ietf-drums-get-comment
413 Return the last most comment from the string.
414
415 @item ietf-drums-parse-address
416 @findex ietf-drums-parse-address
417 Parse an address string and return a list that contains the mailbox and
418 the plain text name.
419
420 @item ietf-drums-parse-addresses
421 @findex ietf-drums-parse-addresses
422 Parse a string that contains any number of comma-separated addresses and
423 return a list that contains mailbox/plain text pairs.
424
425 @item ietf-drums-parse-date
426 @findex ietf-drums-parse-date
427 Parse a date string and return an Emacs time structure.
428
429 @item ietf-drums-narrow-to-header
430 @findex ietf-drums-narrow-to-header
431 Narrow the buffer to the header section of the current buffer.
432
433 @end table
434
435
436 @node rfc2047
437 @section rfc2047
438
439 RFC2047 (Message Header Extensions for Non-ASCII Text) specifies how
440 non-ASCII text in headers are to be encoded.  This is actually rather
441 complicated, so a number of variables are necessary to tweak what this
442 library does.
443
444 The following variables are tweakable:
445
446 @table @code
447 @item rfc2047-default-charset
448 @vindex rfc2047-default-charset
449 Characters in this charset should not be decoded by this library.
450 This defaults to @code{iso-8859-1}.
451
452 @item rfc2047-header-encoding-list
453 @vindex rfc2047-header-encoding-list
454 This is an alist of header / encoding-type pairs.  Its main purpose is
455 to prevent encoding of certain headers.
456
457 The keys can either be header regexps, or @code{t}.
458
459 The values can be either @code{nil}, in which case the header(s) in
460 question won't be encoded, or @code{mime}, which means that they will be
461 encoded.
462
463 @item rfc2047-charset-encoding-alist
464 @vindex rfc2047-charset-encoding-alist
465 RFC2047 specifies two forms of encoding---@code{Q} (a
466 Quoted-Printable-like encoding) and @code{B} (base64).  This alist
467 specifies which charset should use which encoding.
468
469 @item rfc2047-encoding-function-alist
470 @vindex rfc2047-encoding-function-alist
471 This is an alist of encoding / function pairs.  The encodings are
472 @code{Q}, @code{B} and @code{nil}.
473
474 @item rfc2047-q-encoding-alist
475 @vindex rfc2047-q-encoding-alist
476 The @code{Q} encoding isn't quite the same for all headers.  Some
477 headers allow a narrower range of characters, and that is what this
478 variable is for.  It's an alist of header regexps / allowable character
479 ranges.
480
481 @item rfc2047-encoded-word-regexp
482 @vindex rfc2047-encoded-word-regexp
483 When decoding words, this library looks for matches to this regexp.
484
485 @end table
486
487 Those were the variables, and these are this functions:
488
489 @table @code
490 @item rfc2047-narrow-to-field
491 @findex rfc2047-narrow-to-field
492 Narrow the buffer to the header on the current line.
493
494 @item rfc2047-encode-message-header
495 @findex rfc2047-encode-message-header
496 Should be called narrowed to the header of a message.  Encodes according
497 to @code{rfc2047-header-encoding-alist}.
498
499 @item rfc2047-encode-region
500 @findex rfc2047-encode-region
501 Encodes all encodable words in the region specified.
502
503 @item rfc2047-encode-string
504 @findex rfc2047-encode-string
505 Encode a string and return the results.
506
507 @item rfc2047-decode-region
508 @findex rfc2047-decode-region
509 Decode the encoded words in the region.
510
511 @item rfc2047-decode-string
512 @findex rfc2047-decode-string
513 Decode a string and return the results.
514
515 @end table
516
517
518 @node time-date
519 @section time-date
520
521 While not really a part of the @sc{mime} library, it is convenient to
522 document this library here.  It deals with parsing @code{Date} headers
523 and manipulating time.  (Not by using tesseracts, though, I'm sorry to
524 say.)
525
526 These functions convert between five formats: A date string, an Emacs
527 time structure, a decoded time list, a second number, and a day number.
528
529 Here's a bunch of time/date/second/day examples:
530
531 @example
532 (parse-time-string "Sat Sep 12 12:21:54 1998 +0200")
533 @result{} (54 21 12 12 9 1998 6 nil 7200)
534
535 (date-to-time "Sat Sep 12 12:21:54 1998 +0200")
536 @result{} (13818 19266)
537
538 (time-to-seconds '(13818 19266))
539 @result{} 905595714.0
540
541 (seconds-to-time 905595714.0)
542 @result{} (13818 19266 0)
543
544 (time-to-days '(13818 19266))
545 @result{} 729644
546
547 (days-to-time 729644)
548 @result{} (961933 65536)
549
550 (time-since '(13818 19266))
551 @result{} (0 430)
552
553 (time-less-p '(13818 19266) '(13818 19145))
554 @result{} nil
555
556 (subtract-time '(13818 19266) '(13818 19145))
557 @result{} (0 121)
558
559 (days-between "Sat Sep 12 12:21:54 1998 +0200"
560               "Sat Sep 07 12:21:54 1998 +0200")
561 @result{} 5
562
563 (date-leap-year-p 2000)
564 @result{} t
565
566 (time-to-day-in-year '(13818 19266))
567 @result{} 255
568
569 (time-to-number-of-days
570  (time-since
571   (date-to-time "Mon, 01 Jan 2001 02:22:26 GMT")))
572 @result{} 4.146122685185185
573 @end example
574
575 And finally, we have @code{safe-date-to-time}, which does the same as
576 @code{date-to-time}, but returns a zero time if the date is
577 syntactically malformed.
578
579 The five data representations used are the following:
580
581 @table @var
582 @item date
583 An RFC822 (or similar) date string.  For instance: @code{"Sat Sep 12
584 12:21:54 1998 +0200"}.
585
586 @item time
587 An internal Emacs time.  For instance: @code{(13818 26466)}.
588
589 @item seconds
590 A floating point representation of the internal Emacs time.  For
591 instance: @code{905595714.0}.
592
593 @item days
594 An integer number representing the number of days since 00000101.  For
595 instance: @code{729644}.
596
597 @item decoded time
598 A list of decoded time.  For instance: @code{(54 21 12 12 9 1998 6 t
599 7200)}.
600 @end table
601
602 All the examples above represent the same moment.
603
604 These are the functions available:
605
606 @table @code
607 @item date-to-time
608 Take a date and return a time.
609
610 @item time-to-seconds
611 Take a time and return seconds.
612
613 @item seconds-to-time
614 Take seconds and return a time.
615
616 @item time-to-days
617 Take a time and return days.
618
619 @item days-to-time
620 Take days and return a time.
621
622 @item date-to-day
623 Take a date and return days.
624
625 @item time-to-number-of-days
626 Take a time and return the number of days that represents.
627
628 @item safe-date-to-time
629 Take a date and return a time.  If the date is not syntactically valid,
630 return a "zero" date.
631
632 @item time-less-p
633 Take two times and say whether the first time is less (i. e., earlier)
634 than the second time.
635
636 @item time-since
637 Take a time and return a time saying how long it was since that time.
638
639 @item subtract-time
640 Take two times and subtract the second from the first.  I. e., return
641 the time between the two times.
642
643 @item days-between
644 Take two days and return the number of days between those two days.
645
646 @item date-leap-year-p
647 Take a year number and say whether it's a leap year.
648
649 @item time-to-day-in-year
650 Take a time and return the day number within the year that the time is
651 in.
652
653 @end table
654
655
656 @node qp
657 @section qp
658
659 This library deals with decoding and encoding Quoted-Printable text.
660
661 Very briefly explained, qp encoding means translating all 8-bit
662 characters (and lots of control characters) into things that look like
663 @samp{=EF}; that is, an equal sign followed by the byte encoded as a hex
664 string.
665
666 The following functions are defined by the library:
667
668 @table @code
669 @item quoted-printable-decode-region
670 @findex quoted-printable-decode-region
671 QP-decode all the encoded text in the specified region.
672
673 @item quoted-printable-decode-string
674 @findex quoted-printable-decode-string
675 Decode the QP-encoded text in a string and return the results.
676
677 @item quoted-printable-encode-region
678 @findex quoted-printable-encode-region
679 QP-encode all the encodable characters in the specified region.  The third
680 optional parameter @var{fold} specifies whether to fold long lines.
681 (Long here means 72.)
682
683 @item quoted-printable-encode-string
684 @findex quoted-printable-encode-string
685 QP-encode all the encodable characters in a string and return the
686 results.
687
688 @end table
689
690
691 @node base64
692 @section base64
693 @cindex base64
694
695 Base64 is an encoding that encodes three bytes into four characters,
696 thereby increasing the size by about 33%.  The alphabet used for
697 encoding is very resistant to mangling during transit.
698
699 The following functions are defined by this library:
700
701 @table @code
702 @item base64-encode-region
703 @findex base64-encode-region
704 base64 encode the selected region.  Return the length of the encoded
705 text.  Optional third argument @var{no-line-break} means do not break
706 long lines into shorter lines.
707
708 @item base64-encode-string
709 @findex base64-encode-string
710 base64 encode a string and return the result.
711
712 @item base64-decode-region
713 @findex base64-decode-region
714 base64 decode the selected region.  Return the length of the decoded
715 text.  If the region can't be decoded, return @code{nil} and don't
716 modify the buffer.
717
718 @item base64-decode-string
719 @findex base64-decode-string
720 base64 decode a string and return the result.  If the string can't be
721 decoded, @code{nil} is returned.
722
723 @end table
724
725
726 @node binhex
727 @section binhex
728 @cindex binhex
729 @cindex Apple
730 @cindex Macintosh
731
732 @code{binhex} is an encoding that originated in Macintosh environments.
733 The following function is supplied to deal with these:
734
735 @table @code
736 @item binhex-decode-region
737 @findex binhex-decode-region
738 Decode the encoded text in the region.  If given a third parameter, only
739 decode the @code{binhex} header and return the filename.
740
741 @end table
742
743
744 @node uudecode
745 @section uudecode
746 @cindex uuencode
747 @cindex uudecode
748
749 @code{uuencode} is probably still the most popular encoding of binaries
750 used on Usenet, although @code{base64} rules the mail world.
751
752 The following function is supplied by this package:
753
754 @table @code
755 @item uudecode-decode-region
756 @findex uudecode-decode-region
757 Decode the text in the region.
758 @end table
759
760
761 @node rfc1843
762 @section rfc1843
763 @cindex rfc1843
764 @cindex HZ
765 @cindex Chinese
766
767 RFC1843 deals with mixing Chinese and ASCII characters in messages.  In
768 essence, RFC1843 switches between ASCII and Chinese by doing this:
769
770 @example
771 This sentence is in ASCII.
772 The next sentence is in GB.~@{<:Ky2;S@{#,NpJ)l6HK!#~@}Bye.
773 @end example
774
775 Simple enough, and widely used in China.
776
777 The following functions are available to handle this encoding:
778
779 @table @code
780 @item rfc1843-decode-region
781 Decode HZ-encoded text in the region.
782
783 @item rfc1843-decode-string
784 Decode a HZ-encoded string and return the result.
785
786 @end table
787
788
789 @node mailcap
790 @section mailcap
791
792 The @file{~/.mailcap} file is parsed by most @sc{mime}-aware message
793 handlers and describes how elements are supposed to be displayed.
794 Here's an example file:
795
796 @example
797 image/*; gimp -8 %s
798 audio/wav; wavplayer %s
799 application/msword; catdoc %s ; copiousoutput ; nametemplate=%s.doc
800 @end example
801
802 This says that all image files should be displayed with @code{gimp},
803 that WAVE audio files should be played by @code{wavplayer}, and that
804 MS-WORD files should be inlined by @code{catdoc}.
805
806 The @code{mailcap} library parses this file, and provides functions for
807 matching types.
808
809 @table @code
810 @item mailcap-mime-data
811 @vindex mailcap-mime-data
812 This variable is an alist of alists containing backup viewing rules.
813
814 @end table
815
816 Interface functions:
817
818 @table @code
819 @item mailcap-parse-mailcaps
820 @findex mailcap-parse-mailcaps
821 Parse the @code{~/.mailcap} file.
822
823 @item mailcap-mime-info
824 Takes a @sc{mime} type as its argument and returns the matching viewer.
825
826 @end table
827
828
829
830
831 @node Decoding and Viewing
832 @chapter Decoding and Viewing
833
834 This chapter deals with decoding and viewing @sc{mime} messages on a
835 higher level.
836
837 The main idea is to first analyze a @sc{mime} article, and then allow
838 other programs to do things based on the list of @dfn{handles} that are
839 returned as a result of this analysis.
840
841 @menu
842 * Dissection::     Analyzing a @sc{mime} message.
843 * Non-MIME::       Analyzing a non-@sc{mime} message.
844 * Handles::        Handle manipulations.
845 * Display::        Displaying handles.
846 * Customization::  Variables that affect display.
847 * New Viewers::    How to write your own viewers.
848 @end menu
849
850
851 @node Dissection
852 @section Dissection
853
854 The @code{mm-dissect-buffer} is the function responsible for dissecting
855 a @sc{mime} article.  If given a multipart message, it will recursively
856 descend the message, following the structure, and return a tree of
857 @sc{mime} handles that describes the structure of the message.
858
859 @node Non-MIME
860 @section Non-MIME
861
862 Gnus also understands some non-@sc{mime} attachments, such as
863 postscript, uuencode, binhex, shar, forward, gnatsweb, pgp.  Each of
864 these features can be disabled by add an item into
865 @code{mm-uu-configure-list}.  For example,
866
867 @lisp
868 (require 'mm-uu)
869 (add-to-list 'mm-uu-configure-list '(pgp-signed . disabled))
870 @end lisp
871
872 @table @code
873 @item postscript
874 @findex postscript
875 Postscript file.
876
877 @item uu
878 @findex uu
879 Uuencoded file.
880
881 @item binhex
882 @findex binhex
883 Binhex encoded file.
884
885 @item shar
886 @findex shar
887 Shar archive file.
888
889 @item forward
890 @findex forward
891 Non-@sc{mime} forwarded message.
892
893 @item gnatsweb
894 @findex gnatsweb
895 Gnatsweb attachment.
896
897 @item pgp-signed
898 @findex pgp-signed
899 PGP signed clear text.
900
901 @item pgp-encrypted
902 @findex pgp-encrypted
903 PGP encrypted clear text.
904
905 @item pgp-key
906 @findex pgp-key
907 PGP public keys.
908
909 @item emacs-sources
910 @findex emacs-sources
911 Emacs source code.  This item works only in the groups matching
912 @code{mm-uu-emacs-sources-regexp}.
913
914 @end table
915
916 @node Handles
917 @section Handles
918
919 A @sc{mime} handle is a list that fully describes a @sc{mime}
920 component.
921
922 The following macros can be used to access elements in a handle:
923
924 @table @code
925 @item mm-handle-buffer
926 @findex mm-handle-buffer
927 Return the buffer that holds the contents of the undecoded @sc{mime}
928 part.
929
930 @item mm-handle-type
931 @findex mm-handle-type
932 Return the parsed @code{Content-Type} of the part.
933
934 @item mm-handle-encoding
935 @findex mm-handle-encoding
936 Return the @code{Content-Transfer-Encoding} of the part.
937
938 @item mm-handle-undisplayer
939 @findex mm-handle-undisplayer
940 Return the object that can be used to remove the displayed part (if it
941 has been displayed).
942
943 @item mm-handle-set-undisplayer
944 @findex mm-handle-set-undisplayer
945 Set the undisplayer object.
946
947 @item mm-handle-disposition
948 @findex mm-handle-disposition
949 Return the parsed @code{Content-Disposition} of the part.
950
951 @item mm-handle-disposition
952 @findex mm-handle-disposition
953 Return the description of the part.
954
955 @item mm-get-content-id
956 Returns the handle(s) referred to by @code{Content-ID}.
957
958 @end table
959
960
961 @node Display
962 @section Display
963
964 Functions for displaying, removing and saving.
965
966 @table @code
967 @item mm-display-part
968 @findex mm-display-part
969 Display the part.
970
971 @item mm-remove-part
972 @findex mm-remove-part
973 Remove the part (if it has been displayed).
974
975 @item mm-inlinable-p
976 @findex mm-inlinable-p
977 Say whether a @sc{mime} type can be displayed inline.
978
979 @item mm-automatic-display-p
980 @findex mm-automatic-display-p
981 Say whether a @sc{mime} type should be displayed automatically.
982
983 @item mm-destroy-part
984 @findex mm-destroy-part
985 Free all resources occupied by a part.
986
987 @item mm-save-part
988 @findex mm-save-part
989 Offer to save the part in a file.
990
991 @item mm-pipe-part
992 @findex mm-pipe-part
993 Offer to pipe the part to some process.
994
995 @item mm-interactively-view-part
996 @findex mm-interactively-view-part
997 Prompt for a mailcap method to use to view the part.
998
999 @end table
1000
1001
1002 @node Customization
1003 @section Customization
1004
1005 @table @code
1006
1007 @item mm-inline-media-tests
1008 This is an alist where the key is a @sc{mime} type, the second element
1009 is a function to display the part @dfn{inline} (i.e., inside Emacs), and
1010 the third element is a form to be @code{eval}ed to say whether the part
1011 can be displayed inline.
1012
1013 This variable specifies whether a part @emph{can} be displayed inline,
1014 and, if so, how to do it.  It does not say whether parts are
1015 @emph{actually} displayed inline.
1016
1017 @item mm-inlined-types
1018 This, on the other hand, says what types are to be displayed inline, if
1019 they satisfy the conditions set by the variable above.  It's a list of
1020 @sc{mime} media types.
1021
1022 @item mm-automatic-display
1023 This is a list of types that are to be displayed ``automatically'', but
1024 only if the above variable allows it.  That is, only inlinable parts can
1025 be displayed automatically.
1026
1027 @item mm-attachment-override-types
1028 Some @sc{mime} agents create parts that have a content-disposition of
1029 @samp{attachment}.  This variable allows overriding that disposition and
1030 displaying the part inline.  (Note that the disposition is only
1031 overridden if we are able to, and want to, display the part inline.)
1032
1033 @item mm-discouraged-alternatives
1034 List of @sc{mime} types that are discouraged when viewing
1035 @samp{multipart/alternative}.  Viewing agents are supposed to view the
1036 last possible part of a message, as that is supposed to be the richest.
1037 However, users may prefer other types instead, and this list says what
1038 types are most unwanted.  If, for instance, @samp{text/html} parts are
1039 very unwanted, and @samp{text/richtech} parts are somewhat unwanted,
1040 you could say something like:
1041
1042 @lisp
1043 (setq mm-discouraged-alternatives
1044       '("text/html" "text/richtext")
1045       mm-automatic-display
1046       (remove "text/html" mm-automatic-display))
1047 @end lisp
1048
1049 @item mm-inline-large-images-p
1050 When displaying inline images that are larger than the window, XEmacs
1051 does not enable scrolling, which means that you cannot see the whole
1052 image.  To prevent this, the library tries to determine the image size
1053 before displaying it inline, and if it doesn't fit the window, the
1054 library will display it externally (e.g. with @samp{ImageMagick} or
1055 @samp{xv}).  Setting this variable to @code{t} disables this check and
1056 makes the library display all inline images as inline, regardless of
1057 their size.
1058
1059 @item mm-inline-override-type
1060 @code{mm-inlined-types} may include regular expressions, for example to
1061 specify that all @samp{text/.*} parts be displayed inline.  If a user
1062 prefers to have a type that matches such a regular expression be treated
1063 as an attachment, that can be accomplished by setting this variable to a
1064 list containing that type.  For example assuming @code{mm-inlined-types}
1065 includes @samp{text/.*}, then including @samp{text/html} in this
1066 variable will cause @samp{text/html} parts to be treated as attachments.
1067
1068 @item mm-inline-text-html-renderer
1069 This selects the function used to render @sc{html}.  The predefined
1070 renderers are selected by the symbols @code{w3},
1071 @code{w3m}@footnote{See @uref{http://emacs-w3m.namazu.org/} for more
1072 information about emacs-w3m}, @code{links}, @code{lynx} or
1073 @code{html2text}.  You can also specify a function, which will be
1074 called with a @sc{mime} handle as the argument.
1075
1076 @item mm-inline-text-html-with-images
1077 Some @sc{html} mails might have the trick of spammers using
1078 @samp{<img>} tags.  It is likely to be intended to verify whether you
1079 have read the mail.  You can prevent your personal informations from
1080 leaking by setting this option to @code{nil} (which is the default).
1081 It is currently ignored by Emacs/w3.  For emacs-w3m, you may use the
1082 command @kbd{t} on the image anchor to show an image even if it is
1083 @code{nil}.@footnote{The command @kbd{T} will load all images.  If you
1084 have set the option @code{w3m-key-binding} to @code{info}, use @kbd{i}
1085 or @kbd{I} instead.}
1086
1087 @item mm-inline-text-html-with-w3m-keymap
1088 You can use emacs-w3m command keys in the inlined text/html part by
1089 setting this option to non-@code{nil}.  The default value is @code{t}.
1090
1091 @end table
1092
1093
1094 @node New Viewers
1095 @section New Viewers
1096
1097 Here's an example viewer for displaying @code{text/enriched} inline:
1098
1099 @lisp
1100 (defun mm-display-enriched-inline (handle)
1101   (let (text)
1102     (with-temp-buffer
1103       (mm-insert-part handle)
1104       (save-window-excursion
1105         (enriched-decode (point-min) (point-max))
1106         (setq text (buffer-string))))
1107     (mm-insert-inline handle text)))
1108 @end lisp
1109
1110 We see that the function takes a @sc{mime} handle as its parameter.  It
1111 then goes to a temporary buffer, inserts the text of the part, does some
1112 work on the text, stores the result, goes back to the buffer it was
1113 called from and inserts the result.
1114
1115 The two important helper functions here are @code{mm-insert-part} and
1116 @code{mm-insert-inline}.  The first function inserts the text of the
1117 handle in the current buffer.  It handles charset and/or content
1118 transfer decoding.  The second function just inserts whatever text you
1119 tell it to insert, but it also sets things up so that the text can be
1120 ``undisplayed' in a convenient manner.
1121
1122
1123 @node Composing
1124 @chapter Composing
1125 @cindex Composing
1126 @cindex MIME Composing
1127 @cindex MML
1128 @cindex MIME Meta Language
1129
1130 Creating a @sc{mime} message is boring and non-trivial.  Therefore, a
1131 library called @code{mml} has been defined that parses a language called
1132 MML (@sc{mime} Meta Language) and generates @sc{mime} messages.
1133
1134 @findex mml-generate-mime
1135 The main interface function is @code{mml-generate-mime}.  It will
1136 examine the contents of the current (narrowed-to) buffer and return a
1137 string containing the @sc{mime} message.
1138
1139 @menu
1140 * Simple MML Example::             An example MML document.
1141 * MML Definition::                 All valid MML elements.
1142 * Advanced MML Example::           Another example MML document.
1143 * Charset Translation::            How charsets are mapped from @sc{mule} to @sc{mime}.
1144 * Conversion::                     Going from @sc{mime} to MML and vice versa.
1145 * Flowed text::                    Soft and hard newlines.
1146 @end menu
1147
1148
1149 @node Simple MML Example
1150 @section Simple MML Example
1151
1152 Here's a simple @samp{multipart/alternative}:
1153
1154 @example
1155 <#multipart type=alternative>
1156 This is a plain text part.
1157 <#part type=text/enriched>
1158 <center>This is a centered enriched part</center>
1159 <#/multipart>
1160 @end example
1161
1162 After running this through @code{mml-generate-mime}, we get this:
1163
1164 @example
1165 Content-Type: multipart/alternative; boundary="=-=-="
1166
1167
1168 --=-=-=
1169
1170
1171 This is a plain text part.
1172
1173 --=-=-=
1174 Content-Type: text/enriched
1175
1176
1177 <center>This is a centered enriched part</center>
1178
1179 --=-=-=--
1180 @end example
1181
1182
1183 @node MML Definition
1184 @section MML Definition
1185
1186 The MML language is very simple.  It looks a bit like an SGML
1187 application, but it's not.
1188
1189 The main concept of MML is the @dfn{part}.  Each part can be of a
1190 different type or use a different charset.  The way to delineate a part
1191 is with a @samp{<#part ...>} tag.  Multipart parts can be introduced
1192 with the @samp{<#multipart ...>} tag.  Parts are ended by the
1193 @samp{<#/part>} or @samp{<#/multipart>} tags.  Parts started with the
1194 @samp{<#part ...>} tags are also closed by the next open tag.
1195
1196 There's also the @samp{<#external ...>} tag.  These introduce
1197 @samp{external/message-body} parts.
1198
1199 Each tag can contain zero or more parameters on the form
1200 @samp{parameter=value}.  The values may be enclosed in quotation marks,
1201 but that's not necessary unless the value contains white space.  So
1202 @samp{filename=/home/user/#hello$^yes} is perfectly valid.
1203
1204 The following parameters have meaning in MML; parameters that have no
1205 meaning are ignored.  The MML parameter names are the same as the
1206 @sc{mime} parameter names; the things in the parentheses say which
1207 header it will be used in.
1208
1209 @table @samp
1210 @item type
1211 The @sc{mime} type of the part (@code{Content-Type}).
1212
1213 @item filename
1214 Use the contents of the file in the body of the part
1215 (@code{Content-Disposition}).
1216
1217 @item charset
1218 The contents of the body of the part are to be encoded in the character
1219 set speficied (@code{Content-Type}).
1220
1221 @item name
1222 Might be used to suggest a file name if the part is to be saved
1223 to a file (@code{Content-Type}).
1224
1225 @item disposition
1226 Valid values are @samp{inline} and @samp{attachment}
1227 (@code{Content-Disposition}).
1228
1229 @item encoding
1230 Valid values are @samp{7bit}, @samp{8bit}, @samp{quoted-printable} and
1231 @samp{base64} (@code{Content-Transfer-Encoding}).
1232
1233 @item description
1234 A description of the part (@code{Content-Description}).
1235
1236 @item creation-date
1237 RFC822 date when the part was created (@code{Content-Disposition}).
1238
1239 @item modification-date
1240 RFC822 date when the part was modified (@code{Content-Disposition}).
1241
1242 @item read-date
1243 RFC822 date when the part was read (@code{Content-Disposition}).
1244
1245 @item recipients
1246 Who to encrypt/sign the part to.  This field is used to override any
1247 auto-detection based on the To/CC headers.
1248
1249 @item size
1250 The size (in octets) of the part (@code{Content-Disposition}).
1251
1252 @item sign
1253 What technology to sign this MML part with (@code{smime}, @code{pgp}
1254 or @code{pgpmime})
1255
1256 @item encrypt
1257 What technology to encrypt this MML part with (@code{smime},
1258 @code{pgp} or @code{pgpmime})
1259
1260 @end table
1261
1262 Parameters for @samp{application/octet-stream}:
1263
1264 @table @samp
1265 @item type
1266 Type of the part; informal---meant for human readers
1267 (@code{Content-Type}).
1268 @end table
1269
1270 Parameters for @samp{message/external-body}:
1271
1272 @table @samp
1273 @item access-type
1274 A word indicating the supported access mechanism by which the file may
1275 be obtained.  Values include @samp{ftp}, @samp{anon-ftp}, @samp{tftp},
1276 @samp{localfile}, and @samp{mailserver}.  (@code{Content-Type}.)
1277
1278 @item expiration
1279 The RFC822 date after which the file may no longer be fetched.
1280 (@code{Content-Type}.)
1281
1282 @item size
1283 The size (in octets) of the file.  (@code{Content-Type}.)
1284
1285 @item permission
1286 Valid values are @samp{read} and @samp{read-write}
1287 (@code{Content-Type}).
1288
1289 @end table
1290
1291 Parameters for @samp{sign=smime}:
1292
1293 @table @samp
1294
1295 @item keyfile
1296 File containing key and certificate for signer.
1297
1298 @end table
1299
1300 Parameters for @samp{encrypt=smime}:
1301
1302 @table @samp
1303
1304 @item certfile
1305 File containing certificate for recipient.
1306
1307 @end table
1308
1309
1310 @node Advanced MML Example
1311 @section Advanced MML Example
1312
1313 Here's a complex multipart message.  It's a @samp{multipart/mixed} that
1314 contains many parts, one of which is a @samp{multipart/alternative}.
1315
1316 @example
1317 <#multipart type=mixed>
1318 <#part type=image/jpeg filename=~/rms.jpg disposition=inline>
1319 <#multipart type=alternative>
1320 This is a plain text part.
1321 <#part type=text/enriched name=enriched.txt>
1322 <center>This is a centered enriched part</center>
1323 <#/multipart>
1324 This is a new plain text part.
1325 <#part disposition=attachment>
1326 This plain text part is an attachment.
1327 <#/multipart>
1328 @end example
1329
1330 And this is the resulting @sc{mime} message:
1331
1332 @example
1333 Content-Type: multipart/mixed; boundary="=-=-="
1334
1335
1336 --=-=-=
1337
1338
1339
1340 --=-=-=
1341 Content-Type: image/jpeg;
1342  filename="~/rms.jpg"
1343 Content-Disposition: inline;
1344  filename="~/rms.jpg"
1345 Content-Transfer-Encoding: base64
1346
1347 /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof
1348 Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/wAALCAAwADABAREA/8QAHwAA
1349 AQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQR
1350 BRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RF
1351 RkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ip
1352 qrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/9oACAEB
1353 AAA/AO/rifFHjldNuGsrDa0qcSSHkA+gHrXKw+LtWLrMb+RgTyhbr+HSug07xNqV9fQtZrNI
1354 AyiaE/NuBPOOOP0rvRNE880KOC8TbXXGCv1FPqjrF4LDR7u5L7SkTFT/ALWOP1xXgTuXfc7E
1355 sx6nua6rwp4IvvEM8chCxWxOdzn7wz6V9AaB4S07w9p5itow0rDLSY5Pt9K43xO66P4xs71m
1356 2QXiGCbA4yOVJ9+1aYORkdK434lyNH4ahCnG66VT9Nj15JFbPdX0MS43M4VQf5/yr2vSpLnw
1357 5ZW8dlCZ8KFXjOPX0/mK6rSPEGt3Angu44fNEReHYNvIH3TzXDeKNO8RX+kSX2ouZkicTIOc
1358 L+g7E810ulFjpVtv3bwgB3HJyK5L4quY/C9sVxk3ij/xx6850u7t1mtp/wDlpEw3An3Jr3Dw
1359 34gsbWza4nBlhC5LDsaW6+IFgupQyCF3iHH7gA7c9R9ay7zx6t7aX9jHC4smhfBkGCvHGfrm
1360 tLQ7hbnRrV1GPkAP1x1/Hr+Ncr8Vzjwrbf8AX6v/AKA9eQRyYlQk8Yx9K6XTNbkgia2ciSIn
1361 7p5Ga9Atte0LTLKO6it4i7dVRFJDcZ4PvXN+JvEMF9bILVGXJLSZ4zkjivRPDaeX4b08HOTC
1362 pOffmua+KkbS+GLVUGT9tT/0B68eeIpIFYjB70+OOVXyoOM9+M1eaWeCLzHPyHGO/NVWvJJm
1363 jQ8KGH1NfQWhXSXmh2c8eArRLwO3HSv/2Q==
1364
1365 --=-=-=
1366 Content-Type: multipart/alternative; boundary="==-=-="
1367
1368
1369 --==-=-=
1370
1371
1372 This is a plain text part.
1373
1374 --==-=-=
1375 Content-Type: text/enriched;
1376  name="enriched.txt"
1377
1378
1379 <center>This is a centered enriched part</center>
1380
1381 --==-=-=--
1382
1383 --=-=-=
1384
1385 This is a new plain text part.
1386
1387 --=-=-=
1388 Content-Disposition: attachment
1389
1390
1391 This plain text part is an attachment.
1392
1393 --=-=-=--
1394 @end example
1395
1396 @node Charset Translation
1397 @section Charset Translation
1398 @cindex charsets
1399
1400 During translation from MML to @sc{mime}, for each @sc{mime} part which
1401 has been composed inside Emacs, an appropriate charset has to be chosen.
1402
1403 @vindex mail-parse-charset
1404 If you are running a non-@sc{mule} Emacs, this process is simple: If the
1405 part contains any non-ASCII (8-bit) characters, the @sc{mime} charset
1406 given by @code{mail-parse-charset} (a symbol) is used.  (Never set this
1407 variable directly, though.  If you want to change the default charset,
1408 please consult the documentation of the package which you use to process
1409 @sc{mime} messages.
1410 @xref{Various Message Variables, , Various Message Variables, message,
1411       Message Manual}, for example.)
1412 If there are only ASCII characters, the @sc{mime} charset US-ASCII is
1413 used, of course.
1414
1415 @cindex MULE
1416 @cindex UTF-8
1417 @cindex Unicode
1418 @vindex mm-mime-mule-charset-alist
1419 Things are slightly more complicated when running Emacs with @sc{mule}
1420 support.  In this case, a list of the @sc{mule} charsets used in the
1421 part is obtained, and the @sc{mule} charsets are translated to @sc{mime}
1422 charsets by consulting the variable @code{mm-mime-mule-charset-alist}.
1423 If this results in a single @sc{mime} charset, this is used to encode
1424 the part.  But if the resulting list of @sc{mime} charsets contains more
1425 than one element, two things can happen: If it is possible to encode the
1426 part via UTF-8, this charset is used.  (For this, Emacs must support
1427 the @code{utf-8} coding system, and the part must consist entirely of
1428 characters which have Unicode counterparts.)  If UTF-8 is not available
1429 for some reason, the part is split into several ones, so that each one
1430 can be encoded with a single @sc{mime} charset.  The part can only be
1431 split at line boundaries, though---if more than one @sc{mime} charset is
1432 required to encode a single line, it is not possible to encode the part.
1433
1434 @node Conversion
1435 @section Conversion
1436
1437 @findex mime-to-mml
1438 A (multipart) @sc{mime} message can be converted to MML with the
1439 @code{mime-to-mml} function.  It works on the message in the current
1440 buffer, and substitutes MML markup for @sc{mime} boundaries.
1441 Non-textual parts do not have their contents in the buffer, but instead
1442 have the contents in separate buffers that are referred to from the MML
1443 tags.
1444
1445 @findex mml-to-mime
1446 An MML message can be converted back to @sc{mime} by the
1447 @code{mml-to-mime} function.
1448
1449 These functions are in certain senses ``lossy''---you will not get back
1450 an identical message if you run @sc{mime-to-mml} and then
1451 @sc{mml-to-mime}.  Not only will trivial things like the order of the
1452 headers differ, but the contents of the headers may also be different.
1453 For instance, the original message may use base64 encoding on text,
1454 while @sc{mml-to-mime} may decide to use quoted-printable encoding, and
1455 so on.
1456
1457 In essence, however, these two functions should be the inverse of each
1458 other.  The resulting contents of the message should remain equivalent,
1459 if not identical.
1460
1461
1462 @node Flowed text
1463 @section Flowed text
1464 @cindex format=flowed
1465
1466 The Emacs @sc{mime} library will respect the @code{use-hard-newlines}
1467 variable (@pxref{Hard and Soft Newlines, ,Hard and Soft Newlines,
1468 emacs, Emacs Manual}) when encoding a message, and the
1469 ``format=flowed'' Content-Type parameter when decoding a message.
1470
1471 On encoding text, lines terminated by soft newline characters are
1472 filled together and wrapped after the column decided by
1473 @code{fill-flowed-encode-column}.  This variable controls how the text
1474 will look in a client that does not support flowed text, the default
1475 is to wrap after 66 characters.  If hard newline characters are not
1476 present in the buffer, no flow encoding occurs.
1477
1478 On decoding flowed text, lines with soft newline characters are filled
1479 together and wrapped after the column decided by
1480 @code{fill-flowed-display-column}.  The default is to wrap after
1481 @code{fill-column}.
1482
1483 @node Standards
1484 @chapter Standards
1485
1486 The Emacs @sc{mime} library implements handling of various elements
1487 according to a (somewhat) large number of RFCs, drafts and standards
1488 documents.  This chapter lists the relevant ones.  They can all be
1489 fetched from @uref{http://quimby.gnus.org/notes/}.
1490
1491 @table @dfn
1492 @item RFC822
1493 @itemx STD11
1494 Standard for the Format of ARPA Internet Text Messages.
1495
1496 @item RFC1036
1497 Standard for Interchange of USENET Messages
1498
1499 @item RFC2045
1500 Format of Internet Message Bodies
1501
1502 @item RFC2046
1503 Media Types
1504
1505 @item RFC2047
1506 Message Header Extensions for Non-ASCII Text
1507
1508 @item RFC2048
1509 Registration Procedures
1510
1511 @item RFC2049
1512 Conformance Criteria and Examples
1513
1514 @item RFC2231
1515 @sc{mime} Parameter Value and Encoded Word Extensions: Character Sets,
1516 Languages, and Continuations
1517
1518 @item RFC1843
1519 HZ - A Data Format for Exchanging Files of Arbitrarily Mixed Chinese and
1520 ASCII characters
1521
1522 @item draft-ietf-drums-msg-fmt-05.txt
1523 Draft for the successor of RFC822
1524
1525 @item RFC2112
1526 The @sc{mime} Multipart/Related Content-type
1527
1528 @item RFC1892
1529 The Multipart/Report Content Type for the Reporting of Mail System
1530 Administrative Messages
1531
1532 @item RFC2183
1533 Communicating Presentation Information in Internet Messages: The
1534 Content-Disposition Header Field
1535
1536 @item RFC2646
1537 Documentation of the text/plain format parameter for flowed text.
1538
1539 @end table
1540
1541
1542 @node Index
1543 @chapter Index
1544 @printindex cp
1545
1546 @summarycontents
1547 @contents
1548 @bye
1549
1550 \f
1551 @c Local Variables:
1552 @c mode: texinfo
1553 @c coding: iso-8859-1
1554 @c End: