Mercurial > emacs
annotate man/emacs-mime.texi @ 32311:035ce2227d76
Docstring fixes.
(initialize-new-tags-table): Use run-hook-with-args-until-success.
(find-tag): Use pop-to-buffer if switch-to-buffer failed.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 08 Oct 2000 19:25:30 +0000 |
parents | 43e6b74b0852 |
children | 4ef19e88da9a |
rev | line source |
---|---|
32085
56bb657c0878
Add coding tag. Fix 7-bit mangling.
Dave Love <fx@gnu.org>
parents:
32008
diff
changeset
|
1 \input texinfo @c -*-mode: texinfo; coding: latin-1 -*- |
31853 | 2 |
32008
a0a62e1e3675
Fix the @setfilename directive.
Eli Zaretskii <eliz@gnu.org>
parents:
31855
diff
changeset
|
3 @setfilename ../info/emacs-mime |
31853 | 4 @settitle Emacs MIME Manual |
5 @synindex fn cp | |
6 @synindex vr cp | |
7 @synindex pg cp | |
8 @dircategory Editors | |
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,99,2000 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 | |
32258 | 25 any later version published by the Free Software Foundation; with no |
26 Invariant Sections, with the Front-Cover texts being ``A GNU | |
31853 | 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 | |
32248
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
29 License'' in the Emacs manual. |
31853 | 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.'' | |
32248
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
34 |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
35 This document is part of a collection distributed under the GNU Free |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
36 Documentation License. If you want to distribute this document |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
37 separately from the collection, you can do so by adding a copy of the |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
38 license to the document, as described in section 6 of the license. |
31853 | 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,99,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 | |
32250 | 58 License'' in the Emacs manual. |
31853 | 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.'' | |
32250 | 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. | |
31853 | 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. | |
244 | |
245 @item mail-encode-encoded-word-region | |
246 @findex mail-encode-encoded-word-region | |
247 Encode the non-ASCII words in the region. For instance, | |
32258 | 248 @samp{Naïve} is encoded as @samp{=?iso-8859-1?q?Na=EFve?=}. |
31853 | 249 |
250 @item mail-encode-encoded-word-buffer | |
251 @findex mail-encode-encoded-word-buffer | |
252 Encode the non-ASCII words in the current buffer. This function is | |
253 meant to be called narrowed to the headers of a message. | |
254 | |
255 @item mail-encode-encoded-word-string | |
256 @findex mail-encode-encoded-word-string | |
257 Encode the words that need encoding in a string, and return the result. | |
258 | |
259 @example | |
260 (mail-encode-encoded-word-string | |
32085
56bb657c0878
Add coding tag. Fix 7-bit mangling.
Dave Love <fx@gnu.org>
parents:
32008
diff
changeset
|
261 "This is naïve, baby") |
31853 | 262 @result{} "This is =?iso-8859-1?q?na=EFve,?= baby" |
263 @end example | |
264 | |
265 @item mail-decode-encoded-word-region | |
266 @findex mail-decode-encoded-word-region | |
267 Decode the encoded words in the region. | |
268 | |
269 @item mail-decode-encoded-word-string | |
270 @findex mail-decode-encoded-word-string | |
271 Decode the encoded words in the string and return the result. | |
272 | |
273 @example | |
274 (mail-decode-encoded-word-string | |
275 "This is =?iso-8859-1?q?na=EFve,?= baby") | |
32085
56bb657c0878
Add coding tag. Fix 7-bit mangling.
Dave Love <fx@gnu.org>
parents:
32008
diff
changeset
|
276 @result{} "This is naïve, baby" |
31853 | 277 @end example |
278 | |
279 @end table | |
280 | |
281 Currently, @code{mail-parse} is an abstraction over @code{ietf-drums}, | |
282 @code{rfc2047}, @code{rfc2045} and @code{rfc2231}. These are documented | |
283 in the subsequent sections. | |
284 | |
285 | |
286 | |
287 @node Basic Functions | |
288 @chapter Basic Functions | |
289 | |
290 This chapter describes the basic, ground-level functions for parsing and | |
291 handling. Covered here is parsing @code{From} lines, removing comments | |
292 from header lines, decoding encoded words, parsing date headers and so | |
293 on. High-level functionality is dealt with in the next chapter | |
294 (@pxref{Decoding and Viewing}). | |
295 | |
296 @menu | |
297 * rfc2045:: Encoding @code{Content-Type} headers. | |
298 * rfc2231:: Parsing @code{Content-Type} headers. | |
299 * ietf-drums:: Handling mail headers defined by RFC822bis. | |
300 * rfc2047:: En/decoding encoded words in headers. | |
301 * time-date:: Functions for parsing dates and manipulating time. | |
302 * qp:: Quoted-Printable en/decoding. | |
303 * base64:: Base64 en/decoding. | |
304 * binhex:: Binhex decoding. | |
305 * uudecode:: Uuencode decoding. | |
306 * rfc1843:: Decoding HZ-encoded text. | |
307 * mailcap:: How parts are displayed is specified by the @file{.mailcap} file | |
308 @end menu | |
309 | |
310 | |
311 @node rfc2045 | |
312 @section rfc2045 | |
313 | |
314 RFC2045 is the ``main'' @sc{mime} document, and as such, one would | |
315 imagine that there would be a lot to implement. But there isn't, since | |
316 most of the implementation details are delegated to the subsequent | |
317 RFCs. | |
318 | |
319 So @file{rfc2045.el} has only a single function: | |
320 | |
321 @table @code | |
322 @item rfc2045-encode-string | |
323 @findex rfc2045-encode-string | |
324 Takes a parameter and a value and returns a @samp{PARAM=VALUE} string. | |
325 @var{value} will be quoted if there are non-safe characters in it. | |
326 @end table | |
327 | |
328 | |
329 @node rfc2231 | |
330 @section rfc2231 | |
331 | |
332 RFC2231 defines a syntax for the @code{Content-Type} and | |
333 @code{Content-Disposition} headers. Its snappy name is @dfn{MIME | |
334 Parameter Value and Encoded Word Extensions: Character Sets, Languages, | |
335 and Continuations}. | |
336 | |
337 In short, these headers look something like this: | |
338 | |
339 @example | |
340 Content-Type: application/x-stuff; | |
341 title*0*=us-ascii'en'This%20is%20even%20more%20; | |
342 title*1*=%2A%2A%2Afun%2A%2A%2A%20; | |
343 title*2="isn't it!" | |
344 @end example | |
345 | |
346 They usually aren't this bad, though. | |
347 | |
348 The following functions are defined by this library: | |
349 | |
350 @table @code | |
351 @item rfc2231-parse-string | |
352 @findex rfc2231-parse-string | |
353 Parse a @code{Content-Type} header and return a list describing its | |
354 elements. | |
355 | |
356 @example | |
357 (rfc2231-parse-string | |
358 "application/x-stuff; | |
359 title*0*=us-ascii'en'This%20is%20even%20more%20; | |
360 title*1*=%2A%2A%2Afun%2A%2A%2A%20; | |
361 title*2=\"isn't it!\"") | |
362 @result{} ("application/x-stuff" | |
363 (title . "This is even more ***fun*** isn't it!")) | |
364 @end example | |
365 | |
366 @item rfc2231-get-value | |
367 @findex rfc2231-get-value | |
368 Takes one of the lists on the format above and returns | |
369 the value of the specified attribute. | |
370 | |
371 @item rfc2231-encode-string | |
372 @findex rfc2231-encode-string | |
373 Encode a parameter in headers likes @code{Content-Type} and | |
374 @code{Content-Disposition}. | |
375 | |
376 @end table | |
377 | |
378 | |
379 @node ietf-drums | |
380 @section ietf-drums | |
381 | |
382 @dfn{drums} is an IETF working group that is working on the replacement | |
383 for RFC822. | |
384 | |
385 The functions provided by this library include: | |
386 | |
387 @table @code | |
388 @item ietf-drums-remove-comments | |
389 @findex ietf-drums-remove-comments | |
390 Remove the comments from the argument and return the results. | |
391 | |
392 @item ietf-drums-remove-whitespace | |
393 @findex ietf-drums-remove-whitespace | |
394 Remove linear white space from the string and return the results. | |
395 Spaces inside quoted strings and comments are left untouched. | |
396 | |
397 @item ietf-drums-get-comment | |
398 @findex ietf-drums-get-comment | |
399 Return the last most comment from the string. | |
400 | |
401 @item ietf-drums-parse-address | |
402 @findex ietf-drums-parse-address | |
403 Parse an address string and return a list that contains the mailbox and | |
404 the plain text name. | |
405 | |
406 @item ietf-drums-parse-addresses | |
407 @findex ietf-drums-parse-addresses | |
408 Parse a string that contains any number of comma-separated addresses and | |
409 return a list that contains mailbox/plain text pairs. | |
410 | |
411 @item ietf-drums-parse-date | |
412 @findex ietf-drums-parse-date | |
413 Parse a date string and return an Emacs time structure. | |
414 | |
415 @item ietf-drums-narrow-to-header | |
416 @findex ietf-drums-narrow-to-header | |
417 Narrow the buffer to the header section of the current buffer. | |
418 | |
419 @end table | |
420 | |
421 | |
422 @node rfc2047 | |
423 @section rfc2047 | |
424 | |
425 RFC2047 (Message Header Extensions for Non-ASCII Text) specifies how | |
426 non-ASCII text in headers are to be encoded. This is actually rather | |
427 complicated, so a number of variables are necessary to tweak what this | |
428 library does. | |
429 | |
430 The following variables are tweakable: | |
431 | |
432 @table @code | |
433 @item rfc2047-default-charset | |
434 @vindex rfc2047-default-charset | |
435 Characters in this charset should not be decoded by this library. | |
436 This defaults to @code{iso-8859-1}. | |
437 | |
438 @item rfc2047-header-encoding-list | |
439 @vindex rfc2047-header-encoding-list | |
440 This is an alist of header / encoding-type pairs. Its main purpose is | |
441 to prevent encoding of certain headers. | |
442 | |
443 The keys can either be header regexps, or @code{t}. | |
444 | |
445 The values can be either @code{nil}, in which case the header(s) in | |
446 question won't be encoded, or @code{mime}, which means that they will be | |
447 encoded. | |
448 | |
449 @item rfc2047-charset-encoding-alist | |
450 @vindex rfc2047-charset-encoding-alist | |
451 RFC2047 specifies two forms of encoding---@code{Q} (a | |
452 Quoted-Printable-like encoding) and @code{B} (base64). This alist | |
453 specifies which charset should use which encoding. | |
454 | |
455 @item rfc2047-encoding-function-alist | |
456 @vindex rfc2047-encoding-function-alist | |
457 This is an alist of encoding / function pairs. The encodings are | |
458 @code{Q}, @code{B} and @code{nil}. | |
459 | |
460 @item rfc2047-q-encoding-alist | |
461 @vindex rfc2047-q-encoding-alist | |
462 The @code{Q} encoding isn't quite the same for all headers. Some | |
463 headers allow a narrower range of characters, and that is what this | |
464 variable is for. It's an alist of header regexps / allowable character | |
465 ranges. | |
466 | |
467 @item rfc2047-encoded-word-regexp | |
468 @vindex rfc2047-encoded-word-regexp | |
469 When decoding words, this library looks for matches to this regexp. | |
470 | |
471 @end table | |
472 | |
473 Those were the variables, and these are this functions: | |
474 | |
475 @table @code | |
476 @item rfc2047-narrow-to-field | |
477 @findex rfc2047-narrow-to-field | |
478 Narrow the buffer to the header on the current line. | |
479 | |
480 @item rfc2047-encode-message-header | |
481 @findex rfc2047-encode-message-header | |
482 Should be called narrowed to the header of a message. Encodes according | |
483 to @code{rfc2047-header-encoding-alist}. | |
484 | |
485 @item rfc2047-encode-region | |
486 @findex rfc2047-encode-region | |
487 Encodes all encodable words in the region specified. | |
488 | |
489 @item rfc2047-encode-string | |
490 @findex rfc2047-encode-string | |
491 Encode a string and return the results. | |
492 | |
493 @item rfc2047-decode-region | |
494 @findex rfc2047-decode-region | |
495 Decode the encoded words in the region. | |
496 | |
497 @item rfc2047-decode-string | |
498 @findex rfc2047-decode-string | |
499 Decode a string and return the results. | |
500 | |
501 @end table | |
502 | |
503 | |
504 @node time-date | |
505 @section time-date | |
506 | |
507 While not really a part of the @sc{mime} library, it is convenient to | |
508 document this library here. It deals with parsing @code{Date} headers | |
509 and manipulating time. (Not by using tesseracts, though, I'm sorry to | |
510 say.) | |
511 | |
512 These functions convert between five formats: A date string, an Emacs | |
513 time structure, a decoded time list, a second number, and a day number. | |
514 | |
515 The functions have quite self-explanatory names, so the following just | |
516 gives an overview of which functions are available. | |
517 | |
518 @example | |
519 (parse-time-string "Sat Sep 12 12:21:54 1998 +0200") | |
520 @result{} (54 21 12 12 9 1998 6 nil 7200) | |
521 | |
522 (date-to-time "Sat Sep 12 12:21:54 1998 +0200") | |
523 @result{} (13818 19266) | |
524 | |
525 (time-to-seconds '(13818 19266)) | |
526 @result{} 905595714.0 | |
527 | |
528 (seconds-to-time 905595714.0) | |
529 @result{} (13818 19266 0) | |
530 | |
531 (time-to-day '(13818 19266)) | |
532 @result{} 729644 | |
533 | |
534 (days-to-time 729644) | |
535 @result{} (961933 65536) | |
536 | |
537 (time-since '(13818 19266)) | |
538 @result{} (0 430) | |
539 | |
540 (time-less-p '(13818 19266) '(13818 19145)) | |
541 @result{} nil | |
542 | |
543 (subtract-time '(13818 19266) '(13818 19145)) | |
544 @result{} (0 121) | |
545 | |
546 (days-between "Sat Sep 12 12:21:54 1998 +0200" | |
547 "Sat Sep 07 12:21:54 1998 +0200") | |
548 @result{} 5 | |
549 | |
550 (date-leap-year-p 2000) | |
551 @result{} t | |
552 | |
553 (time-to-day-in-year '(13818 19266)) | |
554 @result{} 255 | |
555 | |
556 @end example | |
557 | |
558 And finally, we have @code{safe-date-to-time}, which does the same as | |
559 @code{date-to-time}, but returns a zero time if the date is | |
560 syntactically malformed. | |
561 | |
562 | |
563 | |
564 @node qp | |
565 @section qp | |
566 | |
567 This library deals with decoding and encoding Quoted-Printable text. | |
568 | |
32248
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
569 Very briefly explained, QP encoding means translating all 8-bit |
31853 | 570 characters (and lots of control characters) into things that look like |
571 @samp{=EF}; that is, an equal sign followed by the byte encoded as a hex | |
32248
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
572 string. It is defined in RFC 2045. |
31853 | 573 |
574 The following functions are defined by the library: | |
575 | |
32248
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
576 @deffn Command quoted-printable-decode-region @var{from} @var{to} &optional @var{coding-system} |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
577 QP-decode all the encoded text in the region. If @var{coding-system} is |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
578 non-nil, decode bytes into characters with that coding-system. |
32258 | 579 @end deffn |
31853 | 580 |
32248
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
581 @defun quoted-printable-decode-string @var{string} &optional @var{coding-system} |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
582 Return a QP-encoded copy of @var{string}. If @var{coding-system} is |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
583 non-nil, decode bytes into characters with that coding-system. |
32258 | 584 @end defun |
31853 | 585 |
32248
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
586 @deffn Command quoted-printable-encode-region @var{from} @var{to} &optional @var{fold} @var{class} |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
587 QP-encode all the region. If @var{fold} is non-@var{nil}, fold lines at |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
588 76 characters, as required by the RFC. If @var{class} is |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
589 non-@code{nil}, translate the characters matched by that class in the |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
590 form expected by @var{skip-chars-forward}. If variable |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
591 @var{mm-use-ultra-safe-encoding} is defined and non-@code{nil}, fold |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
592 lines unconditionally and encode lines starting with @samp{From }. |
32258 | 593 @end deffn |
31853 | 594 |
32248
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
595 @defun quoted-printable-encode-string string |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
596 Return a QP-encoded copy of @var{string}. |
32258 | 597 @end defun |
31853 | 598 |
599 @node base64 | |
600 @section base64 | |
601 @cindex base64 | |
602 | |
603 Base64 is an encoding that encodes three bytes into four characters, | |
604 thereby increasing the size by about 33%. The alphabet used for | |
32248
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
605 encoding is very resistant to mangling during transit. @xref{Base |
086aff3bf8ca
Modify licence notice. QP, base64 changes.
Dave Love <fx@gnu.org>
parents:
32085
diff
changeset
|
606 64,,Base 64 Encoding, elisp, The Emacs Lisp Reference Manual}. |
31853 | 607 |
608 @node binhex | |
609 @section binhex | |
610 @cindex binhex | |
611 @cindex Apple | |
612 @cindex Macintosh | |
613 | |
614 @code{binhex} is an encoding that originated in Macintosh environments. | |
615 The following function is supplied to deal with these: | |
616 | |
617 @table @code | |
618 @item binhex-decode-region | |
619 @findex binhex-decode-region | |
620 Decode the encoded text in the region. If given a third parameter, only | |
621 decode the @code{binhex} header and return the filename. | |
622 | |
623 @end table | |
624 | |
625 | |
626 @node uudecode | |
627 @section uudecode | |
628 @cindex uuencode | |
629 @cindex uudecode | |
630 | |
631 @code{uuencode} is probably still the most popular encoding of binaries | |
632 used on Usenet, although @code{base64} rules the mail world. | |
633 | |
634 The following function is supplied by this package: | |
635 | |
636 @table @code | |
637 @item uudecode-decode-region | |
638 @findex uudecode-decode-region | |
639 Decode the text in the region. | |
640 @end table | |
641 | |
642 | |
643 @node rfc1843 | |
644 @section rfc1843 | |
645 @cindex rfc1843 | |
646 @cindex HZ | |
647 @cindex Chinese | |
648 | |
649 RFC1843 deals with mixing Chinese and ASCII characters in messages. In | |
650 essence, RFC1843 switches between ASCII and Chinese by doing this: | |
651 | |
652 @example | |
653 This sentence is in ASCII. | |
654 The next sentence is in GB.~@{<:Ky2;S@{#,NpJ)l6HK!#~@}Bye. | |
655 @end example | |
656 | |
657 Simple enough, and widely used in China. | |
658 | |
659 The following functions are available to handle this encoding: | |
660 | |
661 @table @code | |
662 @item rfc1843-decode-region | |
663 Decode HZ-encoded text in the region. | |
664 | |
665 @item rfc1843-decode-string | |
666 Decode a HZ-encoded string and return the result. | |
667 | |
668 @end table | |
669 | |
670 | |
671 @node mailcap | |
672 @section mailcap | |
673 | |
674 The @file{~/.mailcap} file is parsed by most @sc{mime}-aware message | |
675 handlers and describes how elements are supposed to be displayed. | |
676 Here's an example file: | |
677 | |
678 @example | |
679 image/*; gimp -8 %s | |
680 audio/wav; wavplayer %s | |
681 @end example | |
682 | |
683 This says that all image files should be displayed with @code{gimp}, and | |
684 that realaudio files should be played by @code{rvplayer}. | |
685 | |
686 The @code{mailcap} library parses this file, and provides functions for | |
687 matching types. | |
688 | |
689 @table @code | |
690 @item mailcap-mime-data | |
691 @vindex mailcap-mime-data | |
692 This variable is an alist of alists containing backup viewing rules. | |
693 | |
694 @end table | |
695 | |
696 Interface functions: | |
697 | |
698 @table @code | |
699 @item mailcap-parse-mailcaps | |
700 @findex mailcap-parse-mailcaps | |
701 Parse the @code{~/.mailcap} file. | |
702 | |
703 @item mailcap-mime-info | |
704 Takes a @sc{mime} type as its argument and returns the matching viewer. | |
705 | |
706 @end table | |
707 | |
708 | |
709 | |
710 | |
711 @node Decoding and Viewing | |
712 @chapter Decoding and Viewing | |
713 | |
714 This chapter deals with decoding and viewing @sc{mime} messages on a | |
715 higher level. | |
716 | |
717 The main idea is to first analyze a @sc{mime} article, and then allow | |
718 other programs to do things based on the list of @dfn{handles} that are | |
719 returned as a result of this analysis. | |
720 | |
721 @menu | |
722 * Dissection:: Analyzing a @sc{mime} message. | |
723 * Handles:: Handle manipulations. | |
724 * Display:: Displaying handles. | |
725 * Customization:: Variables that affect display. | |
726 * New Viewers:: How to write your own viewers. | |
727 @end menu | |
728 | |
729 | |
730 @node Dissection | |
731 @section Dissection | |
732 | |
733 The @code{mm-dissect-buffer} is the function responsible for dissecting | |
734 a @sc{mime} article. If given a multipart message, it will recursively | |
735 descend the message, following the structure, and return a tree of | |
736 @sc{mime} handles that describes the structure of the message. | |
737 | |
738 | |
739 @node Handles | |
740 @section Handles | |
741 | |
742 A @sc{mime} handle is a list that fully describes a @sc{mime} | |
743 component. | |
744 | |
745 The following macros can be used to access elements in a handle: | |
746 | |
747 @table @code | |
748 @item mm-handle-buffer | |
749 @findex mm-handle-buffer | |
750 Return the buffer that holds the contents of the undecoded @sc{mime} | |
751 part. | |
752 | |
753 @item mm-handle-type | |
754 @findex mm-handle-type | |
755 Return the parsed @code{Content-Type} of the part. | |
756 | |
757 @item mm-handle-encoding | |
758 @findex mm-handle-encoding | |
759 Return the @code{Content-Transfer-Encoding} of the part. | |
760 | |
761 @item mm-handle-undisplayer | |
762 @findex mm-handle-undisplayer | |
763 Return the object that can be used to remove the displayed part (if it | |
764 has been displayed). | |
765 | |
766 @item mm-handle-set-undisplayer | |
767 @findex mm-handle-set-undisplayer | |
768 Set the undisplayer object. | |
769 | |
770 @item mm-handle-disposition | |
771 @findex mm-handle-disposition | |
772 Return the parsed @code{Content-Disposition} of the part. | |
773 | |
774 @item mm-handle-disposition | |
775 @findex mm-handle-disposition | |
776 Return the description of the part. | |
777 | |
778 @item mm-get-content-id | |
779 Returns the handle(s) referred to by @code{Content-ID}. | |
780 | |
781 @end table | |
782 | |
783 | |
784 @node Display | |
785 @section Display | |
786 | |
787 Functions for displaying, removing and saving. | |
788 | |
789 @table @code | |
790 @item mm-display-part | |
791 @findex mm-display-part | |
792 Display the part. | |
793 | |
794 @item mm-remove-part | |
795 @findex mm-remove-part | |
796 Remove the part (if it has been displayed). | |
797 | |
798 @item mm-inlinable-p | |
799 @findex mm-inlinable-p | |
800 Say whether a @sc{mime} type can be displayed inline. | |
801 | |
802 @item mm-automatic-display-p | |
803 @findex mm-automatic-display-p | |
804 Say whether a @sc{mime} type should be displayed automatically. | |
805 | |
806 @item mm-destroy-part | |
807 @findex mm-destroy-part | |
808 Free all resources occupied by a part. | |
809 | |
810 @item mm-save-part | |
811 @findex mm-save-part | |
812 Offer to save the part in a file. | |
813 | |
814 @item mm-pipe-part | |
815 @findex mm-pipe-part | |
816 Offer to pipe the part to some process. | |
817 | |
818 @item mm-interactively-view-part | |
819 @findex mm-interactively-view-part | |
820 Prompt for a mailcap method to use to view the part. | |
821 | |
822 @end table | |
823 | |
824 | |
825 @node Customization | |
826 @section Customization | |
827 | |
828 @table @code | |
829 | |
830 @item mm-inline-media-tests | |
831 This is an alist where the key is a @sc{mime} type, the second element | |
832 is a function to display the part @dfn{inline} (i.e., inside Emacs), and | |
833 the third element is a form to be @code{eval}ed to say whether the part | |
834 can be displayed inline. | |
835 | |
836 This variable specifies whether a part @emph{can} be displayed inline, | |
837 and, if so, how to do it. It does not say whether parts are | |
838 @emph{actually} displayed inline. | |
839 | |
840 @item mm-inlined-types | |
841 This, on the other hand, says what types are to be displayed inline, if | |
842 they satisfy the conditions set by the variable above. It's a list of | |
843 @sc{mime} media types. | |
844 | |
845 @item mm-automatic-display | |
846 This is a list of types that are to be displayed ``automatically'', but | |
847 only if the above variable allows it. That is, only inlinable parts can | |
848 be displayed automatically. | |
849 | |
850 @item mm-attachment-override-types | |
851 Some @sc{mime} agents create parts that have a content-disposition of | |
852 @samp{attachment}. This variable allows overriding that disposition and | |
853 displaying the part inline. (Note that the disposition is only | |
854 overridden if we are able to, and want to, display the part inline.) | |
855 | |
856 @item mm-discouraged-alternatives | |
857 List of @sc{mime} types that are discouraged when viewing | |
858 @samp{multipart/alternative}. Viewing agents are supposed to view the | |
859 last possible part of a message, as that is supposed to be the richest. | |
860 However, users may prefer other types instead, and this list says what | |
861 types are most unwanted. If, for instance, @samp{text/html} parts are | |
862 very unwanted, and @samp{text/richtech} parts are somewhat unwanted, | |
863 then the value of this variable should be set to: | |
864 | |
865 @lisp | |
866 ("text/html" "text/richtext") | |
867 @end lisp | |
868 | |
869 @item mm-inline-large-images-p | |
870 When displaying inline images that are larger than the window, XEmacs | |
871 does not enable scrolling, which means that you cannot see the whole | |
872 image. To prevent this, the library tries to determine the image size | |
873 before displaying it inline, and if it doesn't fit the window, the | |
874 library will display it externally (e.g. with @samp{ImageMagick} or | |
875 @samp{xv}). Setting this variable to @code{t} disables this check and | |
876 makes the library display all inline images as inline, regardless of | |
877 their size. | |
878 | |
879 @item mm-inline-override-p | |
880 @code{mm-inlined-types} may include regular expressions, for example to | |
881 specify that all @samp{text/.*} parts be displayed inline. If a user | |
882 prefers to have a type that matches such a regular expression be treated | |
883 as an attachment, that can be accomplished by setting this variable to a | |
884 list containing that type. For example assuming @code{mm-inlined-types} | |
885 includes @samp{text/.*}, then including @samp{text/html} in this | |
886 variable will cause @samp{text/html} parts to be treated as attachments. | |
887 | |
888 @end table | |
889 | |
890 | |
891 @node New Viewers | |
892 @section New Viewers | |
893 | |
894 Here's an example viewer for displaying @code{text/enriched} inline: | |
895 | |
896 @lisp | |
897 (defun mm-display-enriched-inline (handle) | |
898 (let (text) | |
899 (with-temp-buffer | |
900 (mm-insert-part handle) | |
901 (save-window-excursion | |
902 (enriched-decode (point-min) (point-max)) | |
903 (setq text (buffer-string)))) | |
904 (mm-insert-inline handle text))) | |
905 @end lisp | |
906 | |
907 We see that the function takes a @sc{mime} handle as its parameter. It | |
908 then goes to a temporary buffer, inserts the text of the part, does some | |
909 work on the text, stores the result, goes back to the buffer it was | |
910 called from and inserts the result. | |
911 | |
912 The two important helper functions here are @code{mm-insert-part} and | |
913 @code{mm-insert-inline}. The first function inserts the text of the | |
914 handle in the current buffer. It handles charset and/or content | |
915 transfer decoding. The second function just inserts whatever text you | |
916 tell it to insert, but it also sets things up so that the text can be | |
917 ``undisplayed' in a convenient manner. | |
918 | |
919 | |
920 @node Composing | |
921 @chapter Composing | |
922 @cindex Composing | |
923 @cindex MIME Composing | |
924 @cindex MML | |
925 @cindex MIME Meta Language | |
926 | |
927 Creating a @sc{mime} message is boring and non-trivial. Therefore, a | |
928 library called @code{mml} has been defined that parses a language called | |
929 MML (@sc{mime} Meta Language) and generates @sc{mime} messages. | |
930 | |
931 @findex mml-generate-mime | |
932 The main interface function is @code{mml-generate-mime}. It will | |
933 examine the contents of the current (narrowed-to) buffer and return a | |
934 string containing the @sc{mime} message. | |
935 | |
936 @menu | |
937 * Simple MML Example:: An example MML document. | |
938 * MML Definition:: All valid MML elements. | |
939 * Advanced MML Example:: Another example MML document. | |
940 * Charset Translation:: How charsets are mapped from @sc{mule} to MIME. | |
941 * Conversion:: Going from @sc{mime} to MML and vice versa. | |
942 @end menu | |
943 | |
944 | |
945 @node Simple MML Example | |
946 @section Simple MML Example | |
947 | |
948 Here's a simple @samp{multipart/alternative}: | |
949 | |
950 @example | |
951 <#multipart type=alternative> | |
952 This is a plain text part. | |
953 <#part type=text/enriched> | |
954 <center>This is a centered enriched part</center> | |
955 <#/multipart> | |
956 @end example | |
957 | |
958 After running this through @code{mml-generate-mime}, we get this: | |
959 | |
960 @example | |
961 Content-Type: multipart/alternative; boundary="=-=-=" | |
962 | |
963 | |
964 --=-=-= | |
965 | |
966 | |
967 This is a plain text part. | |
968 | |
969 --=-=-= | |
970 Content-Type: text/enriched | |
971 | |
972 | |
973 <center>This is a centered enriched part</center> | |
974 | |
975 --=-=-=-- | |
976 @end example | |
977 | |
978 | |
979 @node MML Definition | |
980 @section MML Definition | |
981 | |
982 The MML language is very simple. It looks a bit like an SGML | |
983 application, but it's not. | |
984 | |
985 The main concept of MML is the @dfn{part}. Each part can be of a | |
986 different type or use a different charset. The way to delineate a part | |
987 is with a @samp{<#part ...>} tag. Multipart parts can be introduced | |
988 with the @samp{<#multipart ...>} tag. Parts are ended by the | |
989 @samp{<#/part>} or @samp{<#/multipart>} tags. Parts started with the | |
990 @samp{<#part ...>} tags are also closed by the next open tag. | |
991 | |
992 There's also the @samp{<#external ...>} tag. These introduce | |
993 @samp{external/message-body} parts. | |
994 | |
995 Each tag can contain zero or more parameters on the form | |
996 @samp{parameter=value}. The values may be enclosed in quotation marks, | |
997 but that's not necessary unless the value contains white space. So | |
998 @samp{filename=/home/user/#hello$^yes} is perfectly valid. | |
999 | |
1000 The following parameters have meaning in MML; parameters that have no | |
1001 meaning are ignored. The MML parameter names are the same as the | |
1002 @sc{mime} parameter names; the things in the parentheses say which | |
1003 header it will be used in. | |
1004 | |
1005 @table @samp | |
1006 @item type | |
1007 The @sc{mime} type of the part (@code{Content-Type}). | |
1008 | |
1009 @item filename | |
1010 Use the contents of the file in the body of the part | |
1011 (@code{Content-Disposition}). | |
1012 | |
1013 @item charset | |
1014 The contents of the body of the part are to be encoded in the character | |
1015 set speficied (@code{Content-Type}). | |
1016 | |
1017 @item name | |
1018 Might be used to suggest a file name if the part is to be saved | |
1019 to a file (@code{Content-Type}). | |
1020 | |
1021 @item disposition | |
1022 Valid values are @samp{inline} and @samp{attachment} | |
1023 (@code{Content-Disposition}). | |
1024 | |
1025 @item encoding | |
1026 Valid values are @samp{7bit}, @samp{8bit}, @samp{quoted-printable} and | |
1027 @samp{base64} (@code{Content-Transfer-Encoding}). | |
1028 | |
1029 @item description | |
1030 A description of the part (@code{Content-Description}). | |
1031 | |
1032 @item creation-date | |
1033 RFC822 date when the part was created (@code{Content-Disposition}). | |
1034 | |
1035 @item modification-date | |
1036 RFC822 date when the part was modified (@code{Content-Disposition}). | |
1037 | |
1038 @item read-date | |
1039 RFC822 date when the part was read (@code{Content-Disposition}). | |
1040 | |
1041 @item size | |
1042 The size (in octets) of the part (@code{Content-Disposition}). | |
1043 | |
1044 @end table | |
1045 | |
1046 Parameters for @samp{application/octet-stream}: | |
1047 | |
1048 @table @samp | |
1049 @item type | |
1050 Type of the part; informal---meant for human readers | |
1051 (@code{Content-Type}). | |
1052 @end table | |
1053 | |
1054 Parameters for @samp{message/external-body}: | |
1055 | |
1056 @table @samp | |
1057 @item access-type | |
1058 A word indicating the supported access mechanism by which the file may | |
1059 be obtained. Values include @samp{ftp}, @samp{anon-ftp}, @samp{tftp}, | |
1060 @samp{localfile}, and @samp{mailserver}. (@code{Content-Type}.) | |
1061 | |
1062 @item expiration | |
1063 The RFC822 date after which the file may no longer be fetched. | |
1064 (@code{Content-Type}.) | |
1065 | |
1066 @item size | |
1067 The size (in octets) of the file. (@code{Content-Type}.) | |
1068 | |
1069 @item permission | |
1070 Valid values are @samp{read} and @samp{read-write} | |
1071 (@code{Content-Type}). | |
1072 | |
1073 @end table | |
1074 | |
1075 | |
1076 @node Advanced MML Example | |
1077 @section Advanced MML Example | |
1078 | |
1079 Here's a complex multipart message. It's a @samp{multipart/mixed} that | |
1080 contains many parts, one of which is a @samp{multipart/alternative}. | |
1081 | |
1082 @example | |
1083 <#multipart type=mixed> | |
1084 <#part type=image/jpeg filename=~/rms.jpg disposition=inline> | |
1085 <#multipart type=alternative> | |
1086 This is a plain text part. | |
1087 <#part type=text/enriched name=enriched.txt> | |
1088 <center>This is a centered enriched part</center> | |
1089 <#/multipart> | |
1090 This is a new plain text part. | |
1091 <#part disposition=attachment> | |
1092 This plain text part is an attachment. | |
1093 <#/multipart> | |
1094 @end example | |
1095 | |
1096 And this is the resulting @sc{mime} message: | |
1097 | |
1098 @example | |
1099 Content-Type: multipart/mixed; boundary="=-=-=" | |
1100 | |
1101 | |
1102 --=-=-= | |
1103 | |
1104 | |
1105 | |
1106 --=-=-= | |
1107 Content-Type: image/jpeg; | |
1108 filename="~/rms.jpg" | |
1109 Content-Disposition: inline; | |
1110 filename="~/rms.jpg" | |
1111 Content-Transfer-Encoding: base64 | |
1112 | |
1113 /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof | |
1114 Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/wAALCAAwADABAREA/8QAHwAA | |
1115 AQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQR | |
1116 BRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RF | |
1117 RkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ip | |
1118 qrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/9oACAEB | |
1119 AAA/AO/rifFHjldNuGsrDa0qcSSHkA+gHrXKw+LtWLrMb+RgTyhbr+HSug07xNqV9fQtZrNI | |
1120 AyiaE/NuBPOOOP0rvRNE880KOC8TbXXGCv1FPqjrF4LDR7u5L7SkTFT/ALWOP1xXgTuXfc7E | |
1121 sx6nua6rwp4IvvEM8chCxWxOdzn7wz6V9AaB4S07w9p5itow0rDLSY5Pt9K43xO66P4xs71m | |
1122 2QXiGCbA4yOVJ9+1aYORkdK434lyNH4ahCnG66VT9Nj15JFbPdX0MS43M4VQf5/yr2vSpLnw | |
1123 5ZW8dlCZ8KFXjOPX0/mK6rSPEGt3Angu44fNEReHYNvIH3TzXDeKNO8RX+kSX2ouZkicTIOc | |
1124 L+g7E810ulFjpVtv3bwgB3HJyK5L4quY/C9sVxk3ij/xx6850u7t1mtp/wDlpEw3An3Jr3Dw | |
1125 34gsbWza4nBlhC5LDsaW6+IFgupQyCF3iHH7gA7c9R9ay7zx6t7aX9jHC4smhfBkGCvHGfrm | |
1126 tLQ7hbnRrV1GPkAP1x1/Hr+Ncr8Vzjwrbf8AX6v/AKA9eQRyYlQk8Yx9K6XTNbkgia2ciSIn | |
1127 7p5Ga9Atte0LTLKO6it4i7dVRFJDcZ4PvXN+JvEMF9bILVGXJLSZ4zkjivRPDaeX4b08HOTC | |
1128 pOffmua+KkbS+GLVUGT9tT/0B68eeIpIFYjB70+OOVXyoOM9+M1eaWeCLzHPyHGO/NVWvJJm | |
1129 jQ8KGH1NfQWhXSXmh2c8eArRLwO3HSv/2Q== | |
1130 | |
1131 --=-=-= | |
1132 Content-Type: multipart/alternative; boundary="==-=-=" | |
1133 | |
1134 | |
1135 --==-=-= | |
1136 | |
1137 | |
1138 This is a plain text part. | |
1139 | |
1140 --==-=-= | |
1141 Content-Type: text/enriched; | |
1142 name="enriched.txt" | |
1143 | |
1144 | |
1145 <center>This is a centered enriched part</center> | |
1146 | |
1147 --==-=-=-- | |
1148 | |
1149 --=-=-= | |
1150 | |
1151 This is a new plain text part. | |
1152 | |
1153 --=-=-= | |
1154 Content-Disposition: attachment | |
1155 | |
1156 | |
1157 This plain text part is an attachment. | |
1158 | |
1159 --=-=-=-- | |
1160 @end example | |
1161 | |
1162 @node Charset Translation | |
1163 @section Charset Translation | |
1164 @cindex charsets | |
1165 | |
1166 During translation from MML to @sc{mime}, for each @sc{mime} part which | |
1167 has been composed inside Emacs, an appropriate charset has to be chosen. | |
1168 | |
1169 @vindex mail-parse-charset | |
1170 If you are running a non-@sc{mule} Emacs, this process is simple: If the | |
1171 part contains any non-ASCII (8-bit) characters, the @sc{mime} charset | |
1172 given by @code{mail-parse-charset} (a symbol) is used. (Never set this | |
1173 variable directly, though. If you want to change the default charset, | |
1174 please consult the documentation of the package which you use to process | |
1175 @sc{mime} messages. | |
1176 @xref{Various Message Variables, , Various Message Variables, message, | |
1177 Message Manual}, for example.) | |
1178 If there are only ASCII characters, the @sc{mime} charset US-ASCII is | |
1179 used, of course. | |
1180 | |
1181 @cindex MULE | |
1182 @cindex UTF-8 | |
1183 @cindex Unicode | |
1184 @vindex mm-mime-mule-charset-alist | |
1185 Things are slightly more complicated when running Emacs with @sc{mule} | |
1186 support. In this case, a list of the @sc{mule} charsets used in the | |
1187 part is obtained, and the @sc{mule} charsets are translated to @sc{mime} | |
1188 charsets by consulting the variable @code{mm-mime-mule-charset-alist}. | |
1189 If this results in a single @sc{mime} charset, this is used to encode | |
1190 the part. But if the resulting list of @sc{mime} charsets contains more | |
1191 than one element, two things can happen: If it is possible to encode the | |
1192 part via UTF-8, this charset is used. (For this, Emacs must support | |
1193 the @code{utf-8} coding system, and the part must consist entirely of | |
1194 characters which have Unicode counterparts.) If UTF-8 is not available | |
1195 for some reason, the part is split into several ones, so that each one | |
1196 can be encoded with a single @sc{mime} charset. The part can only be | |
1197 split at line boundaries, though---if more than one @sc{mime} charset is | |
1198 required to encode a single line, it is not possible to encode the part. | |
1199 | |
1200 @node Conversion | |
1201 @section Conversion | |
1202 | |
1203 @findex mime-to-mml | |
1204 A (multipart) @sc{mime} message can be converted to MML with the | |
1205 @code{mime-to-mml} function. It works on the message in the current | |
1206 buffer, and substitutes MML markup for @sc{mime} boundaries. | |
1207 Non-textual parts do not have their contents in the buffer, but instead | |
1208 have the contents in separate buffers that are referred to from the MML | |
1209 tags. | |
1210 | |
1211 @findex mml-to-mime | |
1212 An MML message can be converted back to @sc{mime} by the | |
1213 @code{mml-to-mime} function. | |
1214 | |
1215 These functions are in certain senses ``lossy''---you will not get back | |
1216 an identical message if you run @sc{mime-to-mml} and then | |
1217 @sc{mml-to-mime}. Not only will trivial things like the order of the | |
1218 headers differ, but the contents of the headers may also be different. | |
1219 For instance, the original message may use base64 encoding on text, | |
1220 while @sc{mml-to-mime} may decide to use quoted-printable encoding, and | |
1221 so on. | |
1222 | |
1223 In essence, however, these two functions should be the inverse of each | |
1224 other. The resulting contents of the message should remain equivalent, | |
1225 if not identical. | |
1226 | |
1227 | |
1228 @node Standards | |
1229 @chapter Standards | |
1230 | |
1231 The Emacs @sc{mime} library implements handling of various elements | |
1232 according to a (somewhat) large number of RFCs, drafts and standards | |
1233 documents. This chapter lists the relevant ones. They can all be | |
1234 fetched from @samp{http://quimby.gnus.org/notes/}. | |
1235 | |
1236 @table @dfn | |
1237 @item RFC822 | |
1238 @itemx STD11 | |
1239 Standard for the Format of ARPA Internet Text Messages. | |
1240 | |
1241 @item RFC1036 | |
1242 Standard for Interchange of USENET Messages | |
1243 | |
1244 @item RFC2045 | |
1245 Format of Internet Message Bodies | |
1246 | |
1247 @item RFC2046 | |
1248 Media Types | |
1249 | |
1250 @item RFC2047 | |
1251 Message Header Extensions for Non-ASCII Text | |
1252 | |
1253 @item RFC2048 | |
1254 Registration Procedures | |
1255 | |
1256 @item RFC2049 | |
1257 Conformance Criteria and Examples | |
1258 | |
1259 @item RFC2231 | |
1260 MIME Parameter Value and Encoded Word Extensions: Character Sets, | |
1261 Languages, and Continuations | |
1262 | |
1263 @item RFC1843 | |
1264 HZ - A Data Format for Exchanging Files of Arbitrarily Mixed Chinese and | |
1265 ASCII characters | |
1266 | |
1267 @item draft-ietf-drums-msg-fmt-05.txt | |
1268 Draft for the successor of RFC822 | |
1269 | |
1270 @item RFC2112 | |
1271 The MIME Multipart/Related Content-type | |
1272 | |
1273 @item RFC1892 | |
1274 The Multipart/Report Content Type for the Reporting of Mail System | |
1275 Administrative Messages | |
1276 | |
1277 @item RFC2183 | |
1278 Communicating Presentation Information in Internet Messages: The | |
1279 Content-Disposition Header Field | |
1280 | |
1281 @end table | |
1282 | |
1283 | |
1284 @node Index | |
1285 @chapter Index | |
1286 @printindex cp | |
1287 | |
1288 @summarycontents | |
1289 @contents | |
1290 @bye | |
1291 | |
1292 @c End: |