This file documents MIME features of FLIM, a fundamental library to process Internet Messages for GNU Emacsen.
FLIM is a library to provide basic features about message representation or encoding.
Please eval following to use MIME features provided by FLIM:
According to
The definition of RFC 2045 indicates that a MIME message is a tree, and each node of the tree is an entity. Namely MIME extends message to tree structure.
FLIM uses
Open an entity and return it.
type is representation-type.
location is location of entity. Specification of it is
depended on representation-type.
Parse buffer as message, and set the result to buffer local
variable
If buffer is omitted, current buffer is used.
type is representation-type of created mime-entity. mime-message-structure
of buffer as
mime-entity.
Structure of a MIME message is tree.
In the tree, root node is the entity indicates all of the message. In
this document, it is called mime-message-structure
.
Each entity except root-entity has a parent. An entity may have children. We can indicate an entity by relative position from a base entity, based on the parent-child relationship.
In addition, we can indicate an entity by absolute position of the message.
Each entity, which is a node of the tree, can be numbered by
depth and left-to-right order of the depth.
Namely, if depth of a node is n, the node has a node-number, which is
consists of n integers. In this document, it is called
(1 2 3)
.
mime-entity has also (3 2 1)
.
Each entity can be indicated by entity-number or node-id in
Buffer local variable to store mime-entity structure of message.
Return list of entities included in the entity.
Return parent entity of the entity.
If message is specified, it is regarded as root instead of
Return non-
Return node-id of entity.
Return entity-number of entity.
mime-message-structure
.
mime-message-structure
.
nil
if entity is root entity
(message).
Return entity from entity-number in message.
If message is not specified,
Return entity from entity-node-id in message.
If message is not specified,
Return entity from cid in message.
If message is not specified,
mime-message-structure
is used.
mime-message-structure
is used.
mime-message-structure
is used.
Return content-type of entity.
Return content-disposition of entity.
Return file name of entity.
Return content-transfer-encoding of entity.
If the entity does not have Content-Transfer-Encoding
field, this function returns default-encoding. If it is
nil,
Return non-nil if contents of entity has been already
code-converted.
"7bit"
is used as default value.
Return field-body of field-name field in header of
entity.
The results is network representation.
If entity is omitted,
If field-name field is not found, this function returns
Parse field-name field in header of entity, and
return the result.
Format of result is depended on kind of field. For non-structured
field, this function returns string. For structured field, it returns
list corresponding with structure of the field.
Strings in the result will be converted to internal representation of
Emacs.
If entity is omitted,
If field-name field is not found, this function returns
mime-message-structure
is used as default value.
nil
.
mime-message-structure
is used as default value.
nil
.
Insert before point a decoded contents of header of entity.
invisible-fields is list of regexps to match field-name to
hide. visible-fields is list of regexps to match
field-name to hide.
If a field-name is matched with some elements of
invisible-fields and matched with none of
visible-fields, this function don't insert the field.
Each
Insert before point a contents of entity as text entity.
Contents of the entity are decoded as
Symbol to indicate default value of
It is used when MIME charset is not specified.
It is originally variable of APEL.
default-mime-charset
.
default-mime-charset
is
used as default value.
Return content of entity as byte sequence.
Insert content of entity at point.
Write content of entity into filename.
Insert header and body of entity at point.
Write representation of entity into filename.
Write body of entity into filename.
Return buffer, which contains entity.
Return the start point of entity in the buffer which
contains entity.
Return the end point of entity in the buffer which
contains entity.
Return the start point of header of entity in the buffer
which contains entity.
Return the end point of header of entity in the buffer
which contains entity.
Return the start point of body of entity in the buffer
which contains entity.
Return the end point of body of entity in the buffer which
contains entity.
Entity is an abstraction. It is designed to use various data representations for their purposes.
Each entity has
Functions about entity are implemented by request processing to the
entity. Each entity knows its representation-type. Each entity calls
processing function corresponding with the representation-type. Such
kind of function is called
Module name of each mm-backend consists of the prefix
Send message to entity with args, and
return the result.
args is arguments of the message.
Define type as a mm-backend.
If PARENTS is specified, type inherits parents.
Each parent must be representation-type.
Example:
Define name as a method function of (nth 1 (car
args)) backend.
args is like an argument list of lambda, but (car
args) must be specialized parameter. (car (car
args)) is name of variable and (nth 1 (car
args)) is name of backend (representation-type).
Example:
Historically, Content-Type field was proposed in RFC 1049. In it,
Content-Type did not distinguish type and subtype, and there are no
mechanism to represent kind of character code like MIME charset.
FLIM provides parser for Content-Type field and structure
Format of Content-Type field is defined as follows:
For example:
`type' and `subtype' indicate format of an entity. In this document,
pair of them is called `media-type'. `image/jpeg' or `text/plain' is
a media-type.
If an entity does not have Content-Type field, it is regarded as
following:
Structure to store information of a Content-Type field.
Applications should use reference functions
Slots of the structure are following:
Constructor of content-type.
Return value of parameter of content-type.
Parse string as a field-body of Content-Type field, and
return the result as
Parse Content-Type field of the current buffer, and return the result
as
Return
Return type/subtype string from type and
subtype.
FLIM provides parser for Content-Disposition field and structure
Structure to store information of a Content-Disposition field.
Applications should use reference functions
Slots of the structure are following:
Return value of parameter of
content-disposition.
Return filename of content-disposition.
Parse string as field-body of Content-Disposition field,
and return the result as
Parse Content-Disposition field of the current buffer, and return the
result as
Return
FLIM provides parser functions for Content-Transfer-Encoding field.
They represent information of Content-Transfer-Encoding field as
string.
In addition, FLIM provides encoder/decoder functions by
Content-Transfer-Encoding.
Parse string as a field-body of Content-Transfer-Encoding
field, and return the result.
Parse Content-Transfer-Encoding field of the current buffer, and
return the result.
Return default-encoding if Content-Transfer-Encoding field
is not found. If it is not specified,
Encode region start to end of current buffer
using encoding.
Decode region start to end of current buffer
using encoding.
Decode string which is encoded in encoding, and
return the result.
Insert file FILENAME encoded by ENCODING format.
Decode and write current region encoded by encoding into
filename.
start and end are buffer positions.
Return list of Content-Transfer-Encoding.
If service is specified, it returns available list of
Content-Transfer-Encoding for it.
Return table of Content-Transfer-Encoding for completion.
If service is specified, it returns available list of
Content-Transfer-Encoding for it.
Define name as a method function of (nth 1 (car (last
args))) backend.
args is like an argument list of lambda, but (car (last
args)) must be specialized parameter. (car (car (last
args))) is name of variable and (nth 1 (car (last
args))) is name of backend (encoding).
Example:
Set spec's function definition to function.
First element of spec is service.
Rest of args is like an argument list of lambda, but (car
(last args)) must be specialized parameter. (car (car
(last args))) is name of variable and (nth 1 (car (last
args))) is name of backend (encoding).
Example:
Define name as a service for Content-Transfer-Encodings.
If args is specified, name is defined as a
generic function for the service.
Example:
The encoded-word is the only valid format to represent
non-
FLIM provides encoding/decoding features of both encoded-word and
invalid "raw" non-
Decode MIME encoded-words in header fields.
If code-conversion is
If separator is not
Encode header fields to network representation, such as MIME
encoded-word.
Each field is encoded as corresponding method specified by variable
Association list to specify field encoding method. Each element looks
like (FIELD . METHOD).
If METHOD is
If METHOD is
If METHOD is a MIME charset, the FIELD will be encoded as the charset
when it must be convert into network-code.
Otherwise the FIELD will be encoded as variable
The group associated with functions related to MIME.
It belongs to
Any data represented by 7bit integers is called
Textual string consisted of Control characters between 0 .. 31 and
127, and space represented by 32, and graphic characters between 33
.. 236 are called
Conventional Internet MTA can translate 7bit data,
so it is no need to translate by Quoted-Printable or Base64 for 7bit data.
However if there are too long lines, it can not translate by 7bit MTA
even if it is 7bit data.
Any data represented by 8bit integers is called
Textual string consisted of Control characters between 0 .. 31, 127,
and 128 .. 159, and space represented by 32, and graphic characters
between 33 .. 236 and 160 .. 255 are called
For example,
Traditional Internet MTA can translate only
However 8bit MTA are increasing today.
However if there are too long lines, it can not translate by 8bit MTA
even if it is 8bit data.
The encoding process represents 24-bit groups of input bits as output
strings of 4 encoded characters. Encoded characters represent integer
0 .. 63 or
These 65 characters are subset of all versions of ISO 646, including
US-ASCII, and all versions of EBCDIC. So it is safe even if it is
translated by non-Internet gateways.
Any byte stream is called
It does not require structureof lines. It differs from from 8bit.
In addition, if line structured data contain too long line (more than
998 bytes), it is regarded as binary.
A set of unambiguous rules that establishes a character set and the
one-to-one relationship between the characters of the set and their
bit combinations.
Currently there are following standard primary-types:
And there are various subtypes, for example, application/octet-stream,
audio/basic, image/jpeg,
You can refer registered media types at MEDIA
TYPES.
In addition, you can use private type or subtype using
In this document, it means mail defined in
MIME stands for
According to RFC 2045:
STD 11, RFC 822, defines a message representation protocol specifying
considerable detail about US-ASCII message headers, and leaves the
message content, or message body, as flat US-ASCII text. This set of
documents, collectively called the Multipurpose Internet Mail
Extensions, or MIME, redefines the format of messages to allow for
It is defined in
Coded character set used in
It is defined in
If the data being encoded are mostly US-ASCII text, the encoded form
of the data remains largely recognizable by humans.
A RFC defines format of Internet mail message, mainly
news message is based on RFC 822, so
A RFC defines format of USENET message. It is a subset of
A textual data represented by only
A MIME charset for primary Latin script
mainly written by English or other languages.
It is a 7bit
It is standard coded character set of Internet mail. If MIME charset
is not specified,
In addition,
If you write bug-reports and/or suggestions for improvement, please
send them to the EMACS-MIME Mailing List:
Notice that, we do not welcome bug reports about too old version.
Bugs in old version might be fixed. So please try latest version at
first.
You should write
Bug may not appear only your environment, but also in a lot of
environment (otherwise it might not bug). Therefor if you send mail
to author directly, we must write a lot of mails. So please send mail
to address for EMACS-MIME Mailing List instead of author.
Via the EMACS-MIME ML, you can report FLIM bugs, obtain the latest
release of FLIM, and discuss future enhancements to FLIM. To join the
EMACS-MIME ML, send an empty e-mail to:
Files in FLIM are managed under CVS. Therefore you can obtain the
newest FLIM by the following method:
If you would like to join CVS based development, please send mail to
If you cannot use ssh, you can join development via pserver.
In this case, please send UNIX /etc/passwd style crypted password.
Then cvsroot is :pserver:
FLIM の code の最古の部分は 榎並 嗣智 氏が書いた
その後、守岡 知彦 は
この頃、守岡 知彦 は
守岡 知彦 はやがて、MIME message を閲覧するためのプログラムである
また、後に、守岡 知彦 によって uuencode 用の
tm では後に、守岡 知彦 によって
後に、守岡 知彦 らによって tm の全面書き換え作業が行われ、この過程で、
tm は APEL, MEL, SEMI, EMH, RMAIL-MIME, Gnus-MIME などに分けられました。
このうちの MEL が FLIM の直接の先祖に当たります。
後に、APEL から
この直前から田中 哲 氏がより RFC に忠実な実装を書き始め、これは、現在、
FLIM の枝である ``FLIM-FLAM'' となっています。
mm
and its representation-type. The module is required automatically
when its entity is created at first.
Message-passing for entity
Definition of mm-backend
Information of Content-Type field
Format of Content-Type field
``Content-Type'' ``:''
mime-content-type structure
mime-content-type-SLOT
to refer information of the
structure.
Parser
nil
if Content-Type field is not found.
Utility functions
Information of Content-Disposition field
mime-content-disposition structure
mime-content-disposition-SLOT
to refer information of the
structure.
Parser for Content-Disposition field
nil
if Content-Disposition field is not found.
Encoding Method
Parser
nil
is used as the
default value.
Encoder/decoder
Other utilities
How to write encoder/decoder module
How to add encoding/decoding service
Network representation of header
Header encoding/decoding
nil
, only encoded-words
are decoded. If code-conversion is a default-mime-charset
. nil
, it is used as header
separator.
mime-field-encoding-method-alist
.
mime
, the FIELD will be encoded into MIME
format (encoded-word).
nil
, the FIELD will not be encoded.
default-mime-charset
when it must be convert into
network-code.
Various Customization
mail
and news
.
Appendix
Glossary
7bit
8bit
ASCII
Base64
binary
Coded character set, Character code
media-type
message
MIME
MIME charset
MTA
MUA
Quoted-Printable
RFC 822
RFC 1036
RFC 2045
RFC 2046
RFC 2048
RFC 2049
plain text
us-ascii
How to report bugs
CVS based development
History of FLIM
Concept Index
Function Index
Variable Index