Next: Setting Syntax Properties, Previous: Faces for Font Lock, Up: Font Lock Mode
Syntactic fontification uses the syntax table to find comments and
string constants (see Syntax Tables). It highlights them using
font-lock-comment-face and font-lock-string-face
(see Faces for Font Lock), or whatever
font-lock-syntactic-face-function chooses. There are several
variables that affect syntactic fontification; you should set them by
means of font-lock-defaults (see Font Lock Basics).
Non-
nilmeans Font Lock should not do syntactic fontification; it should only fontify based onfont-lock-keywords. The normal way for a mode to set this variable totis with keywords-only infont-lock-defaults.
This variable holds the syntax table to use for fontification of comments and strings. Specify it using syntax-alist in
font-lock-defaults. If this isnil, fontification uses the buffer's syntax table.
If this variable is non-
nil, it should be a function to move point back to a position that is syntactically at “top level” and outside of strings or comments. Font Lock uses this when necessary to get the right results for syntactic fontification.This function is called with no arguments. It should leave point at the beginning of any enclosing syntactic block. Typical values are
beginning-of-line(used when the start of the line is known to be outside a syntactic block), orbeginning-of-defunfor programming modes, orbackward-paragraphfor textual modes.If the value is
nil, Font Lock usessyntax-begin-functionto move back outside of any comment, string, or sexp. This variable is semi-obsolete; we recommend settingsyntax-begin-functioninstead.Specify this variable using syntax-begin in
font-lock-defaults.
A function to determine which face to use for a given syntactic element (a string or a comment). The function is called with one argument, the parse state at point returned by
parse-partial-sexp, and should return a face. The default value returnsfont-lock-comment-facefor comments andfont-lock-string-facefor strings.This can be used to highlighting different kinds of strings or comments differently. It is also sometimes abused together with
font-lock-syntactic-keywordsto highlight constructs that span multiple lines, but this is too esoteric to document here.Specify this variable using other-vars in
font-lock-defaults.
