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