[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

23.6.8 Syntactic Font Lock

Syntactic fontification uses the syntax table to find comments and string constants (@pxref{Syntax Tables}). It highlights them using font-lock-comment-face and font-lock-string-face (voir la section 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 (voir la section Font Lock Basics).

Variable: font-lock-keywords-only

Non-nil means Font Lock should not do syntactic fontification; it should only fontify based on font-lock-keywords. The normal way for a mode to set this variable to t is with keywords-only in font-lock-defaults.

Variable: font-lock-syntax-table

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 is nil, fontification uses the buffer's syntax table.

Variable: font-lock-beginning-of-syntax-function

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), or beginning-of-defun for programming modes, or backward-paragraph for textual modes.

If the value is nil, Font Lock uses syntax-begin-function to move back outside of any comment, string, or sexp. This variable is semi-obsolete; we recommend setting syntax-begin-function instead.

Specify this variable using syntax-begin in font-lock-defaults.

Variable: font-lock-syntactic-face-function

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 returns font-lock-comment-face for comments and font-lock-string-face for strings.

This can be used to highlighting different kinds of strings or comments differently. It is also sometimes abused together with font-lock-syntactic-keywords to highlight constructs that span multiple lines, but this is too esoteric to document here.

Specify this variable using other-vars in font-lock-defaults.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 13 Octobre 2007 en utilisant texi2html 1.78.