Font Lock mode can highlight using any face, but Emacs defines several faces specifically for Font Lock to use to highlight text. These Font Lock faces are listed below. They can also be used by major modes for syntactic highlighting outside of Font Lock mode (see Major Mode Conventions).
Each of these symbols is both a face name, and a variable whose
default value is the symbol itself. Thus, the default value of
font-lock-comment-face
is font-lock-comment-face
.
The faces are listed with descriptions of their typical usage, and in order of greater to lesser prominence. If a mode’s syntactic categories do not fit well with the usage descriptions, the faces can be assigned using the ordering as a guide.
font-lock-warning-face
¶for a construct that is peculiar (e.g., an unescaped confusable quote in an Emacs Lisp symbol like ‘‘foo’), or that greatly changes the meaning of other text, like ‘;;;###autoload’ in Emacs Lisp and ‘#error’ in C.
font-lock-function-name-face
¶for the name of a function being defined or declared.
font-lock-function-call-face
¶for the name of a function being called. This face inherits, by
default, from font-lock-function-name-face
.
font-lock-variable-name-face
¶for the name of a variable being defined or declared.
font-lock-variable-use-face
¶for the name of a variable being referenced. This face inherits, by
default, from font-lock-variable-name-face
.
font-lock-keyword-face
¶for a keyword with special syntactic significance, like ‘for’ and ‘if’ in C.
font-lock-comment-face
¶for comments.
font-lock-comment-delimiter-face
¶for comments delimiters, like ‘/*’ and ‘*/’ in C. On most
terminals, this inherits from font-lock-comment-face
.
font-lock-type-face
¶for the names of user-defined data types.
font-lock-constant-face
¶for the names of constants, like ‘NULL’ in C.
font-lock-builtin-face
¶for the names of built-in functions.
font-lock-preprocessor-face
¶for preprocessor commands. This inherits, by default, from
font-lock-builtin-face
.
font-lock-string-face
¶for string constants.
font-lock-doc-face
¶for documentation embedded in program code inside specially-formed
comments or strings. This face inherits, by default, from
font-lock-string-face
.
font-lock-doc-markup-face
¶for mark-up elements in text using font-lock-doc-face
.
It is typically used for the mark-up constructs in documentation embedded
in program code, following conventions such as Haddock, Javadoc or Doxygen.
This face inherits, by default, from font-lock-constant-face
.
font-lock-negation-char-face
¶for easily-overlooked negation characters.
font-lock-escape-face
¶for escape sequences in strings.
This face inherits, by default, from font-lock-regexp-grouping-backslash
.
Here is an example in Python, where the escape sequence \n
is used:
print('Hello world!\n')
font-lock-number-face
¶for numbers.
font-lock-operator-face
¶for operators.
font-lock-property-name-face
¶for properties of an object, such as the declaration of fields in a
struct. This face inherits, by default, from
font-lock-variable-name-face
.
font-lock-property-use-face
¶for properties of an object, such as use of fields in a struct. This
face inherits, by default, from font-lock-property-name-face
.
For example,
typedef struct { int prop; // ^ property } obj; int main() { obj o; o.prop = 3; // ^ property }
font-lock-punctuation-face
¶for punctuation such as brackets and delimiters.
font-lock-bracket-face
¶for brackets (e.g., ()
, []
, {}
).
This face inherits, by default, from font-lock-punctuation-face
.
font-lock-delimiter-face
¶for delimiters (e.g., ;
, :
, ,
).
This face inherits, by default, from font-lock-punctuation-face
.
font-lock-misc-punctuation-face
¶for punctuation that is not a bracket or delimiter.
This face inherits, by default, from font-lock-punctuation-face
.