Font Lock mode is a buffer-local minor mode that automatically
attaches face
properties to certain parts of the buffer based on
their syntactic role. How it parses the buffer depends on the major
mode; most major modes define syntactic criteria for which faces to use
in which contexts. This section explains how to customize Font Lock for
a particular major mode.
Font Lock mode finds text to highlight in three ways: through parsing based on a full-blown parser (usually, via an external library or program), through syntactic parsing based on the Emacs’s built-in syntax table, or through searching (usually for regular expressions). If enabled, parser-based fontification happens first (see Parser-based Font Lock). Syntactic fontification happens next; it finds comments and string constants and highlights them. Search-based fontification happens last.