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

23.6.9 Setting Syntax Properties

Font Lock mode can be used to update syntax-table properties automatically (voir la section Syntax Properties). This is useful in languages for which a single syntax table by itself is not sufficient.

Variable: font-lock-syntactic-keywords

This variable enables and controls updating syntax-table properties by Font Lock. Its value should be a list of elements of this form:

 
(matcher subexp syntax override laxmatch)

The parts of this element have the same meanings as in the corresponding sort of element of font-lock-keywords,

 
(matcher subexp facespec override laxmatch)

However, instead of specifying the value facespec to use for the face property, it specifies the value syntax to use for the syntax-table property. Here, syntax can be a string (as taken by modify-syntax-entry), a syntax table, a cons cell (as returned by string-to-syntax), or an expression whose value is one of those two types. override cannot be prepend or append.

For example, an element of the form:

 
("\\$\\(#\\)" 1 ".")

highlights syntactically a hash character when following a dollar character, with a SYNTAX of "." (meaning punctuation syntax). Assuming that the buffer syntax table specifies hash characters to have comment start syntax, the element will only highlight hash characters that do not follow dollar characters as comments syntactically.

An element of the form:

 
 ("\\('\\).\\('\\)"
  (1 "\"")
  (2 "\""))

highlights syntactically both single quotes which surround a single character, with a SYNTAX of "\"" (meaning string quote syntax). Assuming that the buffer syntax table does not specify single quotes to have quote syntax, the element will only highlight single quotes of the form ‘'c'’ as strings syntactically. Other forms, such as ‘foo'bar’ or ‘'fubar'’, will not be highlighted as strings.

Major modes normally set this variable with 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.