File formats are a general mechanism for turning file contents into another form for editing or viewing in a buffer. The file is “decoded” on read, and “encoded” on write. See file format conversion.
The builtin formats include,
Here’s some things adding new file formats,
Here’s some things using file formats to help the way they view or save, without quite being actual full formats,
pcf font file as bdf sourcetcd tide constituent database filesEnrichedMode is a good example. It turns markup like <bold> into actual bold TextProperties in the buffer so you edit WYSIWYG style, yet still write RFC 1896 markup to the file.
Or “TeX” format converts TeX accented character sequences like {\“a} in the file into actual characters like รค for editing. This is very good if you’ve got a lot of accents in a TeX document. html format does the same sort of thing with HTML/SGML character entities like ä.
A format can be automatically recognised from a pattern at the start of the file. EnrichedMode for instance looks for “Content-Type: text/enriched”. Other formats must be explicitly converted with M-x format-decode-buffer (after which the save automatically re-encodes).
Have a look at the format-alist variable for all the formats (per format-alist). The ones like the TeX helper that are not automatically enabled are likely to be well-kept secrets until you nose around.
WYSIWYG word processing (or just viewing) is the most obvious application, but all sorts of munching of text or binaries into presentable form ought to be possible. If you’re thinking of hooking after-insert-file-functions or write-contents-functions to crunch buffer contents, consider whether the format mechanism can do it more easily (and cooperate better with remote-file accessors and whatnot).