3 @setfilename emacs-mime
4 @settitle Emacs MIME Manual
10 * Emacs MIME: (emacs-mime). The MIME de/composition library.
15 @setchapternewpage odd
19 This file documents the Emacs MIME interface functionality.
21 Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
23 Permission is granted to copy, distribute and/or modify this document
24 under the terms of the GNU Free Documentation License, Version 1.1 or
25 any later version published by the Free Software Foundation; with no
26 Invariant Sections, with the Front-Cover texts being ``A GNU
27 Manual'', and with the Back-Cover Texts as in (a) below. A copy of the
28 license is included in the section entitled ``GNU Free Documentation
29 License'' in the Emacs manual.
31 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
32 this GNU Manual, like GNU software. Copies published by the Free
33 Software Foundation raise funds for GNU development.''
35 This document is part of a collection distributed under the GNU Free
36 Documentation License. If you want to distribute this document
37 separately from the collection, you can do so by adding a copy of the
38 license to the document, as described in section 6 of the license.
44 @title Emacs MIME Manual
46 @author by Lars Magne Ingebrigtsen
49 @vskip 0pt plus 1filll
50 Copyright @copyright{} 1998, 1999, 2000, 2001, 2002 Free Software
53 Permission is granted to copy, distribute and/or modify this document
54 under the terms of the GNU Free Documentation License, Version 1.1 or
55 any later version published by the Free Software Foundation; with the
56 Invariant Sections being none, with the Front-Cover texts being ``A GNU
57 Manual'', and with the Back-Cover Texts as in (a) below. A copy of the
58 license is included in the section entitled ``GNU Free Documentation
59 License'' in the Emacs manual.
61 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
62 this GNU Manual, like GNU software. Copies published by the Free
63 Software Foundation raise funds for GNU development.''
65 This document is part of a collection distributed under the GNU Free
66 Documentation License. If you want to distribute this document
67 separately from the collection, you can do so by adding a copy of the
68 license to the document, as described in section 6 of the license.
77 This manual documents the libraries used to compose and display
80 This manual is directed at users who want to modify the behaviour of
81 the MIME encoding/decoding process or want a more detailed picture of
82 how the Emacs MIME library works, and people who want to write
83 functions and commands that manipulate @sc{mime} elements.
85 @sc{mime} is short for @dfn{Multipurpose Internet Mail Extensions}.
86 This standard is documented in a number of RFCs; mainly RFC2045 (Format
87 of Internet Message Bodies), RFC2046 (Media Types), RFC2047 (Message
88 Header Extensions for Non-ASCII Text), RFC2048 (Registration
89 Procedures), RFC2049 (Conformance Criteria and Examples). It is highly
90 recommended that anyone who intends writing @sc{mime}-compliant software
91 read at least RFC2045 and RFC2047.
94 * Interface Functions:: An abstraction over the basic functions.
95 * Basic Functions:: Utility and basic parsing functions.
96 * Decoding and Viewing:: A framework for decoding and viewing.
97 * Composing:: MML; a language for describing @sc{mime} parts.
98 * Standards:: A summary of RFCs and working documents used.
99 * Index:: Function and variable index.
103 @node Interface Functions
104 @chapter Interface Functions
105 @cindex interface functions
108 The @code{mail-parse} library is an abstraction over the actual
109 low-level libraries that are described in the next chapter.
111 Standards change, and so programs have to change to fit in the new
112 mold. For instance, RFC2045 describes a syntax for the
113 @code{Content-Type} header that only allows ASCII characters in the
114 parameter list. RFC2231 expands on RFC2045 syntax to provide a scheme
115 for continuation headers and non-ASCII characters.
117 The traditional way to deal with this is just to update the library
118 functions to parse the new syntax. However, this is sometimes the wrong
119 thing to do. In some instances it may be vital to be able to understand
120 both the old syntax as well as the new syntax, and if there is only one
121 library, one must choose between the old version of the library and the
122 new version of the library.
124 The Emacs @sc{mime} library takes a different tack. It defines a
125 series of low-level libraries (@file{rfc2047.el}, @file{rfc2231.el}
126 and so on) that parses strictly according to the corresponding
127 standard. However, normal programs would not use the functions
128 provided by these libraries directly, but instead use the functions
129 provided by the @code{mail-parse} library. The functions in this
130 library are just aliases to the corresponding functions in the latest
131 low-level libraries. Using this scheme, programs get a consistent
132 interface they can use, and library developers are free to create
133 write code that handles new standards.
135 The following functions are defined by this library:
138 @item mail-header-parse-content-type
139 @findex mail-header-parse-content-type
140 Parse a @code{Content-Type} header and return a list on the following
145 (attribute1 . value1)
146 (attribute2 . value2)
153 (mail-header-parse-content-type
154 "image/gif; name=\"b980912.gif\"")
155 @result{} ("image/gif" (name . "b980912.gif"))
158 @item mail-header-parse-content-disposition
159 @findex mail-header-parse-content-disposition
160 Parse a @code{Content-Disposition} header and return a list on the same
161 format as the function above.
163 @item mail-content-type-get
164 @findex mail-content-type-get
165 Takes two parameters---a list on the format above, and an attribute.
166 Returns the value of the attribute.
169 (mail-content-type-get
170 '("image/gif" (name . "b980912.gif")) 'name)
171 @result{} "b980912.gif"
174 @item mail-header-encode-parameter
175 @findex mail-header-encode-parameter
176 Takes a parameter string and returns an encoded version of the string.
177 This is used for parameters in headers like @code{Content-Type} and
178 @code{Content-Disposition}.
180 @item mail-header-remove-comments
181 @findex mail-header-remove-comments
182 Return a comment-free version of a header.
185 (mail-header-remove-comments
186 "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
187 @result{} "Gnus/5.070027 "
190 @item mail-header-remove-whitespace
191 @findex mail-header-remove-whitespace
192 Remove linear white space from a header. Space inside quoted strings
193 and comments is preserved.
196 (mail-header-remove-whitespace
197 "image/gif; name=\"Name with spaces\"")
198 @result{} "image/gif;name=\"Name with spaces\""
201 @item mail-header-get-comment
202 @findex mail-header-get-comment
203 Return the last comment in a header.
206 (mail-header-get-comment
207 "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
208 @result{} "Finnish Landrace"
211 @item mail-header-parse-address
212 @findex mail-header-parse-address
213 Parse an address and return a list containing the mailbox and the
217 (mail-header-parse-address
218 "Hrvoje Niksic <hniksic@@srce.hr>")
219 @result{} ("hniksic@@srce.hr" . "Hrvoje Niksic")
222 @item mail-header-parse-addresses
223 @findex mail-header-parse-addresses
224 Parse a string with list of addr