annotate lisp/font-lock.el @ 13014:077bb437f649

(command_loop_1): Set this_command to nil before reading a command.
author Richard M. Stallman <rms@gnu.org>
date Sun, 10 Sep 1995 01:23:14 +0000
parents c9ed95ec05b6
children d6bfe124472c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;; Electric Font Lock Mode
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
2 ;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
4 ;; Author: jwz, then rms and sm <simon@gnu.ai.mit.edu>
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Maintainer: FSF
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Keywords: languages, faces
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
26 ;; Font Lock mode is a minor mode that causes your comments to be displayed in
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
27 ;; one face, strings in another, reserved words in another, and so on.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;;
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; Comments will be displayed in `font-lock-comment-face'.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; Strings will be displayed in `font-lock-string-face'.
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
31 ;; Regexps are used to display selected patterns in other faces.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;;
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; To make the text you type be fontified, use M-x font-lock-mode.
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
34 ;; When this minor mode is on, the faces of the current line are
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; updated with every insertion or deletion.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;;
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
37 ;; To turn Font Lock mode on automatically, add this to your .emacs file:
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
39 ;; (add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock)
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;;
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
41 ;; On a Sparc2, `font-lock-fontify-buffer' takes about 10 seconds for a 120k
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
42 ;; file of C code using the default configuration, and about 25 seconds using
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
43 ;; the more extensive configuration, though times also depend on file contents.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
44 ;; You can speed this up substantially by removing some of the patterns that
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
45 ;; are highlighted by default. Fontifying Lisp code is significantly faster,
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
46 ;; because Lisp has a more regular syntax than C, so the expressions don't have
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
47 ;; to be as hairy.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
48 ;;
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
49 ;; If you add patterns for a new mode, say foo.el's `foo-mode', say in which
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
50 ;; you don't want syntactic fontification to occur, you can make Font Lock mode
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
51 ;; use your regexps when turning on Font Lock by adding to `foo-mode-hook':
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
52 ;;
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
53 ;; (add-hook 'foo-mode-hook
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
54 ;; '(lambda () (make-local-variable 'font-lock-defaults)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
55 ;; (setq font-lock-defaults '(foo-font-lock-keywords t))))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
56 ;;
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
57 ;; Nasty regexps of the form "bar\\(\\|lo\\)\\|f\\(oo\\|u\\(\\|bar\\)\\)\\|lo"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
58 ;; are made thusly: (make-regexp '("foo" "fu" "fubar" "bar" "barlo" "lo")) for
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
59 ;; efficiency. See /pub/gnu/emacs/elisp-archive/functions/make-regexp.el.Z on
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
60 ;; archive.cis.ohio-state.edu for this and other functions.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
61
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;;; Code:
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
64 (defvar font-lock-comment-face 'font-lock-comment-face
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 "Face to use for comments.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
67 (defvar font-lock-string-face 'font-lock-string-face
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
68 "Face to use for strings.")
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
70 (defvar font-lock-function-name-face 'font-lock-function-name-face
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 "Face to use for function names.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
73 (defvar font-lock-variable-name-face 'font-lock-variable-name-face
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
74 "Face to use for variable names.")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
75
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
76 (defvar font-lock-keyword-face 'font-lock-keyword-face
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 "Face to use for keywords.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
79 (defvar font-lock-type-face 'font-lock-type-face
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 "Face to use for data types.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
82 (defvar font-lock-reference-face 'font-lock-reference-face
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
83 "Face to use for references.")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
84
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (make-variable-buffer-local 'font-lock-keywords)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (defvar font-lock-keywords nil
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
87 "*A list of the keywords to highlight.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
88 Each element should be of the form:
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
89
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
90 MATCHER
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
91 (MATCHER . MATCH)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
92 (MATCHER . FACENAME)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
93 (MATCHER . HIGHLIGHT)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
94 (MATCHER HIGHLIGHT ...)
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
96 where HIGHLIGHT should be of the form (MATCH FACENAME OVERRIDE LAXMATCH).
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
97 MATCHER can be either the regexp to search for, or the function name to call to
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
98 make the search (called with one argument, the limit of the search). MATCH is
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
99 the subexpression of MATCHER to be highlighted. FACENAME is an expression
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
100 whose value is the face name to use. FACENAME's default attributes may be
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
101 defined in `font-lock-face-attributes'.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
103 OVERRIDE and LAXMATCH are flags. If OVERRIDE is t, existing fontification may
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
104 be overriden. If `keep', only parts not already fontified are highlighted.
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
105 If LAXMATCH is non-nil, no error is signalled if there is no MATCH in MATCHER.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
107 These regular expressions should not match text which spans lines. While
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
108 \\[font-lock-fontify-buffer] handles multi-line patterns correctly, updating
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
109 when you edit the buffer does not, since it considers text one line at a time.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
110
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
111 Be careful composing regexps for this list;
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
112 the wrong pattern can dramatically slow things down!")
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
114 (defvar font-lock-defaults nil
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
115 "If set by a major mode, should be the defaults for Font Lock mode.
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
116 The value should look like the `cdr' of an item in `font-lock-defaults-alist'.")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
117
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
118 (defvar font-lock-defaults-alist
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
119 (let (
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
120 ;; For C and Lisp modes we use `beginning-of-defun', rather than nil,
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
121 ;; for SYNTAX-BEGIN. Thus the calculation of the cache is faster but
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
122 ;; not infallible, so we risk mis-fontification. --sm
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
123 (c-mode-defaults
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
124 '((c-font-lock-keywords c-font-lock-keywords-1 c-font-lock-keywords-2)
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
125 nil nil ((?\_ . "w")) beginning-of-defun))
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
126 (c++-mode-defaults
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
127 '((c++-font-lock-keywords c++-font-lock-keywords-1
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
128 c++-font-lock-keywords-2)
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
129 nil nil ((?\_ . "w")) beginning-of-defun))
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
130 (lisp-mode-defaults
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
131 '((lisp-font-lock-keywords lisp-font-lock-keywords-1
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
132 lisp-font-lock-keywords-2)
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
133 nil nil ((?\: . "w") (?\- . "w") (?\* . "w"))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
134 beginning-of-defun))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
135 (scheme-mode-defaults
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
136 '(scheme-font-lock-keywords
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
137 nil nil ((?\: . "w") (?\- . "w") (?\* . "w") (?\/ . "w"))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
138 beginning-of-defun))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
139 ;; For TeX modes we could use `backward-paragraph' for the same reason.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
140 (tex-mode-defaults '(tex-font-lock-keywords nil nil ((?\$ . "\""))))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
141 )
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
142 (list
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
143 (cons 'bibtex-mode tex-mode-defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
144 (cons 'c++-c-mode c-mode-defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
145 (cons 'c++-mode c++-mode-defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
146 (cons 'c-mode c-mode-defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
147 (cons 'emacs-lisp-mode lisp-mode-defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
148 (cons 'inferior-scheme-mode scheme-mode-defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
149 (cons 'latex-mode tex-mode-defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
150 (cons 'lisp-mode lisp-mode-defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
151 (cons 'lisp-interaction-mode lisp-mode-defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
152 (cons 'plain-tex-mode tex-mode-defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
153 (cons 'scheme-mode scheme-mode-defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
154 (cons 'scheme-interaction-mode scheme-mode-defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
155 (cons 'slitex-mode tex-mode-defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
156 (cons 'tex-mode tex-mode-defaults)))
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
157 "*Alist of default major mode and Font Lock defaults.
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
158 Each item should be a list of the form:
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
159
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
160 (MAJOR-MODE . (KEYWORDS KEYWORDS-ONLY CASE-FOLD SYNTAX-ALIST SYNTAX-BEGIN))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
161
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
162 where MAJOR-MODE is a symbol, and KEYWORDS may be a symbol or a list of
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
163 symbols. If KEYWORDS-ONLY is non-nil, syntactic fontification (strings and
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
164 comments) is not performed. If CASE-FOLD is non-nil, the case of the keywords
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
165 is ignored when fontifying. If SYNTAX-ALIST is non-nil, it should be a list of
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
166 cons pairs of the form (CHAR . STRING) used to set the local Font Lock syntax
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
167 table for keyword and syntactic fontification. (See `modify-syntax-entry'.)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
168
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
169 SYNTAX-BEGIN should be a function, it is called with no args to move outside of
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
170 a syntactic block for syntactic fontification. Typical values are nil
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
171 \(equivalent to `beginning-of-buffer'), `beginning-of-line' (i.e., the start of
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
172 the line is known to be outside a syntactic block), or `beginning-of-defun' for
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
173 programming modes or `backward-paragraph' for textual modes (i.e., the
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
174 mode-dependent function is known to move outside a syntactic block).
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
175
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
176 These item elements are used by Font Lock mode to set the variables
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
177 `font-lock-keywords', `font-lock-no-comments',
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
178 `font-lock-keywords-case-fold-search', `font-lock-syntax-table' and
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
179 `font-lock-beginning-of-syntax-function', respectively.")
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
180
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
181 (defvar font-lock-no-comments nil
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
182 "*Non-nil means Font Lock should not fontify comments or strings.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
183 This is normally set via `font-lock-defaults'.")
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
184
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (defvar font-lock-keywords-case-fold-search nil
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
186 "*Non-nil means the patterns in `font-lock-keywords' are case-insensitive.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
187 This is normally set via `font-lock-defaults'.")
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188
8457
c0492d7043b2 (font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents: 7915
diff changeset
189 (defvar font-lock-syntax-table nil
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
190 "Non-nil means use this syntax table for fontifying.
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
191 If this is nil, the major mode's syntax table is used.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
192 This is normally set via `font-lock-defaults'.")
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
193
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
194 (defvar font-lock-beginning-of-syntax-function nil
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
195 "*Non-nil means use this function to move outside of a syntactic block.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
196 If this is nil, `beginning-of-buffer' is used.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
197 This is normally set via `font-lock-defaults'.")
8457
c0492d7043b2 (font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents: 7915
diff changeset
198
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (defvar font-lock-verbose t
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 "*Non-nil means `font-lock-fontify-buffer' should print status messages.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201
4054
074035743fc9 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 4053
diff changeset
202 ;;;###autoload
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
203 (defvar font-lock-maximum-decoration nil
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
204 "*If non-nil, the maximum decoration for fontifying.
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
205 If nil, use the default decoration (typically the minimum available).
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
206 If t, use the maximum decoration available.
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
207 If a number, use that level of decoration (or if not available the maximum).")
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
208
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
209 ;;;###autoload
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
210 (defvar font-lock-maximum-size
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
211 (if font-lock-maximum-decoration (* 150 1024) (* 300 1024))
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
212 "*If non-nil, the maximum size for buffers for fontifying.
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
213 Only buffers less than this can be fontified when Font Lock mode is turned on.
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
214 If nil, means size is irrelevant.")
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
215
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
216 ;;;###autoload
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (defvar font-lock-mode-hook nil
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 "Function or functions to run on entry to Font Lock mode.")
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
219
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
220 ;; Colour etc. support.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
222 (defvar font-lock-display-type nil
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
223 "A symbol indicating the display Emacs is running under.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
224 The symbol should be one of `color', `grayscale' or `mono'.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
225 If Emacs guesses this display attribute wrongly, either set this variable in
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
226 your `~/.emacs' or set the resource `Emacs.displayType' in your `~/.Xdefaults'.
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
227 See also `font-lock-background-mode' and `font-lock-face-attributes'.")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
228
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
229 (defvar font-lock-background-mode nil
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
230 "A symbol indicating the Emacs background brightness.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
231 The symbol should be one of `light' or `dark'.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
232 If Emacs guesses this frame attribute wrongly, either set this variable in
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
233 your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
234 `~/.Xdefaults'.
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
235 See also `font-lock-display-type' and `font-lock-face-attributes'.")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
236
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
237 (defvar font-lock-face-attributes nil
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
238 "A list of default attributes to use for face attributes.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
239 Each element of the list should be of the form
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
240
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
241 (FACE FOREGROUND BACKGROUND BOLD-P ITALIC-P UNDERLINE-P)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
242
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
243 where FACE should be one of the face symbols `font-lock-comment-face',
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
244 `font-lock-string-face', `font-lock-keyword-face', `font-lock-type-face',
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
245 `font-lock-function-name-face', `font-lock-variable-name-face', and
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
246 `font-lock-reference-face'. A form for each of these face symbols should be
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
247 provided in the list, but other face symbols and attributes may be given and
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
248 used in highlighting. See `font-lock-keywords'.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
249
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
250 Subsequent element items should be the attributes for the corresponding
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
251 Font Lock mode faces. Attributes FOREGROUND and BACKGROUND should be strings
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
252 \(default if nil), while BOLD-P, ITALIC-P, and UNDERLINE-P should specify the
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
253 corresponding face attributes (yes if non-nil).
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
254
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
255 Emacs uses default attributes based on display type and background brightness.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
256 See variables `font-lock-display-type' and `font-lock-background-mode'.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
257
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
258 Resources can be used to over-ride these face attributes. For example, the
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
259 resource `Emacs.font-lock-comment-face.attributeUnderline' can be used to
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
260 specify the UNDERLINE-P attribute for face `font-lock-comment-face'.")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
261
12268
f22803cfdc5c Change so font-lock-make-faces doesn't stomp all over user Font Lock faces.
Simon Marshall <simon@gnu.org>
parents: 12047
diff changeset
262 (defun font-lock-make-faces (&optional override)
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
263 "Make faces from `font-lock-face-attributes'.
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
264 A default list is used if this is nil.
12268
f22803cfdc5c Change so font-lock-make-faces doesn't stomp all over user Font Lock faces.
Simon Marshall <simon@gnu.org>
parents: 12047
diff changeset
265 If optional OVERRIDE is non-nil, faces that already exist are reset.
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
266 See `font-lock-make-face' and `list-faces-display'."
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
267 ;; We don't need to `setq' any of these variables, but the user can see what
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
268 ;; is being used if we do.
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
269 (if (null font-lock-display-type)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
270 (setq font-lock-display-type
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
271 (let ((display-resource (x-get-resource ".displayType"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
272 "DisplayType")))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
273 (cond (display-resource (intern (downcase display-resource)))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
274 ((x-display-color-p) 'color)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
275 ((x-display-grayscale-p) 'grayscale)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
276 (t 'mono)))))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
277 (if (null font-lock-background-mode)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
278 (setq font-lock-background-mode
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
279 (let ((bg-resource (x-get-resource ".backgroundMode"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
280 "BackgroundMode"))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
281 (params (frame-parameters)))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
282 (cond (bg-resource (intern (downcase bg-resource)))
11467
bb7c9db199ae (font-lock-make-faces): Determine font-lock-background-mode from color
Richard M. Stallman <rms@gnu.org>
parents: 10879
diff changeset
283 ((< (apply '+ (x-color-values
bb7c9db199ae (font-lock-make-faces): Determine font-lock-background-mode from color
Richard M. Stallman <rms@gnu.org>
parents: 10879
diff changeset
284 (cdr (assq 'background-color params))))
bb7c9db199ae (font-lock-make-faces): Determine font-lock-background-mode from color
Richard M. Stallman <rms@gnu.org>
parents: 10879
diff changeset
285 (/ (apply '+ (x-color-values "white")) 3))
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
286 'dark)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
287 (t 'light)))))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
288 (if (null font-lock-face-attributes)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
289 (setq font-lock-face-attributes
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
290 (let ((light-bg (eq font-lock-background-mode 'light)))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
291 (cond ((memq font-lock-display-type '(mono monochrome))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
292 ;; Emacs 19.25's font-lock defaults:
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
293 ;;'((font-lock-comment-face nil nil nil t nil)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
294 ;; (font-lock-string-face nil nil nil nil t)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
295 ;; (font-lock-keyword-face nil nil t nil nil)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
296 ;; (font-lock-function-name-face nil nil t t nil)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
297 ;; (font-lock-type-face nil nil nil t nil))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
298 (list '(font-lock-comment-face nil nil t t nil)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
299 '(font-lock-string-face nil nil nil t nil)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
300 '(font-lock-keyword-face nil nil t nil nil)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
301 (list
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
302 'font-lock-function-name-face
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
303 (cdr (assq 'background-color (frame-parameters)))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
304 (cdr (assq 'foreground-color (frame-parameters)))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
305 t nil nil)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
306 '(font-lock-variable-name-face nil nil t t nil)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
307 '(font-lock-type-face nil nil t nil t)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
308 '(font-lock-reference-face nil nil t nil t)))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
309 ((memq font-lock-display-type '(grayscale greyscale
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
310 grayshade greyshade))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
311 (list
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
312 (list 'font-lock-comment-face
12484
bf638e2849d5 (font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents: 12385
diff changeset
313 nil (if light-bg "Gray80" "DimGray") t t nil)
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
314 (list 'font-lock-string-face
12484
bf638e2849d5 (font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents: 12385
diff changeset
315 nil (if light-bg "Gray50" "LightGray") nil t nil)
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
316 (list 'font-lock-keyword-face
12484
bf638e2849d5 (font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents: 12385
diff changeset
317 nil (if light-bg "Gray90" "DimGray") t nil nil)
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
318 (list 'font-lock-function-name-face
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
319 (cdr (assq 'background-color (frame-parameters)))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
320 (cdr (assq 'foreground-color (frame-parameters)))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
321 t nil nil)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
322 (list 'font-lock-variable-name-face
12484
bf638e2849d5 (font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents: 12385
diff changeset
323 nil (if light-bg "Gray90" "DimGray") t t nil)
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
324 (list 'font-lock-type-face
12484
bf638e2849d5 (font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents: 12385
diff changeset
325 nil (if light-bg "Gray80" "DimGray") t nil t)
10099
71e0c3ece2fe Added defaults for grayscale font-lock-reference-face.
Simon Marshall <simon@gnu.org>
parents: 9909
diff changeset
326 (list 'font-lock-reference-face
12484
bf638e2849d5 (font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents: 12385
diff changeset
327 nil (if light-bg "LightGray" "Gray50") t nil t)))
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
328 (light-bg ; light colour background
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
329 '((font-lock-comment-face "Firebrick")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
330 (font-lock-string-face "RosyBrown")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
331 (font-lock-keyword-face "Purple")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
332 (font-lock-function-name-face "Blue")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
333 (font-lock-variable-name-face "DarkGoldenrod")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
334 (font-lock-type-face "DarkOliveGreen")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
335 (font-lock-reference-face "CadetBlue")))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
336 (t ; dark colour background
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
337 '((font-lock-comment-face "OrangeRed")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
338 (font-lock-string-face "LightSalmon")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
339 (font-lock-keyword-face "LightSteelBlue")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
340 (font-lock-function-name-face "LightSkyBlue")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
341 (font-lock-variable-name-face "LightGoldenrod")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
342 (font-lock-type-face "PaleGreen")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
343 (font-lock-reference-face "Aquamarine")))))))
12268
f22803cfdc5c Change so font-lock-make-faces doesn't stomp all over user Font Lock faces.
Simon Marshall <simon@gnu.org>
parents: 12047
diff changeset
344 ;; Now make the faces if we have to.
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
345 (mapcar (function
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
346 (lambda (face-attributes)
12268
f22803cfdc5c Change so font-lock-make-faces doesn't stomp all over user Font Lock faces.
Simon Marshall <simon@gnu.org>
parents: 12047
diff changeset
347 (let ((face (nth 0 face-attributes)))
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
348 (cond (override
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
349 ;; We can stomp all over it anyway. Get outta my face!
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
350 (font-lock-make-face face-attributes))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
351 ((and (boundp face) (facep (symbol-value face)))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
352 ;; The variable exists and is already bound to a face.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
353 nil)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
354 ((facep face)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
355 ;; We already have a face so we bind the variable to it.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
356 (set face face))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
357 (t
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
358 ;; No variable or no face.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
359 (font-lock-make-face face-attributes))))))
12268
f22803cfdc5c Change so font-lock-make-faces doesn't stomp all over user Font Lock faces.
Simon Marshall <simon@gnu.org>
parents: 12047
diff changeset
360 font-lock-face-attributes))
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
361
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
362 (defun font-lock-make-face (face-attributes)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
363 "Make a face from FACE-ATTRIBUTES.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
364 FACE-ATTRIBUTES should be like an element `font-lock-face-attributes', so that
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
365 the face name is the first item in the list. A variable with the same name as
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
366 the face is also set; its value is the face name."
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
367 (let* ((face (nth 0 face-attributes))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
368 (face-name (symbol-name face))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
369 (set-p (function (lambda (face-name resource)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
370 (x-get-resource (concat face-name ".attribute" resource)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
371 (concat "Face.Attribute" resource)))))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
372 (on-p (function (lambda (face-name resource)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
373 (let ((set (funcall set-p face-name resource)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
374 (and set (member (downcase set) '("on" "true"))))))))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
375 (make-face face)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
376 ;; Set attributes not set from X resources (and therefore `make-face').
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
377 (or (funcall set-p face-name "Foreground")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
378 (condition-case nil
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
379 (set-face-foreground face (nth 1 face-attributes))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
380 (error nil)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
381 (or (funcall set-p face-name "Background")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
382 (condition-case nil
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
383 (set-face-background face (nth 2 face-attributes))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
384 (error nil)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
385 (if (funcall set-p face-name "Bold")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
386 (and (funcall on-p face-name "Bold") (make-face-bold face nil t))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
387 (and (nth 3 face-attributes) (make-face-bold face nil t)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
388 (if (funcall set-p face-name "Italic")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
389 (and (funcall on-p face-name "Italic") (make-face-italic face nil t))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
390 (and (nth 4 face-attributes) (make-face-italic face nil t)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
391 (or (funcall set-p face-name "Underline")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
392 (set-face-underline-p face (nth 5 face-attributes)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
393 (set face face)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
394
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
395 ;; Fontification.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
396
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
397 ;; These variables record, for each buffer, the parse state at a particular
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
398 ;; position, always the start of a line. Used to make font-lock-fontify-region
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
399 ;; faster.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (defvar font-lock-cache-position nil)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 (defvar font-lock-cache-state nil)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 (make-variable-buffer-local 'font-lock-cache-position)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (make-variable-buffer-local 'font-lock-cache-state)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
405 (defun font-lock-fontify-region (start end &optional loudly)
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 "Put proper face on each string and comment between START and END."
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (save-excursion
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
408 (save-restriction
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
409 (widen)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
410 (goto-char start)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
411 (beginning-of-line)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
412 (if loudly (message "Fontifying %s... (syntactically...)" (buffer-name)))
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
413 (let ((inhibit-read-only t) (buffer-undo-list t)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
414 buffer-file-name buffer-file-truename
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
415 (modified (buffer-modified-p))
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
416 (old-syntax (syntax-table))
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
417 (synstart (if comment-start-skip
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
418 (concat "\\s\"\\|" comment-start-skip)
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
419 "\\s\""))
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
420 (comstart (if comment-start-skip
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
421 (concat "\\s<\\|" comment-start-skip)
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
422 "\\s<"))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
423 (startline (point))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
424 state prev prevstate)
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
425 (unwind-protect
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
426 (progn
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
427 ;;
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
428 ;; Use the fontification syntax table, if any.
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
429 (if font-lock-syntax-table
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
430 (set-syntax-table font-lock-syntax-table))
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
431 ;;
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
432 ;; Find the state at the `beginning-of-line' before `start'.
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
433 (if (eq startline font-lock-cache-position)
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
434 ;; Use the cache for the state of `startline'.
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
435 (setq state font-lock-cache-state)
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
436 ;; Find the state of `startline'.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
437 (if (null font-lock-beginning-of-syntax-function)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
438 ;; Use the state at the previous cache position, if any, or
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
439 ;; otherwise calculate from `point-min'.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
440 (if (or (null font-lock-cache-position)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
441 (< startline font-lock-cache-position))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
442 (setq state (parse-partial-sexp
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
443 (point-min) startline))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
444 (setq state (parse-partial-sexp
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
445 font-lock-cache-position startline
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
446 nil nil font-lock-cache-state)))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
447 ;; Call the function to move outside any syntactic block.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
448 (funcall font-lock-beginning-of-syntax-function)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
449 (setq state (parse-partial-sexp (point) startline)))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
450 ;; Cache the state and position of `startline'.
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
451 (setq font-lock-cache-state state
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
452 font-lock-cache-position startline))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
453 ;;
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
454 ;; Now find the state at `start' based on that of `startline'.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
455 (setq state (parse-partial-sexp startline start nil nil state))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
456 ;;
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
457 ;; If the region starts inside a string, show the extent of it.
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
458 (if (nth 3 state)
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
459 (let ((beg (point)))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
460 (while (and (re-search-forward "\\s\"" end 'move)
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
461 (nth 3 (parse-partial-sexp beg (point) nil nil
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
462 state))))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
463 (put-text-property beg (point) 'face font-lock-string-face)
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
464 (setq state (parse-partial-sexp beg (point)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
465 nil nil state))))
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
466 ;;
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
467 ;; Likewise for a comment.
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
468 (if (or (nth 4 state) (nth 7 state))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
469 (let ((beg (point)))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
470 (save-restriction
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
471 (narrow-to-region (point-min) end)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
472 (condition-case nil
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
473 (progn
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
474 (re-search-backward comstart (point-min) 'move)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
475 (forward-comment 1)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
476 ;; forward-comment skips all whitespace,
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
477 ;; so go back to the real end of the comment.
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
478 (skip-chars-backward " \t"))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
479 (error (goto-char end))))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
480 (put-text-property beg (point) 'face
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
481 font-lock-comment-face)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
482 (setq state (parse-partial-sexp beg (point)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
483 nil nil state))))
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
484 ;;
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
485 ;; Find each interesting place between here and `end'.
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
486 (while (and (< (point) end)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
487 (setq prev (point) prevstate state)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
488 (re-search-forward synstart end t)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
489 (progn
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
490 ;; Clear out the fonts of what we skip over.
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
491 (remove-text-properties prev (point) '(face nil))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
492 ;; Verify the state at that place
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
493 ;; so we don't get fooled by \" or \;.
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
494 (setq state (parse-partial-sexp prev (point)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
495 nil nil state))))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
496 (let ((here (point)))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
497 (if (or (nth 4 state) (nth 7 state))
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
498 ;;
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
499 ;; We found a real comment start.
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
500 (let ((beg (match-beginning 0)))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
501 (goto-char beg)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
502 (save-restriction
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
503 (narrow-to-region (point-min) end)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
504 (condition-case nil
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
505 (progn
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
506 (forward-comment 1)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
507 ;; forward-comment skips all whitespace,
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
508 ;; so go back to the real end of the comment.
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
509 (skip-chars-backward " \t"))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
510 (error (goto-char end))))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
511 (put-text-property beg (point) 'face
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
512 font-lock-comment-face)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
513 (setq state (parse-partial-sexp here (point)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
514 nil nil state)))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
515 (if (nth 3 state)
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
516 ;;
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
517 ;; We found a real string start.
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
518 (let ((beg (match-beginning 0)))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
519 (while (and (re-search-forward "\\s\"" end 'move)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
520 (nth 3 (parse-partial-sexp
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
521 here (point) nil nil state))))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
522 (put-text-property beg (point) 'face
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
523 font-lock-string-face)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
524 (setq state (parse-partial-sexp here (point)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
525 nil nil state))))))
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
526 ;;
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
527 ;; Make sure `prev' is non-nil after the loop
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
528 ;; only if it was set on the very last iteration.
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
529 (setq prev nil)))
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
530 ;;
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
531 ;; Clean up.
12512
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
532 (set-syntax-table old-syntax)
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
533 (and prev
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
534 (remove-text-properties prev end '(face nil)))
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
535 (and (buffer-modified-p)
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
536 (not modified)
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
537 (set-buffer-modified-p nil)))))))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (defun font-lock-unfontify-region (beg end)
4219
24f3ca095be9 (perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents: 4054
diff changeset
540 (let ((modified (buffer-modified-p))
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
541 (buffer-undo-list t) (inhibit-read-only t)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
542 buffer-file-name buffer-file-truename)
4219
24f3ca095be9 (perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents: 4054
diff changeset
543 (remove-text-properties beg end '(face nil))
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
544 (and (buffer-modified-p)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
545 (not modified)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
546 (set-buffer-modified-p nil))))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 ;; Called when any modification is made to buffer text.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 (defun font-lock-after-change-function (beg end old-len)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 (save-excursion
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (save-match-data
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 ;; Discard the cache info if text before it has changed.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 (and font-lock-cache-position
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 (> font-lock-cache-position beg)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 (setq font-lock-cache-position nil))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
556 ;; Rescan between start of line from `beg' and start of line after `end'.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 (goto-char beg)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 (beginning-of-line)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 (setq beg (point))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
560 (goto-char end)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
561 (forward-line 1)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
562 (setq end (point))
4239
e8cf7a7d0102 (font-lock-after-change-function):
Richard M. Stallman <rms@gnu.org>
parents: 4219
diff changeset
563 ;; First scan for strings and comments.
e8cf7a7d0102 (font-lock-after-change-function):
Richard M. Stallman <rms@gnu.org>
parents: 4219
diff changeset
564 ;; Must scan from line start in case of
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
565 ;; inserting space into `intfoo () {}', and after widened.
7491
621c162a80db (font-lock-no-comments): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
566 (if font-lock-no-comments
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
567 (font-lock-unfontify-region beg end)
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
568 (font-lock-fontify-region beg end))
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
569 ;; Now scan for keywords.
10116
a8cdb7630b1c Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents: 10099
diff changeset
570 (font-lock-hack-keywords beg end))))
a8cdb7630b1c Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents: 10099
diff changeset
571
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
572 ;; The following must be rethought, since keywords can override fontification.
10116
a8cdb7630b1c Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents: 10099
diff changeset
573 ; ;; Now scan for keywords, but not if we are inside a comment now.
a8cdb7630b1c Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents: 10099
diff changeset
574 ; (or (and (not font-lock-no-comments)
a8cdb7630b1c Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents: 10099
diff changeset
575 ; (let ((state (parse-partial-sexp beg end nil nil
a8cdb7630b1c Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents: 10099
diff changeset
576 ; font-lock-cache-state)))
a8cdb7630b1c Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents: 10099
diff changeset
577 ; (or (nth 4 state) (nth 7 state))))
a8cdb7630b1c Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents: 10099
diff changeset
578 ; (font-lock-hack-keywords beg end))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 ;;; Fontifying arbitrary patterns
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581
12047
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
582 (defun font-lock-compile-keywords (&optional keywords)
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
583 ;; Compile `font-lock-keywords' into the form (t KEYWORD ...) where KEYWORD
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
584 ;; is the (MATCHER HIGHLIGHT ...) shown in the variable's doc string.
12047
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
585 (let ((keywords (or keywords font-lock-keywords)))
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
586 (setq font-lock-keywords
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
587 (if (eq (car-safe keywords) t)
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
588 keywords
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
589 (cons t
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
590 (mapcar
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
591 (function (lambda (item)
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
592 (cond ((nlistp item)
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
593 (list item '(0 font-lock-keyword-face)))
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
594 ((numberp (cdr item))
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
595 (list (car item) (list (cdr item) 'font-lock-keyword-face)))
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
596 ((symbolp (cdr item))
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
597 (list (car item) (list 0 (cdr item))))
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
598 ((nlistp (nth 1 item))
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
599 (list (car item) (cdr item)))
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
600 (t
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
601 item))))
e6001f10daad Made font-lock-compile-keywords not compile if it looks like it already has.
Simon Marshall <simon@gnu.org>
parents: 11983
diff changeset
602 keywords))))))
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
603
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
604 (defsubst font-lock-apply-highlight (highlight)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
605 "Apply HIGHLIGHT following a match. See `font-lock-keywords'."
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
606 (let* ((match (nth 0 highlight))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
607 (beg (match-beginning match)) (end (match-end match))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
608 (override (nth 2 highlight)))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
609 (cond ((not beg)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
610 ;; No match but we might not signal an error
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
611 (or (nth 3 highlight) (error "Highlight %S failed" highlight)))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
612 ((and (not override) (text-property-not-all beg end 'face nil))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
613 ;; Can't override and already fontified
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
614 nil)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
615 ((not (eq override 'keep))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
616 ;; Can override but need not keep existing fontification
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
617 (put-text-property beg end 'face (eval (nth 1 highlight))))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
618 (t
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
619 ;; Can override but must keep existing fontification
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
620 (let ((pos (text-property-any beg end 'face nil)) next
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
621 (face (eval (nth 1 highlight))))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
622 (while pos
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
623 (setq next (next-single-property-change pos 'face nil end))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
624 (put-text-property pos next 'face face)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
625 (setq pos (text-property-any next end 'face nil))))))))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
626
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 (defun font-lock-hack-keywords (start end &optional loudly)
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
628 "Fontify according to `font-lock-keywords' between START and END."
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 (let ((case-fold-search font-lock-keywords-case-fold-search)
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
630 (keywords (cdr (if (eq (car-safe font-lock-keywords) t)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
631 font-lock-keywords
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
632 (font-lock-compile-keywords))))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 (count 0)
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
634 (inhibit-read-only t) (buffer-undo-list t)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
635 buffer-file-name buffer-file-truename
4219
24f3ca095be9 (perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents: 4054
diff changeset
636 (modified (buffer-modified-p))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
637 (old-syntax (syntax-table))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
638 (bufname (buffer-name)))
8457
c0492d7043b2 (font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents: 7915
diff changeset
639 (unwind-protect
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
640 (let (keyword matcher highlights lowdarks)
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
641 (if loudly (message "Fontifying %s... (regexps...)" bufname))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
642 (if font-lock-syntax-table (set-syntax-table font-lock-syntax-table))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
643 (while keywords
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
644 (setq keyword (car keywords) keywords (cdr keywords)
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
645 matcher (car keyword) highlights (cdr keyword))
8457
c0492d7043b2 (font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents: 7915
diff changeset
646 (goto-char start)
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
647 (while (if (stringp matcher)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
648 (re-search-forward matcher end t)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
649 (funcall matcher end))
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
650 ;; An explicit `while' loop is slightly faster than a `mapcar'.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
651 ;(mapcar 'font-lock-apply-highlight highlights)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
652 (setq lowdarks highlights)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
653 (while lowdarks
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
654 (font-lock-apply-highlight (car lowdarks))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
655 (setq lowdarks (cdr lowdarks))))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
656 (if loudly (message "Fontifying %s... (regexps...%s)" bufname
8457
c0492d7043b2 (font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents: 7915
diff changeset
657 (make-string (setq count (1+ count)) ?.)))))
12512
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
658 (set-syntax-table old-syntax)
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
659 (and (buffer-modified-p)
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
660 (not modified)
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
661 (set-buffer-modified-p nil)))))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 ;; The user level functions
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (defvar font-lock-mode nil) ; for modeline
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 (defvar font-lock-fontified nil) ; whether we have hacked this buffer
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (put 'font-lock-fontified 'permanent-local t)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 ;;;###autoload
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 (defun font-lock-mode (&optional arg)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 "Toggle Font Lock mode.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 With arg, turn Font Lock mode on if and only if arg is positive.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 When Font Lock mode is enabled, text is fontified as you type it:
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
677 - Comments are displayed in `font-lock-comment-face';
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
678 - Strings are displayed in `font-lock-string-face';
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
679 - Certain other expressions are displayed in other faces according to the
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
680 value of the variable `font-lock-keywords'.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
681
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
682 You can enable Font Lock mode in any major mode automatically by turning on in
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
683 the major mode's hook. For example, put in your ~/.emacs:
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
684
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
685 (add-hook 'c-mode-hook 'turn-on-font-lock)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
686
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
687 Or for any visited file with the following in your ~/.emacs:
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
688
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
689 (add-hook 'find-file-hooks 'turn-on-font-lock)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
690
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
691 The default Font Lock mode faces and their attributes are defined in the
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
692 variable `font-lock-face-attributes', and Font Lock mode default settings in
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
693 the variable `font-lock-defaults-alist'.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
695 Where modes support different levels of fontification, you can use the variable
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
696 `font-lock-maximum-decoration' to specify which level you generally prefer.
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
697 When you turn Font Lock mode on/off the buffer is fontified/defontified, though
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
698 fontification occurs only if the buffer is less than `font-lock-maximum-size'.
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
699 To fontify a buffer without turning on Font Lock mode, and regardless of buffer
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
700 size, you can use \\[font-lock-fontify-buffer]."
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 (interactive "P")
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
702 (let ((on-p (if arg (> (prefix-numeric-value arg) 0) (not font-lock-mode))))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 (if (equal (buffer-name) " *Compiler Input*") ; hack for bytecomp...
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 (setq on-p nil))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
705 (if (not on-p)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
706 (remove-hook 'after-change-functions 'font-lock-after-change-function)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
707 (make-local-variable 'after-change-functions)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
708 (add-hook 'after-change-functions 'font-lock-after-change-function))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 (set (make-local-variable 'font-lock-mode) on-p)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 (cond (on-p
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 (font-lock-set-defaults)
5717
24e1180b507d (font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents: 5625
diff changeset
712 (make-local-variable 'before-revert-hook)
5625
24f92f49a07f (font-lock-mode): Set after-revert-hook
Richard M. Stallman <rms@gnu.org>
parents: 5360
diff changeset
713 (make-local-variable 'after-revert-hook)
5717
24e1180b507d (font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents: 5625
diff changeset
714 ;; If buffer is reverted, must clean up the state.
24e1180b507d (font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents: 5625
diff changeset
715 (add-hook 'before-revert-hook 'font-lock-revert-setup)
24e1180b507d (font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents: 5625
diff changeset
716 (add-hook 'after-revert-hook 'font-lock-revert-cleanup)
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (run-hooks 'font-lock-mode-hook)
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
718 (cond (font-lock-fontified
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
719 nil)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
720 ((or (null font-lock-maximum-size)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
721 (> font-lock-maximum-size (buffer-size)))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
722 (font-lock-fontify-buffer))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
723 (font-lock-verbose
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
724 (message "Fontifying %s... buffer too big." (buffer-name)))))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 (font-lock-fontified
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 (setq font-lock-fontified nil)
5717
24e1180b507d (font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents: 5625
diff changeset
727 (remove-hook 'before-revert-hook 'font-lock-revert-setup)
24e1180b507d (font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents: 5625
diff changeset
728 (remove-hook 'after-revert-hook 'font-lock-revert-cleanup)
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
729 (font-lock-unfontify-region (point-min) (point-max))
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
730 (font-lock-thing-lock-cleanup))
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
731 (t
11983
a4ab2659db4f (font-lock-revert-cleanup): Always turn font lock on.
Karl Heuer <kwzh@gnu.org>
parents: 11515
diff changeset
732 (remove-hook 'before-revert-hook 'font-lock-revert-setup)
a4ab2659db4f (font-lock-revert-cleanup): Always turn font lock on.
Karl Heuer <kwzh@gnu.org>
parents: 11515
diff changeset
733 (remove-hook 'after-revert-hook 'font-lock-revert-cleanup)
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
734 (font-lock-thing-lock-cleanup)))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 (force-mode-line-update)))
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
737 ;;;###autoload
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
738 (defun turn-on-font-lock ()
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
739 "Unconditionally turn on Font Lock mode."
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
740 (font-lock-mode 1))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
741
12512
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
742 ;; Turn off other related packages if they're on. I prefer a hook. --sm.
11983
a4ab2659db4f (font-lock-revert-cleanup): Always turn font lock on.
Karl Heuer <kwzh@gnu.org>
parents: 11515
diff changeset
743 ;; These explicit calls are easier to understand
a4ab2659db4f (font-lock-revert-cleanup): Always turn font lock on.
Karl Heuer <kwzh@gnu.org>
parents: 11515
diff changeset
744 ;; because people know what they will do.
12512
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
745 ;; A hook is a mystery because it might do anything whatever. --rms.
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
746 (defun font-lock-thing-lock-cleanup ()
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
747 (cond ((and (boundp 'fast-lock-mode) fast-lock-mode)
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
748 (fast-lock-mode -1))
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
749 ((and (boundp 'lazy-lock-mode) lazy-lock-mode)
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
750 (lazy-lock-mode -1))))
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
751
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
752 ;; Do something special for these packages after fontifying. I prefer a hook.
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
753 (defun font-lock-after-fontify-buffer ()
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
754 (cond ((and (boundp 'fast-lock-mode) fast-lock-mode)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
755 (fast-lock-after-fontify-buffer))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
756 ((and (boundp 'lazy-lock-mode) lazy-lock-mode)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
757 (lazy-lock-after-fontify-buffer))))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
758
11983
a4ab2659db4f (font-lock-revert-cleanup): Always turn font lock on.
Karl Heuer <kwzh@gnu.org>
parents: 11515
diff changeset
759 ;; If the buffer is about to be reverted, it won't be fontified afterward.
5717
24e1180b507d (font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents: 5625
diff changeset
760 (defun font-lock-revert-setup ()
24e1180b507d (font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents: 5625
diff changeset
761 (setq font-lock-fontified nil))
24e1180b507d (font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents: 5625
diff changeset
762
11983
a4ab2659db4f (font-lock-revert-cleanup): Always turn font lock on.
Karl Heuer <kwzh@gnu.org>
parents: 11515
diff changeset
763 ;; If the buffer has just been reverted, normally that turns off
a4ab2659db4f (font-lock-revert-cleanup): Always turn font lock on.
Karl Heuer <kwzh@gnu.org>
parents: 11515
diff changeset
764 ;; Font Lock mode. So turn the mode back on if necessary.
5717
24e1180b507d (font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents: 5625
diff changeset
765 (defun font-lock-revert-cleanup ()
11983
a4ab2659db4f (font-lock-revert-cleanup): Always turn font lock on.
Karl Heuer <kwzh@gnu.org>
parents: 11515
diff changeset
766 (font-lock-mode 1))
5717
24e1180b507d (font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents: 5625
diff changeset
767
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
768 ;;;###autoload
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 (defun font-lock-fontify-buffer ()
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
770 "Fontify the current buffer the way `font-lock-mode' would."
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 (interactive)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 (let ((was-on font-lock-mode)
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
773 (verbose (and (or font-lock-verbose (interactive-p))
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
774 (not (zerop (buffer-size)))))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
775 (modified (buffer-modified-p)))
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
776 (set (make-local-variable 'font-lock-fontified) nil)
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
777 (if verbose (message "Fontifying %s..." (buffer-name)))
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
778 ;; Turn it on to run hooks and get the right `font-lock-keywords' etc.
4897
c3db6fd69f1f (font-lock-fontify-buffer): Don't turn
Richard M. Stallman <rms@gnu.org>
parents: 4727
diff changeset
779 (or was-on (font-lock-set-defaults))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
780 (condition-case nil
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
781 (save-excursion
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
782 (if font-lock-no-comments
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
783 (font-lock-unfontify-region (point-min) (point-max))
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
784 (font-lock-fontify-region (point-min) (point-max) verbose))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
785 (font-lock-hack-keywords (point-min) (point-max) verbose)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
786 (setq font-lock-fontified t))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
787 ;; We don't restore the old fontification, so it's best to unfontify.
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
788 (quit (font-lock-unfontify-region (point-min) (point-max))))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
789 (if verbose (message "Fontifying %s... %s." (buffer-name)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
790 (if font-lock-fontified "done" "aborted")))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
791 (and (buffer-modified-p)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
792 (not modified)
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
793 (set-buffer-modified-p nil))
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
794 (font-lock-after-fontify-buffer)))
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
795
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
796 (defun font-lock-choose-keywords (keywords level)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
797 ;; Return LEVELth element of KEYWORDS. A LEVEL of nil is equal to a
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
798 ;; LEVEL of 0, a LEVEL of t is equal to (1- (length KEYWORDS)).
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
799 (cond ((symbolp keywords)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
800 keywords)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
801 ((numberp level)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
802 (or (nth level keywords) (car (reverse keywords))))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
803 ((eq level t)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
804 (car (reverse keywords)))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
805 (t
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
806 (car keywords))))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
807
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
808 (defun font-lock-set-defaults ()
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
809 "Set fontification defaults appropriately for this mode.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
810 Sets `font-lock-keywords', `font-lock-no-comments', `font-lock-syntax-table'
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
811 and `font-lock-keywords-case-fold-search' using `font-lock-defaults' (or, if
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
812 nil, using `font-lock-defaults-alist') and `font-lock-maximum-decoration'."
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
813 ;; Set face defaults.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
814 (font-lock-make-faces)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
815 ;; Set fontification defaults.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
816 (or font-lock-keywords
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
817 (let ((defaults (or font-lock-defaults
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
818 (cdr (assq major-mode font-lock-defaults-alist)))))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
819 ;; Keywords?
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
820 (setq font-lock-keywords
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
821 (font-lock-compile-keywords
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
822 (eval (font-lock-choose-keywords (nth 0 defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
823 font-lock-maximum-decoration))))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
824 ;; Syntactic?
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
825 (if (nth 1 defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
826 (set (make-local-variable 'font-lock-no-comments) t))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
827 ;; Case fold?
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
828 (if (nth 2 defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
829 (set (make-local-variable 'font-lock-keywords-case-fold-search) t))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
830 ;; Syntax table?
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
831 (if (nth 3 defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
832 (let ((slist (nth 3 defaults)))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
833 (set (make-local-variable 'font-lock-syntax-table)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
834 (copy-syntax-table (syntax-table)))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
835 (while slist
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
836 (modify-syntax-entry (car (car slist)) (cdr (car slist))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
837 font-lock-syntax-table)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
838 (setq slist (cdr slist)))))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
839 ;; Syntactic cache function?
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
840 (if (nth 4 defaults)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
841 (set (make-local-variable 'font-lock-beginning-of-syntax-function)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
842 (nth 4 defaults))))))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
844 ;;; Various information shared by several modes.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
845 ;;; Information specific to a single mode should go in its load library.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 (defconst lisp-font-lock-keywords-1
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
848 (list
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
849 ;; Everything not a variable or type declaration is fontified as a function.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
850 ;; It would be cleaner to allow preceding whitespace, but it would also be
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
851 ;; about five times slower.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
852 (list (concat "^(\\(def\\("
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
853 ;; Variable declarations.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
854 "\\(const\\(\\|ant\\)\\|ine-key\\(\\|-after\\)\\|var\\)\\|"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
855 ;; Structure declarations.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
856 "\\(class\\|struct\\|type\\)\\|"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
857 ;; Everything else is a function declaration.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
858 "\\([^ \t\n\(\)]+\\)"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
859 "\\)\\)\\>"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
860 ;; Any whitespace and declared object.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
861 "[ \t'\(]*"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
862 "\\([^ \t\n\)]+\\)?")
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
863 '(1 font-lock-keyword-face)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
864 '(8 (cond ((match-beginning 3) font-lock-variable-name-face)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
865 ((match-beginning 6) font-lock-type-face)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
866 (t font-lock-function-name-face))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
867 nil t)))
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
868 "Subdued level highlighting Lisp modes.")
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 (defconst lisp-font-lock-keywords-2
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
871 (append lisp-font-lock-keywords-1
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
872 (let ((word-char "[-+a-zA-Z0-9_:*]"))
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
873 (list
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
874 ;;
12512
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
875 ;; Control structures. ELisp and CLisp combined.
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
876 ; (make-regexp
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
877 ; '("cond" "if" "while" "let\\*?" "prog[nv12*]?" "catch" "throw"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
878 ; "save-restriction" "save-excursion" "save-window-excursion"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
879 ; "save-selected-window" "save-match-data" "unwind-protect"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
880 ; "condition-case" "track-mouse"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
881 ; "eval-after-load" "eval-and-compile" "eval-when-compile"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
882 ; "when" "unless" "do" "flet" "labels" "return" "return-from"))
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
883 (cons
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
884 (concat
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
885 "(\\("
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
886 "\\(c\\(atch\\|ond\\(\\|ition-case\\)\\)\\|do\\|"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
887 "eval-\\(a\\(fter-load\\|nd-compile\\)\\|when-compile\\)\\|flet\\|"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
888 "if\\|l\\(abels\\|et\\*?\\)\\|prog[nv12*]?\\|return\\(\\|-from\\)\\|"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
889 "save-\\(excursion\\|match-data\\|restriction\\|selected-window\\|"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
890 "window-excursion\\)\\|t\\(hrow\\|rack-mouse\\)\\|"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
891 "un\\(less\\|wind-protect\\)\\|wh\\(en\\|ile\\)\\)"
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
892 "\\)\\>") 1)
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
893 ;;
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
894 ;; Function names in emacs-lisp docstrings (in the syntax that
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
895 ;; `substitute-command-keys' understands).
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
896 (list (concat "\\\\\\\\\\[\\(" word-char "+\\)]")
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
897 1 font-lock-reference-face t)
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
898 ;;
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
899 ;; Words inside `' which tend to be symbol names.
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
900 (list (concat "`\\(" word-char word-char "+\\)'")
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
901 1 'font-lock-reference-face t)
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
902 ;;
12512
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
903 ;; CLisp `:' keywords as references.
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
904 (list (concat "\\<:" word-char "+\\>") 0 font-lock-reference-face t)
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
905 ;;
997e250dfe12 Do all cleanups in font-lock-fontify-region and font-lock-hack-keywords inside
Simon Marshall <simon@gnu.org>
parents: 12484
diff changeset
906 ;; ELisp and CLisp `&' keywords as types.
10879
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
907 '("\\&\\(optional\\|rest\\|whole\\)\\>" . font-lock-type-face)
73ce8261c2ce Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents: 10545
diff changeset
908 )))
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
909 "Gaudy level highlighting for Lisp modes.")
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
911 (defvar lisp-font-lock-keywords lisp-font-lock-keywords-1
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
912 "Default expressions to highlight in Lisp modes.")
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
915 (defvar scheme-font-lock-keywords
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
916 (list
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
917 ;;
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
918 ;; Declarations.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
919 '("^[ \t]*(\\(define\\)\\>[ \t]*(?\\([^ \t\n\)]+\\)?"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
920 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
921 ;;
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
922 ;; Control structures.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
923 ;(make-regexp '("begin" "call-with-current-continuation" "call/cc"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
924 ; "call-with-input-file" "call-with-output-file" "case" "cond"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
925 ; "define-syntax" "do" "else" "for-each" "if" "lambda"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
926 ; "let-syntax" "let\\*?" "letrec" "letrec-syntax"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
927 ; ;; Stefan Monnier <stefan.monnier@epfl.ch> says don't bother.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
928 ; ;;"quasiquote" "quote" "unquote" "unquote-splicing"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
929 ; "map" "syntax" "syntax-rules"))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
930 (cons
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
931 (concat "(\\("
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
932 "begin\\|c\\(a\\(ll\\(-with-\\(current-continuation\\|"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
933 "input-file\\|output-file\\)\\|/cc\\)\\|se\\)\\|ond\\)\\|"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
934 "d\\(efine-syntax\\|o\\)\\|else\\|for-each\\|if\\|"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
935 "l\\(ambda\\|et\\(-syntax\\|\\*?\\|rec\\(\\|-syntax\\)\\)\\)\\|"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
936 "map\\|syntax\\(\\|-rules\\)"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
937 "\\)\\>") 1))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
938 "Default expressions to highlight in Scheme modes.")
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
939
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
940
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 (defconst c-font-lock-keywords-1 nil
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
942 "Subdued level highlighting for C modes.")
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944 (defconst c-font-lock-keywords-2 nil
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
945 "Gaudy level highlighting for C modes.")
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946
6219
d960f0463014 (c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 6093
diff changeset
947 (defconst c++-font-lock-keywords-1 nil
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
948 "Subdued level highlighting for C++ modes.")
6219
d960f0463014 (c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 6093
diff changeset
949
d960f0463014 (c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 6093
diff changeset
950 (defconst c++-font-lock-keywords-2 nil
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
951 "Gaudy level highlighting for C++ modes.")
6219
d960f0463014 (c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 6093
diff changeset
952
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
953 (let ((c-keywords
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
954 ; ("break" "continue" "do" "else" "for" "if" "return" "switch" "while")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
955 "break\\|continue\\|do\\|else\\|for\\|if\\|return\\|switch\\|while")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
956 (c-type-types
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
957 ; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
958 ; "signed" "unsigned" "short" "long" "int" "char" "float" "double"
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
959 ; "void" "volatile" "const")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
960 (concat "auto\\|c\\(har\\|onst\\)\\|double\\|e\\(num\\|xtern\\)\\|"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
961 "float\\|int\\|long\\|register\\|"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
962 "s\\(hort\\|igned\\|t\\(atic\\|ruct\\)\\)\\|typedef\\|"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
963 "un\\(ion\\|signed\\)\\|vo\\(id\\|latile\\)")) ; 6 ()s deep.
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
964 (c++-keywords
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
965 ; ("break" "continue" "do" "else" "for" "if" "return" "switch" "while"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
966 ; "asm" "catch" "delete" "new" "operator" "sizeof" "this" "throw" "try"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
967 ; "protected" "private" "public")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
968 (concat "asm\\|break\\|c\\(atch\\|ontinue\\)\\|d\\(elete\\|o\\)\\|"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
969 "else\\|for\\|if\\|new\\|operator\\|"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
970 "p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\|return\\|"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
971 "s\\(izeof\\|witch\\)\\|t\\(h\\(is\\|row\\)\\|ry\\)\\|while"))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
972 (c++-type-types
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
973 ; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
974 ; "signed" "unsigned" "short" "long" "int" "char" "float" "double"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
975 ; "void" "volatile" "const" "class" "inline" "friend" "bool"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
976 ; "virtual" "complex" "template")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
977 (concat "auto\\|bool\\|c\\(har\\|lass\\|o\\(mplex\\|nst\\)\\)\\|"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
978 "double\\|e\\(num\\|xtern\\)\\|f\\(loat\\|riend\\)\\|"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
979 "in\\(line\\|t\\)\\|long\\|register\\|"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
980 "s\\(hort\\|igned\\|t\\(atic\\|ruct\\)\\)\\|"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
981 "t\\(emplate\\|ypedef\\)\\|un\\(ion\\|signed\\)\\|"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
982 "v\\(irtual\\|o\\(id\\|latile\\)\\)")) ; 11 ()s deep.
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
983 (ctoken "[a-zA-Z0-9_:~]+"))
6093
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
984 (setq c-font-lock-keywords-1
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
985 (list
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
986 ;;
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
987 ;; Fontify filenames in #include <...> preprocessor directives.
6093
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
988 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
989 ;;
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
990 ;; Fontify function macro names.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
991 '("^#[ \t]*define[ \t]+\\(\\(\\sw+\\)(\\)" 2 font-lock-function-name-face)
6093
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
992 ;;
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
993 ;; Fontify otherwise as symbol names, and the preprocessor directive names.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
994 '("^\\(#[ \t]*[a-z]+\\)\\>[ \t]*\\(\\sw+\\)?"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
995 (1 font-lock-reference-face) (2 font-lock-variable-name-face nil t))
6093
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
996 ;;
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
997 ;; Fontify function name definitions (without type on line).
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
998 (list (concat "^\\(" ctoken "\\)[ \t]*(") 1 'font-lock-function-name-face)
6093
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
999 ))
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
1000
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
1001 (setq c-font-lock-keywords-2
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
1002 (append c-font-lock-keywords-1
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003 (list
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 ;;
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1005 ;; Fontify all storage classes and type specifiers (before declarations).
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1006 (cons (concat "\\<\\(" c-type-types "\\)\\>") 'font-lock-type-face)
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007 ;;
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1008 ;; Fontify variable/structure name declarations and definitions, or
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1009 ;; function name declarations (plus definitions with type on same line).
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1010 (list (concat "\\<\\(" c-type-types "\\)[ \t*]+"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1011 "\\(" ctoken "[ \t*]+\\)*"
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1012 "\\(" ctoken "\\)[ \t]*\\((\\)?")
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1013 9
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1014 '(if (match-beginning 10)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1015 font-lock-function-name-face
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1016 font-lock-variable-name-face))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1017 ;;
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1018 ;; Fontify function/variable name declarations at the start of the line.
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1019 ;; (Not everyone follows the GNU convention of function name at the start.)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1020 (list (concat "^" ctoken "[ \t*]+"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1021 "\\(" ctoken "[ \t*]+\\)*"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1022 "\\(" ctoken "\\)[ \t]*\\((\\)?")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1023 2
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1024 '(if (match-beginning 3)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1025 font-lock-function-name-face
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1026 font-lock-variable-name-face))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1027 ;;
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1028 ;; Fontify variable names declared with structures, or typedef names.
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1029 '("}[ \t*]*\\(\\sw+\\)[ \t]*[;,[]" 1 font-lock-variable-name-face)
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1030 ;;
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1031 ;; Fontify all builtin keywords (except case, default and goto; see below).
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1032 (concat "\\<\\(" c-keywords "\\)\\>")
6093
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
1033 ;;
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1034 ;; Fontify case/goto keywords and targets, and goto tags (incl "default:").
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1035 '("\\<\\(case\\|goto\\)\\>[ \t]*\\([^ \t\n:;]+\\)?"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1036 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1037 '("^[ \t]*\\(\\sw+\\)[ \t]*:" 1 font-lock-reference-face)
6093
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
1038 )))
6219
d960f0463014 (c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 6093
diff changeset
1039
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1040 (setq c++-font-lock-keywords-1 c-font-lock-keywords-1)
6219
d960f0463014 (c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 6093
diff changeset
1041 (setq c++-font-lock-keywords-2
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1042 (append c++-font-lock-keywords-1
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1043 (list
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1044 ;; We don't just add to the C keywords for subtle differences and speed.
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1045 ;; See the above comments for `c-font-lock-keywords-2'.
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1046 (cons (concat "\\<\\(" c++-type-types "\\)\\>") 'font-lock-type-face)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1047 (list (concat "\\<\\(" c++-type-types "\\)[ \t*&]+"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1048 "\\(" ctoken "[ \t*&]+\\)*"
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1049 "\\(" ctoken "\\)[ \t<>=!+-]*\\((\\)?")
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1050 14
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1051 '(if (match-beginning 15)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1052 font-lock-function-name-face
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1053 font-lock-variable-name-face))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1054 (list (concat "^" ctoken "[ \t*]+"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1055 "\\(" ctoken "[ \t*]+\\)*"
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1056 "\\(" ctoken "\\)[ \t<>=!+-]*\\((\\)?")
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1057 2
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1058 '(if (match-beginning 3)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1059 font-lock-function-name-face
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1060 font-lock-variable-name-face))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1061 '("}[ \t*]*\\(\\sw+\\)[ \t]*[;,[]" 1 font-lock-variable-name-face)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1062 (concat "\\<\\(" c++-keywords "\\)\\>")
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1063 '("\\<\\(case\\|goto\\)\\>[ \t]*\\([^ \t\n:;]+\\)?"
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1064 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
1065 '("^[ \t]*\\(\\sw+\\)[ \t]*:[^:]" 1 font-lock-reference-face))))
6093
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
1066 )
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
1068 (defvar c-font-lock-keywords c-font-lock-keywords-1
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
1069 "Default expressions to highlight in C mode.")
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070
12385
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
1071 (defvar c++-font-lock-keywords c++-font-lock-keywords-1
c80966dc0b60 Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents: 12268
diff changeset
1072 "Default expressions to highlight in C++ mode.")
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1074
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075 (defvar tex-font-lock-keywords
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1076 ; ;; Regexps updated with help from Ulrik Dickow <dickow@nbi.dk>.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1077 ; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1078 ; 2 font-lock-function-name-face)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1079 ; ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1080 ; 2 font-lock-reference-face)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1081 ; ;; It seems a bit dubious to use `bold' and `italic' faces since we might
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1082 ; ;; not be able to display those fonts.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1083 ; ("{\\\\bf\\([^}]+\\)}" 1 'bold keep)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1084 ; ("{\\\\\\(em\\|it\\|sl\\)\\([^}]+\\)}" 2 'italic keep)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1085 ; ("\\\\\\([a-zA-Z@]+\\|.\\)" . font-lock-keyword-face)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1086 ; ("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" 1 font-lock-function-name-face keep))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1087 ;; Rewritten and extended for LaTeX2e by Ulrik Dickow <dickow@nbi.dk>.
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
1088 '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}"
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
1089 2 font-lock-function-name-face)
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
1090 ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}"
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
1091 2 font-lock-reference-face)
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1092 ("^[ \t]*\\\\def\\\\\\(\\(\\w\\|@\\)+\\)" 1 font-lock-function-name-face)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1093 ("\\\\\\([a-zA-Z@]+\\|.\\)" . font-lock-keyword-face)
11515
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
1094 ;; It seems a bit dubious to use `bold' and `italic' faces since we might
0ebfc7701ebf Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents: 11467
diff changeset
1095 ;; not be able to display those fonts.
12813
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1096 ;; LaTeX2e: \emph{This is emphasized}.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1097 ("\\\\emph{\\([^}]+\\)}" 1 'italic keep)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1098 ;; LaTeX2e: \textbf{This is bold}, \textit{...}, \textsl{...}
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1099 ("\\\\text\\(\\(bf\\)\\|it\\|sl\\){\\([^}]+\\)}"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1100 3 (if (match-beginning 2) 'bold 'italic) keep)
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1101 ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for good tables.
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1102 ("\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)"
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1103 3 (if (match-beginning 2) 'bold 'italic) keep))
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1104 "Additional expressions to highlight in TeX modes.")
c9ed95ec05b6 Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents: 12626
diff changeset
1105
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1106 ;; Install ourselves:
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1107
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1108 (or (assq 'font-lock-mode minor-mode-alist)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1109 (setq minor-mode-alist (cons '(font-lock-mode " Font") minor-mode-alist)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1110
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
1111 ;; Provide ourselves:
7491
621c162a80db (font-lock-no-comments): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
1112
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 (provide 'font-lock)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1114
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1115 ;;; font-lock.el ends here