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