File: format.el.html
This file defines a unified mechanism for saving & loading files stored
in different formats. format-alist contains information that directs
Emacs to call an encoding or decoding function when reading or writing
files that match certain conditions.
When a file is visited, its format is determined by matching the
beginning of the file against regular expressions stored in
format-alist. If this fails, you can manually translate the buffer
using format-decode-buffer. In either case, the formats used are
listed in the variable buffer-file-format, and become the default
format for saving the buffer. To save a buffer in a different format,
change this variable, or use format-write-file.
Auto-save files are normally created in the same format as the visited
file, but the variable buffer-auto-save-file-format can be set to a
particularly fast or otherwise preferred format to be used for
auto-saving (or nil to do no encoding on auto-save files, but then you
risk losing any text-properties in the buffer).
You can manually translate a buffer into or out of a particular format
with the functions format-encode-buffer and format-decode-buffer.
To translate just the region use the functions format-encode-region
and format-decode-region.
You can define a new format by writing the encoding and decoding
functions, and adding an entry to format-alist. See enriched.el for
an example of how to implement a file format. There are various
functions defined in this file that may be useful for writing the
encoding and decoding functions:
* format-annotate-region and format-deannotate-region allow a
single alist of information to be used for encoding and decoding.
The alist defines a correspondence between strings in the file
("annotations") and text-properties in the buffer.
* format-replace-strings is similarly useful for doing simple
string->string translations in a reversible manner.
Defined variables (1)
format-alist | List of information about understood file formats. |
Defined functions (26)
format-annotate-atomic-property-change | (PROP-ALIST OLD NEW) |
format-annotate-function | (FORMAT FROM TO ORIG-BUF FORMAT-COUNT) |
format-annotate-location | (LOC ALL IGNORE TRANSLATIONS) |
format-annotate-region | (FROM TO TRANSLATIONS FORMAT-FN IGNORE) |
format-annotate-single-property-change | (PROP OLD NEW TRANSLATIONS) |
format-annotate-value | (OLD NEW) |
format-deannotate-region | (FROM TO TRANSLATIONS NEXT-FN) |
format-decode | (FORMAT LENGTH &optional VISIT-FLAG) |
format-decode-buffer | (&optional FORMAT) |
format-decode-region | (FROM TO &optional FORMAT) |
format-decode-run-method | (METHOD FROM TO &optional BUFFER) |
format-delq-cons | (CONS LIST) |
format-encode-buffer | (&optional FORMAT) |
format-encode-region | (BEG END &optional FORMAT) |
format-encode-run-method | (METHOD FROM TO &optional BUFFER) |
format-find-file | (FILENAME FORMAT) |
format-insert-annotations | (LIST &optional OFFSET) |
format-insert-file | (FILENAME FORMAT &optional BEG END) |
format-make-relatively-unique | (A B) |
format-proper-list-p | (OBJECT) |
format-property-increment-region | (FROM TO PROP DELTA DEFAULT) |
format-read | (&optional PROMPT) |
format-reorder | (ITEMS ORDER) |
format-replace-strings | (ALIST &optional REVERSE BEG END) |
format-subtract-regions | (MINUEND SUBTRAHEND) |
format-write-file | (FILENAME FORMAT &optional CONFIRM) |