comparison lisp/font-lock.el @ 65960:59561c56ebba

(font-lock-syntactic-keywords, font-lock-keywords): Doc fixes.
author Richard M. Stallman <rms@gnu.org>
date Mon, 10 Oct 2005 03:25:23 +0000
parents b9c26f9516da
children edfe61dd2874 08b4dd6a6e87 5e2d3828e89f
comparison
equal deleted inserted replaced
65959:6a7380207a28 65960:59561c56ebba
352 `font-lock-add-keywords' or `font-lock-remove-keywords' with MODE = nil. 352 `font-lock-add-keywords' or `font-lock-remove-keywords' with MODE = nil.
353 353
354 Each element in a user-level keywords list should have one of these forms: 354 Each element in a user-level keywords list should have one of these forms:
355 355
356 MATCHER 356 MATCHER
357 (MATCHER . MATCH) 357 (MATCHER . SUBEXP)
358 (MATCHER . FACENAME) 358 (MATCHER . FACENAME)
359 (MATCHER . HIGHLIGHT) 359 (MATCHER . HIGHLIGHT)
360 (MATCHER HIGHLIGHT ...) 360 (MATCHER HIGHLIGHT ...)
361 (eval . FORM) 361 (eval . FORM)
362 362
378 instance of another item (the anchor), for example each instance of the 378 instance of another item (the anchor), for example each instance of the
379 word \"bar\" following the word \"anchor\" then MATCH-ANCHORED may be required. 379 word \"bar\" following the word \"anchor\" then MATCH-ANCHORED may be required.
380 380
381 MATCH-HIGHLIGHT should be of the form: 381 MATCH-HIGHLIGHT should be of the form:
382 382
383 (MATCH FACENAME [OVERRIDE [LAXMATCH]]) 383 (SUBEXP FACENAME [OVERRIDE [LAXMATCH]])
384 384
385 MATCH is the subexpression of MATCHER to be highlighted. FACENAME is an 385 SUBEXP is the number of the subexpression of MATCHER to be highlighted.
386 expression whose value is the face name to use. Face default attributes 386
387 can be modified via \\[customize]. Instead of a face, FACENAME can 387 FACENAME is an expression whose value is the face name to use.
388 evaluate to a property list of the form (face FACE PROP1 VAL1 PROP2 VAL2 ...) 388 Instead of a face, FACENAME can evaluate to a property list
389 of the form (face FACE PROP1 VAL1 PROP2 VAL2 ...)
389 in which case all the listed text-properties will be set rather than 390 in which case all the listed text-properties will be set rather than
390 just FACE. In such a case, you will most likely want to put those 391 just FACE. In such a case, you will most likely want to put those
391 properties in `font-lock-extra-managed-props' or to override 392 properties in `font-lock-extra-managed-props' or to override
392 `font-lock-unfontify-region-function'. 393 `font-lock-unfontify-region-function'.
393 394
394 OVERRIDE and LAXMATCH are flags. If OVERRIDE is t, existing fontification can 395 OVERRIDE and LAXMATCH are flags. If OVERRIDE is t, existing fontification can
395 be overwritten. If `keep', only parts not already fontified are highlighted. 396 be overwritten. If `keep', only parts not already fontified are highlighted.
396 If `prepend' or `append', existing fontification is merged with the new, in 397 If `prepend' or `append', existing fontification is merged with the new, in
397 which the new or existing fontification, respectively, takes precedence. 398 which the new or existing fontification, respectively, takes precedence.
398 If LAXMATCH is non-nil, no error is signaled if there is no MATCH in MATCHER. 399 If LAXMATCH is non-nil, that means don't signal an error if there is
400 no match for SUBEXP in MATCHER.
399 401
400 For example, an element of the form highlights (if not already highlighted): 402 For example, an element of the form highlights (if not already highlighted):
401 403
402 \"\\\\\\=<foo\\\\\\=>\" discrete occurrences of \"foo\" in the value of the 404 \"\\\\\\=<foo\\\\\\=>\" discrete occurrences of \"foo\" in the value of the
403 variable `font-lock-keyword-face'. 405 variable `font-lock-keyword-face'.
506 The function is called with a single parameter (the state as returned by 508 The function is called with a single parameter (the state as returned by
507 `parse-partial-sexp' at the beginning of the region to highlight) and 509 `parse-partial-sexp' at the beginning of the region to highlight) and
508 should return a face. This is normally set via `font-lock-defaults'.") 510 should return a face. This is normally set via `font-lock-defaults'.")
509 511
510 (defvar font-lock-syntactic-keywords nil 512 (defvar font-lock-syntactic-keywords nil
511 "A list of the syntactic keywords to highlight. 513 "A list of the syntactic keywords to put syntax properties on.
512 Can be the list or the name of a function or variable whose value is the list. 514 The value can be the list itself, or the name of a function or variable
515 whose value is the list.
516
513 See `font-lock-keywords' for a description of the form of this list; 517 See `font-lock-keywords' for a description of the form of this list;
514 the differences are listed below. MATCH-HIGHLIGHT should be of the form: 518 only the differences are stated here. MATCH-HIGHLIGHT should be of the form:
515 519
516 (MATCH SYNTAX OVERRIDE LAXMATCH) 520 (SUBEXP SYNTAX OVERRIDE LAXMATCH)
517 521
518 where SYNTAX can be a string (as taken by `modify-syntax-entry'), a syntax 522 where SYNTAX can be a string (as taken by `modify-syntax-entry'), a syntax
519 table, a cons cell (as returned by `string-to-syntax') or an expression whose 523 table, a cons cell (as returned by `string-to-syntax') or an expression whose
520 value is such a form. OVERRIDE cannot be `prepend' or `append'. 524 value is such a form. OVERRIDE cannot be `prepend' or `append'.
521 525
522 For example, an element of the form highlights syntactically: 526 Here are two examples of elements of `font-lock-syntactic-keywords'
527 and what they do:
523 528
524 (\"\\\\$\\\\(#\\\\)\" 1 \".\") 529 (\"\\\\$\\\\(#\\\\)\" 1 \".\")
525 530
526 a hash character when following a dollar character, with a SYNTAX of 531 gives a hash character punctuation syntax (\".\") when following a
527 \".\" (meaning punctuation syntax). Assuming that the buffer syntax table does 532 dollar-sign character. Hash characters in other contexts will still
528 specify hash characters to have comment start syntax, the element will only 533 follow whatever the syntax table says about the hash character.
529 highlight hash characters that do not follow dollar characters as comments
530 syntactically.
531 534
532 (\"\\\\('\\\\).\\\\('\\\\)\" 535 (\"\\\\('\\\\).\\\\('\\\\)\"
533 (1 \"\\\"\") 536 (1 \"\\\"\")
534 (2 \"\\\"\")) 537 (2 \"\\\"\"))
535 538
536 both single quotes which surround a single character, with a SYNTAX of 539 gives a pair single-quotes, which surround a single character, a SYNTAX of
537 \"\\\"\" (meaning string quote syntax). Assuming that the buffer syntax table 540 \"\\\"\" (meaning string quote syntax). Single-quote characters in other
538 does not specify single quotes to have quote syntax, the element will only 541 contexts will not be affected.
539 highlight single quotes of the form 'c' as strings syntactically.
540 Other forms, such as foo'bar or 'fubar', will not be highlighted as strings.
541 542
542 This is normally set via `font-lock-defaults'.") 543 This is normally set via `font-lock-defaults'.")
543 544
544 (defvar font-lock-syntax-table nil 545 (defvar font-lock-syntax-table nil
545 "Non-nil means use this syntax table for fontifying. 546 "Non-nil means use this syntax table for fontifying.