diff options
| author | Simon Marshall | 1998-02-18 09:12:24 +0000 |
|---|---|---|
| committer | Simon Marshall | 1998-02-18 09:12:24 +0000 |
| commit | 9c8de95c2a0d0069f9a846c850cb9292370eeab8 (patch) | |
| tree | 010ed233d85d3d9e3fd0cf01e612363eaada07dd | |
| parent | aa7a8f0ee89966ccdb3bb72b1002b28c5d73781d (diff) | |
| download | emacs-9c8de95c2a0d0069f9a846c850cb9292370eeab8.tar.gz emacs-9c8de95c2a0d0069f9a846c850cb9292370eeab8.zip | |
Keyword doc fixes and keyword tweaks.
| -rw-r--r-- | lisp/font-lock.el | 74 |
1 files changed, 48 insertions, 26 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 0981df812c0..ea593fb2bf3 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; font-lock.el --- Electric font lock mode | 1 | ;;; font-lock.el --- Electric font lock mode |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: jwz, then rms, then sm <simon@gnu.org> | 5 | ;; Author: jwz, then rms, then sm <simon@gnu.org> |
| 6 | ;; Maintainer: FSF | 6 | ;; Maintainer: FSF |
| @@ -310,9 +310,11 @@ FORM is an expression, whose value should be a keyword element, evaluated when | |||
| 310 | the keyword is (first) used in a buffer. This feature can be used to provide a | 310 | the keyword is (first) used in a buffer. This feature can be used to provide a |
| 311 | keyword that can only be generated when Font Lock mode is actually turned on. | 311 | keyword that can only be generated when Font Lock mode is actually turned on. |
| 312 | 312 | ||
| 313 | For highlighting single items, typically only MATCH-HIGHLIGHT is required. | 313 | For highlighting single items, for example each instance of the word \"foo\", |
| 314 | typically only MATCH-HIGHLIGHT is required. | ||
| 314 | However, if an item or (typically) items are to be highlighted following the | 315 | However, if an item or (typically) items are to be highlighted following the |
| 315 | instance of another item (the anchor) then MATCH-ANCHORED may be required. | 316 | instance of another item (the anchor), for example each instance of the |
| 317 | word \"bar\" following the word \"anchor\" then MATCH-ANCHORED may be required. | ||
| 316 | 318 | ||
| 317 | MATCH-HIGHLIGHT should be of the form: | 319 | MATCH-HIGHLIGHT should be of the form: |
| 318 | 320 | ||
| @@ -334,16 +336,16 @@ If LAXMATCH is non-nil, no error is signaled if there is no MATCH in MATCHER. | |||
| 334 | 336 | ||
| 335 | For example, an element of the form highlights (if not already highlighted): | 337 | For example, an element of the form highlights (if not already highlighted): |
| 336 | 338 | ||
| 337 | \"\\\\\\=<foo\\\\\\=>\" Discrete occurrences of \"foo\" in the value of the | 339 | \"\\\\\\=<foo\\\\\\=>\" discrete occurrences of \"foo\" in the value of the |
| 338 | variable `font-lock-keyword-face'. | 340 | variable `font-lock-keyword-face'. |
| 339 | (\"fu\\\\(bar\\\\)\" . 1) Substring \"bar\" within all occurrences of \"fubar\" in | 341 | (\"fu\\\\(bar\\\\)\" . 1) substring \"bar\" within all occurrences of \"fubar\" in |
| 340 | the value of `font-lock-keyword-face'. | 342 | the value of `font-lock-keyword-face'. |
| 341 | (\"fubar\" . fubar-face) Occurrences of \"fubar\" in the value of `fubar-face'. | 343 | (\"fubar\" . fubar-face) Occurrences of \"fubar\" in the value of `fubar-face'. |
| 342 | (\"foo\\\\|bar\" 0 foo-bar-face t) | 344 | (\"foo\\\\|bar\" 0 foo-bar-face t) |
| 343 | Occurrences of either \"foo\" or \"bar\" in the value | 345 | occurrences of either \"foo\" or \"bar\" in the value |
| 344 | of `foo-bar-face', even if already highlighted. | 346 | of `foo-bar-face', even if already highlighted. |
| 345 | (fubar-match 1 fubar-face) | 347 | (fubar-match 1 fubar-face) |
| 346 | The first subexpression within all occurrences of | 348 | the first subexpression within all occurrences of |
| 347 | whatever the function `fubar-match' finds and matches | 349 | whatever the function `fubar-match' finds and matches |
| 348 | in the value of `fubar-face'. | 350 | in the value of `fubar-face'. |
| 349 | 351 | ||
| @@ -351,7 +353,8 @@ MATCH-ANCHORED should be of the form: | |||
| 351 | 353 | ||
| 352 | (MATCHER PRE-MATCH-FORM POST-MATCH-FORM MATCH-HIGHLIGHT ...) | 354 | (MATCHER PRE-MATCH-FORM POST-MATCH-FORM MATCH-HIGHLIGHT ...) |
| 353 | 355 | ||
| 354 | where MATCHER is as for MATCH-HIGHLIGHT with one exception; see below. | 356 | where MATCHER is a regexp to search for or the function name to call to make |
| 357 | the search, as for MATCH-HIGHLIGHT above, but with one exception; see below. | ||
| 355 | PRE-MATCH-FORM and POST-MATCH-FORM are evaluated before the first, and after | 358 | PRE-MATCH-FORM and POST-MATCH-FORM are evaluated before the first, and after |
| 356 | the last, instance MATCH-ANCHORED's MATCHER is used. Therefore they can be | 359 | the last, instance MATCH-ANCHORED's MATCHER is used. Therefore they can be |
| 357 | used to initialise before, and cleanup after, MATCHER is used. Typically, | 360 | used to initialise before, and cleanup after, MATCHER is used. Typically, |
| @@ -363,7 +366,7 @@ For example, an element of the form highlights (if not already highlighted): | |||
| 363 | 366 | ||
| 364 | (\"\\\\\\=<anchor\\\\\\=>\" (0 anchor-face) (\"\\\\\\=<item\\\\\\=>\" nil nil (0 item-face))) | 367 | (\"\\\\\\=<anchor\\\\\\=>\" (0 anchor-face) (\"\\\\\\=<item\\\\\\=>\" nil nil (0 item-face))) |
| 365 | 368 | ||
| 366 | Discrete occurrences of \"anchor\" in the value of `anchor-face', and subsequent | 369 | discrete occurrences of \"anchor\" in the value of `anchor-face', and subsequent |
| 367 | discrete occurrences of \"item\" (on the same line) in the value of `item-face'. | 370 | discrete occurrences of \"item\" (on the same line) in the value of `item-face'. |
| 368 | (Here PRE-MATCH-FORM and POST-MATCH-FORM are nil. Therefore \"item\" is | 371 | (Here PRE-MATCH-FORM and POST-MATCH-FORM are nil. Therefore \"item\" is |
| 369 | initially searched for starting from the end of the match of \"anchor\", and | 372 | initially searched for starting from the end of the match of \"anchor\", and |
| @@ -377,9 +380,6 @@ PRE-MATCH-FORM is evaluated, that position is used as the limit of the search. | |||
| 377 | It is generally a bad idea to return a position greater than the end of the | 380 | It is generally a bad idea to return a position greater than the end of the |
| 378 | line, i.e., cause the MATCHER search to span lines. | 381 | line, i.e., cause the MATCHER search to span lines. |
| 379 | 382 | ||
| 380 | Note that the MATCH-ANCHORED feature is experimental; in the future, we may | ||
| 381 | replace it with other ways of providing this functionality. | ||
| 382 | |||
| 383 | These regular expressions should not match text which spans lines. While | 383 | These regular expressions should not match text which spans lines. While |
| 384 | \\[font-lock-fontify-buffer] handles multi-line patterns correctly, updating | 384 | \\[font-lock-fontify-buffer] handles multi-line patterns correctly, updating |
| 385 | when you edit the buffer does not, since it considers text one line at a time. | 385 | when you edit the buffer does not, since it considers text one line at a time. |
| @@ -540,6 +540,27 @@ where SYNTAX can be of the form (SYNTAX-CODE . MATCHING-CHAR), the name of a | |||
| 540 | syntax table, or an expression whose value is such a form or a syntax table. | 540 | syntax table, or an expression whose value is such a form or a syntax table. |
| 541 | OVERRIDE cannot be `prepend' or `append'. | 541 | OVERRIDE cannot be `prepend' or `append'. |
| 542 | 542 | ||
| 543 | For example, an element of the form highlights syntactically: | ||
| 544 | |||
| 545 | (\"\\\\$\\\\(#\\\\)\" 1 (1 . nil)) | ||
| 546 | |||
| 547 | a hash character when following a dollar character, with a SYNTAX-CODE of | ||
| 548 | 1 (meaning punctuation syntax). Assuming that the buffer syntax table does | ||
| 549 | specify hash characters to have comment start syntax, the element will only | ||
| 550 | highlight hash characters that do not follow dollar characters as comments | ||
| 551 | syntactically. | ||
| 552 | |||
| 553 | (\"\\\\('\\\\).\\\\('\\\\)\" | ||
| 554 | (1 (7 . ?')) | ||
| 555 | (2 (7 . ?'))) | ||
| 556 | |||
| 557 | both single quotes which surround a single character, with a SYNTAX-CODE of | ||
| 558 | 7 (meaning string quote syntax) and a MATCHING-CHAR of a single quote (meaning | ||
| 559 | a single quote matches a single quote). Assuming that the buffer syntax table | ||
| 560 | does not specify single quotes to have quote syntax, the element will only | ||
| 561 | highlight single quotes of the form 'c' as strings syntactically. | ||
| 562 | Other forms, such as foo'bar or 'fubar', will not be highlighted as strings. | ||
| 563 | |||
| 543 | This is normally set via `font-lock-defaults'.") | 564 | This is normally set via `font-lock-defaults'.") |
| 544 | 565 | ||
| 545 | (defvar font-lock-syntax-table nil | 566 | (defvar font-lock-syntax-table nil |
| @@ -1750,7 +1771,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using | |||
| 1750 | ;; the entry for "Text Properties" something like: | 1771 | ;; the entry for "Text Properties" something like: |
| 1751 | ;; | 1772 | ;; |
| 1752 | ;; (define-key menu-bar-edit-menu [font-lock] | 1773 | ;; (define-key menu-bar-edit-menu [font-lock] |
| 1753 | ;; '("Syntax Highlighting" . font-lock-menu)) | 1774 | ;; (cons "Syntax Highlighting" font-lock-menu)) |
| 1754 | ;; | 1775 | ;; |
| 1755 | ;; and remove a single ";" from the beginning of each line in the rest of this | 1776 | ;; and remove a single ";" from the beginning of each line in the rest of this |
| 1756 | ;; section. Probably the mechanism for telling the menu code what are menu | 1777 | ;; section. Probably the mechanism for telling the menu code what are menu |
| @@ -1783,7 +1804,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using | |||
| 1783 | ; (put 'font-lock-fontify-less 'menu-enable '(identity))) | 1804 | ; (put 'font-lock-fontify-less 'menu-enable '(identity))) |
| 1784 | ; | 1805 | ; |
| 1785 | ;;; Put the appropriate symbol property values on now. See above. | 1806 | ;;; Put the appropriate symbol property values on now. See above. |
| 1786 | ;(put 'global-font-lock-mode 'menu-selected 'global-font-lock-mode)) | 1807 | ;(put 'global-font-lock-mode 'menu-selected 'global-font-lock-mode) |
| 1787 | ;(put 'font-lock-mode 'menu-selected 'font-lock-mode) | 1808 | ;(put 'font-lock-mode 'menu-selected 'font-lock-mode) |
| 1788 | ;(put 'font-lock-fontify-more 'menu-enable '(nth 2 font-lock-fontify-level)) | 1809 | ;(put 'font-lock-fontify-more 'menu-enable '(nth 2 font-lock-fontify-level)) |
| 1789 | ;(put 'font-lock-fontify-less 'menu-enable '(nth 1 font-lock-fontify-level)) | 1810 | ;(put 'font-lock-fontify-less 'menu-enable '(nth 1 font-lock-fontify-level)) |
| @@ -1892,9 +1913,10 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item." | |||
| 1892 | ;; Definitions. | 1913 | ;; Definitions. |
| 1893 | (list (concat "(\\(def\\(" | 1914 | (list (concat "(\\(def\\(" |
| 1894 | ;; Function declarations. | 1915 | ;; Function declarations. |
| 1895 | "\\(advice\\|alias\\|method\\|" | 1916 | "\\(advice\\|alias\\|generic\\|macro\\*?\\|method\\|" |
| 1896 | "ine-\\(derived-mode\\|function\\|skeleton\\|widget\\)\\|" | 1917 | "setf\\|subst\\*?\\|un\\*?\\|" |
| 1897 | "macro\\|subst\\|un\\)\\|" | 1918 | "ine-\\(derived-mode\\|function\\|" |
| 1919 | "skeleton\\|widget\\)\\)\\|" | ||
| 1898 | ;; Variable declarations. | 1920 | ;; Variable declarations. |
| 1899 | "\\(const\\|custom\\|face\\|var\\)\\|" | 1921 | "\\(const\\|custom\\|face\\|var\\)\\|" |
| 1900 | ;; Structure declarations. | 1922 | ;; Structure declarations. |
| @@ -1929,7 +1951,7 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item." | |||
| 1929 | "inline" "save-restriction" "save-excursion" | 1951 | "inline" "save-restriction" "save-excursion" |
| 1930 | "save-window-excursion" "save-selected-window" | 1952 | "save-window-excursion" "save-selected-window" |
| 1931 | "save-match-data" "save-current-buffer" "unwind-protect" | 1953 | "save-match-data" "save-current-buffer" "unwind-protect" |
| 1932 | "condition-case" "track-mouse" "dont-compile" | 1954 | "condition-case" "track-mouse" |
| 1933 | "eval-after-load" "eval-and-compile" "eval-when-compile" | 1955 | "eval-after-load" "eval-and-compile" "eval-when-compile" |
| 1934 | "eval-when" | 1956 | "eval-when" |
| 1935 | "with-current-buffer" "with-electric-help" | 1957 | "with-current-buffer" "with-electric-help" |
| @@ -1960,7 +1982,7 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item." | |||
| 1960 | ;; Words inside `' tend to be symbol names. | 1982 | ;; Words inside `' tend to be symbol names. |
| 1961 | '("`\\(\\sw\\sw+\\)'" 1 font-lock-reference-face prepend) | 1983 | '("`\\(\\sw\\sw+\\)'" 1 font-lock-reference-face prepend) |
| 1962 | ;; | 1984 | ;; |
| 1963 | ;; CLisp `:' keywords as builtins. | 1985 | ;; Constant values. |
| 1964 | '("\\<:\\sw\\sw+\\>" 0 font-lock-builtin-face) | 1986 | '("\\<:\\sw\\sw+\\>" 0 font-lock-builtin-face) |
| 1965 | ;; | 1987 | ;; |
| 1966 | ;; ELisp and CLisp `&' keywords as types. | 1988 | ;; ELisp and CLisp `&' keywords as types. |
| @@ -1981,7 +2003,7 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item." | |||
| 1981 | ;; this works for SOS, STklos, SCOOPS, Meroon and Tiny CLOS. | 2003 | ;; this works for SOS, STklos, SCOOPS, Meroon and Tiny CLOS. |
| 1982 | (list (concat "(\\(define\\(" | 2004 | (list (concat "(\\(define\\(" |
| 1983 | ;; Function names. | 2005 | ;; Function names. |
| 1984 | "\\(\\|-\\(generic\\(\\|-procedure\\)\\|method\\)\\)\\|" | 2006 | "\\(\\|-method\\|-generic\\(-procedure\\)?\\)\\|" |
| 1985 | ;; Macro names, as variable names. A bit dubious, this. | 2007 | ;; Macro names, as variable names. A bit dubious, this. |
| 1986 | "\\(-syntax\\)\\|" | 2008 | "\\(-syntax\\)\\|" |
| 1987 | ;; Class names. | 2009 | ;; Class names. |
| @@ -1991,8 +2013,8 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item." | |||
| 1991 | "[ \t]*(?" | 2013 | "[ \t]*(?" |
| 1992 | "\\(\\sw+\\)?") | 2014 | "\\(\\sw+\\)?") |
| 1993 | '(1 font-lock-keyword-face) | 2015 | '(1 font-lock-keyword-face) |
| 1994 | '(7 (cond ((match-beginning 3) font-lock-function-name-face) | 2016 | '(6 (cond ((match-beginning 3) font-lock-function-name-face) |
| 1995 | ((match-beginning 6) font-lock-variable-name-face) | 2017 | ((match-beginning 5) font-lock-variable-name-face) |
| 1996 | (t font-lock-type-face)) | 2018 | (t font-lock-type-face)) |
| 1997 | nil t)) | 2019 | nil t)) |
| 1998 | )) | 2020 | )) |
| @@ -2021,8 +2043,8 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item." | |||
| 2021 | ;; David Fox <fox@graphics.cs.nyu.edu> for SOS/STklos class specifiers. | 2043 | ;; David Fox <fox@graphics.cs.nyu.edu> for SOS/STklos class specifiers. |
| 2022 | '("\\<<\\sw+>\\>" . font-lock-type-face) | 2044 | '("\\<<\\sw+>\\>" . font-lock-type-face) |
| 2023 | ;; | 2045 | ;; |
| 2024 | ;; Scheme `:' keywords as references. | 2046 | ;; Scheme `:' keywords as builtins. |
| 2025 | '("\\<:\\sw+\\>" . font-lock-reference-face) | 2047 | '("\\<:\\sw+\\>" . font-lock-builtin-face) |
| 2026 | ))) | 2048 | ))) |
| 2027 | "Gaudy expressions to highlight in Scheme modes.") | 2049 | "Gaudy expressions to highlight in Scheme modes.") |
| 2028 | 2050 | ||
| @@ -2221,7 +2243,7 @@ The value of this variable is used when Font Lock mode is turned on." | |||
| 2221 | :group 'font-lock-extra-types) | 2243 | :group 'font-lock-extra-types) |
| 2222 | 2244 | ||
| 2223 | (defcustom c++-font-lock-extra-types | 2245 | (defcustom c++-font-lock-extra-types |
| 2224 | '("[io]?\\(f\\|str\\)?stream\\(buf\\)?" "ios" | 2246 | '("\\([iof]\\|str\\)+stream\\(buf\\)?" "ios" |
| 2225 | "string" "rope" | 2247 | "string" "rope" |
| 2226 | "list" "slist" | 2248 | "list" "slist" |
| 2227 | "deque" "vector" "bit_vector" | 2249 | "deque" "vector" "bit_vector" |
| @@ -2315,7 +2337,7 @@ See also `c-font-lock-extra-types'.") | |||
| 2315 | '("^#[ \t]*error[ \t]+\\(.+\\)" 1 font-lock-warning-face prepend) | 2337 | '("^#[ \t]*error[ \t]+\\(.+\\)" 1 font-lock-warning-face prepend) |
| 2316 | ;; | 2338 | ;; |
| 2317 | ;; Fontify filenames in #include <...> preprocessor directives as strings. | 2339 | ;; Fontify filenames in #include <...> preprocessor directives as strings. |
| 2318 | '("^#[ \t]*\\(import\\|include\\)[ \t]+\\(<[^>\"\n]*>?\\)" | 2340 | '("^#[ \t]*\\(import\\|include\\)[ \t]*\\(<[^>\"\n]*>?\\)" |
| 2319 | 2 font-lock-string-face) | 2341 | 2 font-lock-string-face) |
| 2320 | ;; | 2342 | ;; |
| 2321 | ;; Fontify function macro names. | 2343 | ;; Fontify function macro names. |