Sync to HEAD
[bpt/emacs.git] / man / emacs-mime.texi
CommitLineData
00ed1b10 1\input texinfo @c -*-mode: texinfo; coding: latin-1 -*-
dd8839b0 2
a1720df0 3@setfilename ../info/emacs-mime
dd8839b0
DL
4@settitle Emacs MIME Manual
5@synindex fn cp
6@synindex vr cp
7@synindex pg cp
dd8839b0 8
18f952d5 9@copying
dd8839b0
DL
10This file documents the Emacs MIME interface functionality.
11
18f952d5 12Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
dd8839b0 13
18f952d5 14@quotation
dd8839b0
DL
15Permission is granted to copy, distribute and/or modify this document
16under the terms of the GNU Free Documentation License, Version 1.1 or
c5c46a26
DL
17any later version published by the Free Software Foundation; with no
18Invariant Sections, with the Front-Cover texts being ``A GNU
4b1b5ae8 19Manual,'' and with the Back-Cover Texts as in (a) below. A copy of the
dd8839b0 20license is included in the section entitled ``GNU Free Documentation
2482f038 21License'' in the Emacs manual.
dd8839b0
DL
22
23(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
24this GNU Manual, like GNU software. Copies published by the Free
25Software Foundation raise funds for GNU development.''
2482f038
DL
26
27This document is part of a collection distributed under the GNU Free
28Documentation License. If you want to distribute this document
29separately from the collection, you can do so by adding a copy of the
30license to the document, as described in section 6 of the license.
18f952d5
KB
31@end quotation
32@end copying
dd8839b0 33
18f952d5
KB
34@dircategory Emacs
35@direntry
36* MIME: (emacs-mime). Emacs MIME de/composition library.
37@end direntry
38@iftex
39@finalout
40@end iftex
41@setchapternewpage odd
dd8839b0
DL
42
43@titlepage
44@title Emacs MIME Manual
45
46@author by Lars Magne Ingebrigtsen
47@page
dd8839b0 48@vskip 0pt plus 1filll
18f952d5 49@insertcopying
dd8839b0 50@end titlepage
dd8839b0 51
dd8839b0
DL
52
53@node Top
54@top Emacs MIME
55
56This manual documents the libraries used to compose and display
57@sc{mime} messages.
58
59This is not a manual meant for users; it's a manual directed at people
60who want to write functions and commands that manipulate @sc{mime}
61elements.
62
63@sc{mime} is short for @dfn{Multipurpose Internet Mail Extensions}.
64This standard is documented in a number of RFCs; mainly RFC2045 (Format
65of Internet Message Bodies), RFC2046 (Media Types), RFC2047 (Message
66Header Extensions for Non-ASCII Text), RFC2048 (Registration
67Procedures), RFC2049 (Conformance Criteria and Examples). It is highly
68recommended that anyone who intends writing @sc{mime}-compliant software
69read at least RFC2045 and RFC2047.
70
71@menu
72* Interface Functions:: An abstraction over the basic functions.
73* Basic Functions:: Utility and basic parsing functions.
74* Decoding and Viewing:: A framework for decoding and viewing.
75* Composing:: MML; a language for describing MIME parts.
76* Standards:: A summary of RFCs and working documents used.
77* Index:: Function and variable index.
78@end menu
79
80
81@node Interface Functions
82@chapter Interface Functions
83@cindex interface functions
84@cindex mail-parse
85
86The @code{mail-parse} library is an abstraction over the actual
87low-level libraries that are described in the next chapter.
88
89Standards change, and so programs have to change to fit in the new
90mold. For instance, RFC2045 describes a syntax for the
edcfa240 91@code{Content-Type} header that only allows @sc{ascii} characters in the
dd8839b0 92parameter list. RFC2231 expands on RFC2045 syntax to provide a scheme
edcfa240 93for continuation headers and non-@sc{ascii} characters.
dd8839b0
DL
94
95The traditional way to deal with this is just to update the library
96functions to parse the new syntax. However, this is sometimes the wrong
97thing to do. In some instances it may be vital to be able to understand
98both the old syntax as well as the new syntax, and if there is only one
99library, one must choose between the old version of the library and the
100new version of the library.
101
102The Emacs MIME library takes a different tack. It defines a series of
103low-level libraries (@file{rfc2047.el}, @file{rfc2231.el} and so on)
104that parses strictly according to the corresponding standard. However,
105normal programs would not use the functions provided by these libraries
106directly, but instead use the functions provided by the
107@code{mail-parse} library. The functions in this library are just
108aliases to the corresponding functions in the latest low-level
109libraries. Using this scheme, programs get a consistent interface they
110can use, and library developers are free to create write code that
111handles new standards.
112
113The following functions are defined by this library:
114
edcfa240
DL
115@defun mail-header-parse-content-type string
116Parse @var{string}, a @code{Content-Type} header, and return a
117content-type list in the following format:
dd8839b0
DL
118
119@lisp
120("type/subtype"
121 (attribute1 . value1)
122 (attribute2 . value2)
edcfa240 123 @dots{})
dd8839b0
DL
124@end lisp
125
126Here's an example:
127
128@example
129(mail-header-parse-content-type
130 "image/gif; name=\"b980912.gif\"")
131@result{} ("image/gif" (name . "b980912.gif"))
132@end example
edcfa240 133@end defun
dd8839b0 134
edcfa240
DL
135@defun mail-header-parse-content-disposition string
136Parse @var{string}, a @code{Content-Disposition} header, and return a
137content-type list in the format above.
138@end defun
dd8839b0 139
edcfa240 140@defun mail-content-type-get ct attribute
dd8839b0 141@findex mail-content-type-get
edcfa240
DL
142Returns the value of the given @var{attribute} from the content-type
143list @var{ct}.
dd8839b0
DL
144
145@example
146(mail-content-type-get
147 '("image/gif" (name . "b980912.gif")) 'name)
148@result{} "b980912.gif"
149@end example
edcfa240 150@end defun
dd8839b0 151
edcfa240
DL
152@defun mail-header-encode-parameter param value
153Takes a parameter string @samp{@var{param}=@var{value}} and returns an
154encoded version of it. This is used for parameters in headers like
155@samp{Content-Type} and @samp{Content-Disposition}.
156@end defun
dd8839b0 157
edcfa240
DL
158@defun mail-header-remove-comments string
159Return a comment-free version of @var{string}.
dd8839b0
DL
160
161@example
162(mail-header-remove-comments
163 "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
164@result{} "Gnus/5.070027 "
165@end example
edcfa240 166@end defun
dd8839b0 167
edcfa240
DL
168@defun mail-header-remove-whitespace string
169Remove linear white space from @var{string}. Space inside quoted
170strings and comments is preserved.
dd8839b0
DL
171
172@example
173(mail-header-remove-whitespace
174 "image/gif; name=\"Name with spaces\"")
175@result{} "image/gif;name=\"Name with spaces\""
176@end example
edcfa240 177@end defun
dd8839b0 178
edcfa240
DL
179@defun mail-header-get-comment string
180Return the last comment in @var{string}.
dd8839b0
DL
181
182@example
183(mail-header-get-comment
184 "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
185@result{} "Finnish Landrace"
186@end example
edcfa240
DL
187@end defun
188
dd8839b0 189
edcfa240
DL
190@defun mail-header-parse-address string
191Parse an address string @var{string} and return a list containing the
192mailbox and the plaintext name.
dd8839b0
DL
193
194@example
195(mail-header-parse-address
196 "Hrvoje Niksic <hniksic@@srce.hr>")
197@result{} ("hniksic@@srce.hr" . "Hrvoje Niksic")
198@end example
edcfa240 199@end defun
dd8839b0 200
edcfa240
DL
201@defun mail-header-parse-addresses string
202Parse @var{string} as a list of addresses and return a list of elements
203like the one described above.
dd8839b0
DL
204
205@example
206(mail-header-parse-addresses
207 "Hrvoje Niksic <hniksic@@srce.hr>, Steinar Bang <sb@@metis.no>")
208@result{} (("hniksic@@srce.hr" . "Hrvoje Niksic")
209 ("sb@@metis.no" . "Steinar Bang"))
210@end example
edcfa240 211@end defun
dd8839b0 212
edcfa240
DL
213@defun mail-header-parse-date string
214Parse a date @var{string} and return an Emacs time structure.
215@end defun
dd8839b0 216
edcfa240 217@defun mail-narrow-to-head
dd8839b0
DL
218Narrow the buffer to the header section of the buffer. Point is placed
219at the beginning of the narrowed buffer.
edcfa240 220@end defun
dd8839b0 221
edcfa240 222@defun mail-header-narrow-to-field
dd8839b0 223Narrow the buffer to the header under point.
edcfa240 224@end defun
dd8839b0 225
edcfa240
DL
226@defun mail-encode-encoded-word-region start end
227Encode the non-@sc{ascii} words in the region @var{start}to @var{end}. For
228