Mercurial > emacs
annotate lisp/font-lock.el @ 15534:7f169dd814ce
(rmail-unix-mail-delimiter):
Accept more user names, since they can be
mangled badly by modern Unix mailers (e.g. Solaris 2.5 mail.local).
Be a little more picky about dates to compensate.
Match all the digits of a year, as per RFC 1123 section 5.2.14.
(rmail-nuke-pinhead-header): Adjust to regexp renumbering in
rmail-unix-mail-delimiter.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 28 Jun 1996 07:10:30 +0000 |
parents | 5c60db96bc32 |
children | 1653d3208c05 |
rev | line source |
---|---|
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1 ;;; font-lock.el --- Electric font lock mode |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
2 |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
3 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. |
4053 | 4 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
5 ;; Author: jwz, then rms, then sm <simon@gnu.ai.mit.edu> |
4053 | 6 ;; Maintainer: FSF |
7 ;; Keywords: languages, faces | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
4053 | 25 |
26 ;;; Commentary: | |
27 | |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
28 ;; 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
|
29 ;; one face, strings in another, reserved words in another, and so on. |
4053 | 30 ;; |
31 ;; Comments will be displayed in `font-lock-comment-face'. | |
32 ;; 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
|
33 ;; Regexps are used to display selected patterns in other faces. |
4053 | 34 ;; |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
35 ;; To make the text you type be fontified, use M-x font-lock-mode RET. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
36 ;; When this minor mode is on, the faces of the current line are updated with |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
37 ;; every insertion or deletion. |
4053 | 38 ;; |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
39 ;; To turn Font Lock mode on automatically, add this to your ~/.emacs file: |
4053 | 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 ;; (add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock) |
4053 | 42 ;; |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
43 ;; Or if you want to turn Font Lock mode on in many modes: |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
44 ;; |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
45 ;; (global-font-lock-mode t) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
46 ;; |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
47 ;; Fontification for a particular mode may be available in a number of levels |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
48 ;; of decoration. The higher the level, the more decoration, but the more time |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
49 ;; it takes to fontify. See the variable `font-lock-maximum-decoration', and |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
50 ;; also the variable `font-lock-maximum-size'. Support modes for Font Lock |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
51 ;; mode can be used to speed up Font Lock mode. See `font-lock-support-mode'. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
52 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
53 ;; 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
|
54 ;; 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
|
55 ;; 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
|
56 ;; |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
57 ;; (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
|
58 ;; '(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
|
59 ;; (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
|
60 ;; |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
61 ;; 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
|
62 ;; 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
|
63 ;; 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
|
64 ;; archive.cis.ohio-state.edu for this and other functions. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
65 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
66 ;; What is fontification for? You might say, "It's to make my code look nice." |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
67 ;; I think it should be for adding information in the form of cues. These cues |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
68 ;; should provide you with enough information to both (a) distinguish between |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
69 ;; different items, and (b) identify the item meanings, without having to read |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
70 ;; the items and think about it. Therefore, fontification allows you to think |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
71 ;; less about, say, the structure of code, and more about, say, why the code |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
72 ;; doesn't work. Or maybe it allows you to think less and drift off to sleep. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
73 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
74 ;; So, here are my opinions/advice/guidelines: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
75 ;; |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
76 ;; - Highlight conceptual objects, such as function and variable names, and |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
77 ;; different objects types differently, i.e., (a) and (b) above, highlight |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
78 ;; function names differently to variable names. |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
79 ;; - Keep the faces distinct from each other as far as possible. |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
80 ;; i.e., (a) above. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
81 ;; - Use the same face for the same conceptual object, across all modes. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
82 ;; i.e., (b) above, all modes that have items that can be thought of as, say, |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
83 ;; keywords, should be highlighted with the same face, etc. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
84 ;; - Make the face attributes fit the concept as far as possible. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
85 ;; i.e., function names might be a bold colour such as blue, comments might |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
86 ;; be a bright colour such as red, character strings might be brown, because, |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
87 ;; err, strings are brown (that was not the reason, please believe me). |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
88 ;; - Don't use a non-nil OVERRIDE unless you have a good reason. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
89 ;; Only use OVERRIDE for special things that are easy to define, such as the |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
90 ;; way `...' quotes are treated in strings and comments in Emacs Lisp mode. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
91 ;; Don't use it to, say, highlight keywords in commented out code or strings. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
92 ;; - Err, that's it. |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
93 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
94 ;; User variables. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
95 |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
96 (defvar font-lock-verbose (* 0 1024) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
97 "*If non-nil, means show status messages for buffer fontification. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
98 If a number, only buffers greater than this size have fontification messages.") |
4053 | 99 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
100 ;;;###autoload |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
101 (defvar font-lock-maximum-decoration nil |
14780
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
102 "*Maximum decoration level for fontification. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
103 If nil, use the default decoration (typically the minimum available). |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
104 If t, use the maximum decoration available. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
105 If a number, use that level of decoration (or if not available the maximum). |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
106 If a list, each element should be a cons pair of the form (MAJOR-MODE . LEVEL), |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
107 where MAJOR-MODE is a symbol or t (meaning the default). For example: |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
108 ((c-mode . t) (c++-mode . 2) (t . 1)) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
109 means use the maximum decoration available for buffers in C mode, level 2 |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
110 decoration for buffers in C++ mode, and level 1 decoration otherwise.") |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
111 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
112 ;;;###autoload |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
113 (defvar font-lock-maximum-size (* 250 1024) |
14780
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
114 "*Maximum size of a buffer for buffer fontification. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
115 Only buffers less than this can be fontified when Font Lock mode is turned on. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
116 If nil, means size is irrelevant. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
117 If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE), |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
118 where MAJOR-MODE is a symbol or t (meaning the default). For example: |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
119 ((c-mode . 256000) (c++-mode . 256000) (rmail-mode . 1048576)) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
120 means that the maximum size is 250K for buffers in C or C++ modes, one megabyte |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
121 for buffers in Rmail mode, and size is irrelevant otherwise.") |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
122 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
123 ;; Fontification variables: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
124 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
125 (defvar font-lock-comment-face 'font-lock-comment-face |
4053 | 126 "Face to use for comments.") |
127 | |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
128 (defvar font-lock-string-face 'font-lock-string-face |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
129 "Face to use for strings.") |
4053 | 130 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
131 (defvar font-lock-keyword-face 'font-lock-keyword-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
132 "Face to use for keywords.") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
133 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
134 (defvar font-lock-function-name-face 'font-lock-function-name-face |
4053 | 135 "Face to use for function names.") |
136 | |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
137 (defvar font-lock-variable-name-face 'font-lock-variable-name-face |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
138 "Face to use for variable names.") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
139 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
140 (defvar font-lock-type-face 'font-lock-type-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
141 "Face to use for type names.") |
4053 | 142 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
143 (defvar font-lock-reference-face 'font-lock-reference-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
144 "Face to use for reference names.") |
4053 | 145 |
146 (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
|
147 "*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
|
148 Each element should be of the form: |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
149 |
11515
0ebfc7701ebf
Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents:
11467
diff
changeset
|
150 MATCHER |
0ebfc7701ebf
Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents:
11467
diff
changeset
|
151 (MATCHER . MATCH) |
0ebfc7701ebf
Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents:
11467
diff
changeset
|
152 (MATCHER . FACENAME) |
0ebfc7701ebf
Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents:
11467
diff
changeset
|
153 (MATCHER . HIGHLIGHT) |
0ebfc7701ebf
Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents:
11467
diff
changeset
|
154 (MATCHER HIGHLIGHT ...) |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
155 (eval . FORM) |
4053 | 156 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
157 where HIGHLIGHT should be either MATCH-HIGHLIGHT or MATCH-ANCHORED. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
158 |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
159 FORM is an expression, whose value should be a keyword element, evaluated when |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
160 the keyword is (first) used in a buffer. This feature can be used to provide a |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
161 keyword that can only be generated when Font Lock mode is actually turned on. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
162 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
163 For highlighting single items, typically only MATCH-HIGHLIGHT is required. |
13982 | 164 However, if an item or (typically) items are to be highlighted following the |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
165 instance of another item (the anchor) then MATCH-ANCHORED may be required. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
166 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
167 MATCH-HIGHLIGHT should be of the form: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
168 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
169 (MATCH FACENAME OVERRIDE LAXMATCH) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
170 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
171 Where MATCHER can be either the regexp to search for, or the function name to |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
172 call to make the search (called with one argument, the limit of the search). |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
173 MATCH is the subexpression of MATCHER to be highlighted. FACENAME is an |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
174 expression whose value is the face name to use. FACENAME's default attributes |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
175 may be defined in `font-lock-face-attributes'. |
4053 | 176 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
177 OVERRIDE and LAXMATCH are flags. If OVERRIDE is t, existing fontification may |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
178 be overwritten. If `keep', only parts not already fontified are highlighted. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
179 If `prepend' or `append', existing fontification is merged with the new, in |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
180 which the new or existing fontification, respectively, takes precedence. |
13982 | 181 If LAXMATCH is non-nil, no error is signaled if there is no MATCH in MATCHER. |
4053 | 182 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
183 For example, an element of the form highlights (if not already highlighted): |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
184 |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
185 \"\\\\\\=<foo\\\\\\=>\" Discrete occurrences of \"foo\" in the value of the |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
186 variable `font-lock-keyword-face'. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
187 (\"fu\\\\(bar\\\\)\" . 1) Substring \"bar\" within all occurrences of \"fubar\" in |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
188 the value of `font-lock-keyword-face'. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
189 (\"fubar\" . fubar-face) Occurrences of \"fubar\" in the value of `fubar-face'. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
190 (\"foo\\\\|bar\" 0 foo-bar-face t) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
191 Occurrences of either \"foo\" or \"bar\" in the value |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
192 of `foo-bar-face', even if already highlighted. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
193 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
194 MATCH-ANCHORED should be of the form: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
195 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
196 (MATCHER PRE-MATCH-FORM POST-MATCH-FORM MATCH-HIGHLIGHT ...) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
197 |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
198 Where MATCHER is as for MATCH-HIGHLIGHT with one exception. The limit of the |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
199 search is currently guaranteed to be (no greater than) the end of the line. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
200 PRE-MATCH-FORM and POST-MATCH-FORM are evaluated before the first, and after |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
201 the last, instance MATCH-ANCHORED's MATCHER is used. Therefore they can be |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
202 used to initialise before, and cleanup after, MATCHER is used. Typically, |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
203 PRE-MATCH-FORM is used to move to some position relative to the original |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
204 MATCHER, before starting with MATCH-ANCHORED's MATCHER. POST-MATCH-FORM might |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
205 be used to move, before resuming with MATCH-ANCHORED's parent's MATCHER. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
206 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
207 For example, an element of the form highlights (if not already highlighted): |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
208 |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
209 (\"\\\\\\=<anchor\\\\\\=>\" (0 anchor-face) (\"\\\\\\=<item\\\\\\=>\" nil nil (0 item-face))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
210 |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
211 Discrete occurrences of \"anchor\" in the value of `anchor-face', and subsequent |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
212 discrete occurrences of \"item\" (on the same line) in the value of `item-face'. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
213 (Here PRE-MATCH-FORM and POST-MATCH-FORM are nil. Therefore \"item\" is |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
214 initially searched for starting from the end of the match of \"anchor\", and |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
215 searching for subsequent instance of \"anchor\" resumes from where searching |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
216 for \"item\" concluded.) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
217 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
218 Note that the MATCH-ANCHORED feature is experimental; in the future, we may |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
219 replace it with other ways of providing this functionality. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
220 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
221 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
|
222 \\[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
|
223 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
|
224 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
225 Be very careful composing regexps for this list; |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
226 the wrong pattern can dramatically slow things down!") |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
227 (make-variable-buffer-local 'font-lock-keywords) |
4053 | 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-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
|
230 "If set by a major mode, should be the defaults for Font Lock mode. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
231 The value should be like the `cdr' of an item in `font-lock-defaults-alist'.") |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
232 |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
233 (defvar font-lock-defaults-alist |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
234 (let (;; For C and Lisp modes we use `beginning-of-defun', rather than nil, |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
235 ;; for SYNTAX-BEGIN. Thus the calculation of the cache is usually |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
236 ;; faster but 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
|
237 (c-mode-defaults |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
238 '((c-font-lock-keywords c-font-lock-keywords-1 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
239 c-font-lock-keywords-2 c-font-lock-keywords-3) |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
240 nil nil ((?_ . "w")) beginning-of-defun |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
241 (font-lock-mark-block-function . mark-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
|
242 (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
|
243 '((c++-font-lock-keywords c++-font-lock-keywords-1 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
244 c++-font-lock-keywords-2 c++-font-lock-keywords-3) |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
245 nil nil ((?_ . "w") (?~ . "w")) beginning-of-defun |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
246 (font-lock-mark-block-function . mark-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
|
247 (lisp-mode-defaults |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
248 '((lisp-font-lock-keywords |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
249 lisp-font-lock-keywords-1 lisp-font-lock-keywords-2) |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
250 nil nil (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
251 (font-lock-mark-block-function . mark-defun))) |
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
|
252 (scheme-mode-defaults |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
253 '(scheme-font-lock-keywords |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
254 nil t (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
255 (font-lock-mark-block-function . mark-defun))) |
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
|
256 ;; For TeX modes we could use `backward-paragraph' for the same reason. |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
257 ;; But we don't, because paragraph breaks are arguably likely enough to |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
258 ;; occur within a genuine syntactic block to make it too risky. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
259 ;; However, we do specify a MARK-BLOCK function as that cannot result |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
260 ;; in a mis-fontification even if it might not fontify enough. --sm. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
261 (tex-mode-defaults '(tex-font-lock-keywords nil nil ((?$ . "\"")) nil |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
262 (font-lock-mark-block-function . mark-paragraph))) |
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
|
263 ) |
11515
0ebfc7701ebf
Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents:
11467
diff
changeset
|
264 (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
|
265 (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
|
266 (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
|
267 (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
|
268 (cons 'c-mode c-mode-defaults) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
269 (cons 'elec-c-mode c-mode-defaults) |
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
|
270 (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
|
271 (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
|
272 (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
|
273 (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
|
274 (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
|
275 (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
|
276 (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
|
277 (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
|
278 (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
|
279 (cons 'tex-mode tex-mode-defaults))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
280 "Alist of default major mode and 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
|
281 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
|
282 |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
283 (MAJOR-MODE . (KEYWORDS KEYWORDS-ONLY CASE-FOLD SYNTAX-ALIST SYNTAX-BEGIN |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
284 ...)) |
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
|
285 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
286 where MAJOR-MODE is a symbol. KEYWORDS may be a symbol (a variable or function |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
287 whose value is the keywords to use for fontification) or a list of symbols. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
288 If KEYWORDS-ONLY is non-nil, syntactic fontification (strings and comments) is |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
289 not performed. If CASE-FOLD is non-nil, the case of the keywords is ignored |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
290 when fontifying. If SYNTAX-ALIST is non-nil, it should be a list of cons pairs |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
291 of the form (CHAR-OR-STRING . STRING) used to set the local Font Lock syntax |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
292 table, for keyword and syntactic fontification (see `modify-syntax-entry'). |
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
|
293 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
294 If SYNTAX-BEGIN is non-nil, it should be a function with no args used to move |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
295 backwards outside any enclosing syntactic block, for syntactic fontification. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
296 Typical values are `beginning-of-line' (i.e., the start of the line is known to |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
297 be outside a syntactic block), or `beginning-of-defun' for programming modes or |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
298 `backward-paragraph' for textual modes (i.e., the mode-dependent function is |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
299 known to move outside a syntactic block). If nil, the beginning of the buffer |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
300 is used as a position outside of a syntactic block, in the worst case. |
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
|
301 |
c9ed95ec05b6
Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
12626
diff
changeset
|
302 These item elements are used by Font Lock mode to set the variables |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
303 `font-lock-keywords', `font-lock-keywords-only', |
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
|
304 `font-lock-keywords-case-fold-search', `font-lock-syntax-table' and |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
305 `font-lock-beginning-of-syntax-function', respectively. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
306 |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
307 Further item elements are alists of the form (VARIABLE . VALUE) and are in no |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
308 particular order. Each VARIABLE is made buffer-local before set to VALUE. |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
309 |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
310 Currently, appropriate variables include `font-lock-mark-block-function'. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
311 If this is non-nil, it should be a function with no args used to mark any |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
312 enclosing block of text, for fontification via \\[font-lock-fontify-block]. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
313 Typical values are `mark-defun' for programming modes or `mark-paragraph' for |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
314 textual modes (i.e., the mode-dependent function is known to put point and mark |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
315 around a text block relevant to that mode). |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
316 |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
317 Other variables include those for buffer-specialised fontification functions, |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
318 `font-lock-fontify-buffer-function', `font-lock-unfontify-buffer-function', |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
319 `font-lock-fontify-region-function', `font-lock-unfontify-region-function', |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
320 `font-lock-maximum-size' and `font-lock-inhibit-thing-lock'.") |
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
|
321 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
322 (defvar font-lock-keywords-only 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
|
323 "*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
|
324 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
|
325 |
4053 | 326 (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
|
327 "*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
|
328 This is normally set via `font-lock-defaults'.") |
4053 | 329 |
8457
c0492d7043b2
(font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents:
7915
diff
changeset
|
330 (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
|
331 "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
|
332 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
|
333 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
|
334 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
335 ;; If this is nil, we only use the beginning of the buffer if we can't use |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
336 ;; `font-lock-cache-position' and `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
|
337 (defvar font-lock-beginning-of-syntax-function nil |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
338 "*Non-nil means use this function to move back outside of a syntactic block. |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
339 When called with no args it should leave point at the beginning of any |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
340 enclosing syntactic block. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
341 If this is nil, the beginning of the buffer is used (in the worst case). |
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
|
342 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
|
343 |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
344 (defvar font-lock-mark-block-function nil |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
345 "*Non-nil means use this function to mark a block of text. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
346 When called with no args it should leave point at the beginning of any |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
347 enclosing textual block and mark at the end. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
348 This is normally set via `font-lock-defaults'.") |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
349 |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
350 (defvar font-lock-fontify-buffer-function 'font-lock-default-fontify-buffer |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
351 "Function to use for fontifying the buffer. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
352 This is normally set via `font-lock-defaults'.") |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
353 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
354 (defvar font-lock-unfontify-buffer-function 'font-lock-default-unfontify-buffer |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
355 "Function to use for unfontifying the buffer. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
356 This is used when turning off Font Lock mode. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
357 This is normally set via `font-lock-defaults'.") |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
358 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
359 (defvar font-lock-fontify-region-function 'font-lock-default-fontify-region |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
360 "Function to use for fontifying a region. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
361 It should take two args, the beginning and end of the region, and an optional |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
362 third arg VERBOSE. If non-nil, the function should print status messages. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
363 This is normally set via `font-lock-defaults'.") |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
364 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
365 (defvar font-lock-unfontify-region-function 'font-lock-default-unfontify-region |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
366 "Function to use for unfontifying a region. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
367 It should take two args, the beginning and end of the region. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
368 This is normally set via `font-lock-defaults'.") |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
369 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
370 (defvar font-lock-inhibit-thing-lock nil |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
371 "List of Font Lock mode related modes that should not be turned on. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
372 Currently, valid mode names as `fast-lock-mode' and `lazy-lock-mode'. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
373 This is normally set via `font-lock-defaults'.") |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
374 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
375 (defvar font-lock-mode nil) ; For the modeline. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
376 (defvar font-lock-fontified nil) ; Whether we have fontified the buffer. |
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
|
377 |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
378 ;;;###autoload |
4053 | 379 (defvar font-lock-mode-hook nil |
380 "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
|
381 |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
382 ;; Font Lock mode. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
383 |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
384 (eval-when-compile |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
385 ;; We don't do this at the top-level as we only use non-autoloaded macros. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
386 (require 'cl)) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
387 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
388 ;;;###autoload |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
389 (defun font-lock-mode (&optional arg) |
13452
5aab5c1f2c33
Oops; left a note in a doc-string.
Simon Marshall <simon@gnu.org>
parents:
13440
diff
changeset
|
390 "Toggle Font Lock mode. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
391 With arg, turn Font Lock mode on if and only if arg is positive. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
392 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
393 When Font Lock mode is enabled, text is fontified as you type it: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
394 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
395 - Comments are displayed in `font-lock-comment-face'; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
396 - Strings are displayed in `font-lock-string-face'; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
397 - Certain other expressions are displayed in other faces according to the |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
398 value of the variable `font-lock-keywords'. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
399 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
400 You can enable Font Lock mode in any major mode automatically by turning on in |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
401 the major mode's hook. For example, put in your ~/.emacs: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
402 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
403 (add-hook 'c-mode-hook 'turn-on-font-lock) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
404 |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
405 Alternatively, you can use Global Font Lock mode to automagically turn on Font |
15500
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
406 Lock mode in buffers whose major mode supports it and whose major mode is one |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
407 of `font-lock-global-modes'. For example, put in your ~/.emacs: |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
408 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
409 (global-font-lock-mode t) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
410 |
15500
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
411 There are a number of support modes that may be used to speed up Font Lock mode |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
412 in various ways, specified via the variable `font-lock-support-mode'. Where |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
413 major modes support different levels of fontification, you can use the variable |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
414 `font-lock-maximum-decoration' to specify which level you generally prefer. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
415 When you turn Font Lock mode on/off the buffer is fontified/defontified, though |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
416 fontification occurs only if the buffer is less than `font-lock-maximum-size'. |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
417 |
15500
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
418 For example, to specify that Font Lock mode use use Lazy Lock mode as a support |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
419 mode and use maximum levels of fontification, put in your ~/.emacs: |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
420 |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
421 (setq font-lock-support-mode 'lazy-lock-mode) |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
422 (setq font-lock-maximum-decoration t) |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
423 |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
424 To fontify a buffer, without turning on Font Lock mode and regardless of buffer |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
425 size, you can use \\[font-lock-fontify-buffer]. |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
426 |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
427 To fontify a block (the function or paragraph containing point, or a number of |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
428 lines around point), perhaps because modification on the current line caused |
15500
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
429 syntactic change on other lines, you can use \\[font-lock-fontify-block]. |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
430 |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
431 The default Font Lock mode faces and their attributes are defined in the |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
432 variable `font-lock-face-attributes', and Font Lock mode default settings in |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
433 the variable `font-lock-defaults-alist'. You can set your own default settings |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
434 for some mode, by setting a buffer local value for `font-lock-defaults', via |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
435 its mode hook." |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
436 (interactive "P") |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
437 ;; Don't turn on Font Lock mode if we don't have a display (we're running a |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
438 ;; batch job) or if the buffer is invisible (the name starts with a space). |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
439 (let ((on-p (and (not noninteractive) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
440 (not (eq (aref (buffer-name) 0) ?\ )) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
441 (if arg |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
442 (> (prefix-numeric-value arg) 0) |
14708
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
443 (not font-lock-mode))))) |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
444 (set (make-local-variable 'font-lock-mode) on-p) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
445 ;; Turn on Font Lock mode. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
446 (when on-p |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
447 (make-local-hook 'after-change-functions) |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
448 (add-hook 'after-change-functions 'font-lock-after-change-function nil t) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
449 (font-lock-set-defaults) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
450 (font-lock-turn-on-thing-lock) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
451 (run-hooks 'font-lock-mode-hook) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
452 ;; Fontify the buffer if we have to. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
453 (let ((max-size (font-lock-value-in-major-mode font-lock-maximum-size))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
454 (cond (font-lock-fontified |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
455 nil) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
456 ((or (null max-size) (> max-size (buffer-size))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
457 (font-lock-fontify-buffer)) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
458 (font-lock-verbose |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
459 (message "Fontifying %s...buffer too big" (buffer-name)))))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
460 ;; Turn off Font Lock mode. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
461 (when (not on-p) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
462 (remove-hook 'after-change-functions 'font-lock-after-change-function t) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
463 (font-lock-unfontify-buffer) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
464 (font-lock-turn-off-thing-lock) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
465 (font-lock-unset-defaults)) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
466 (force-mode-line-update))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
467 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
468 ;;;###autoload |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
469 (defun turn-on-font-lock () |
14516
9360c3107669
Moved `supported' from turn-on-font-lock-if-supported to turn-on-font-lock.
Simon Marshall <simon@gnu.org>
parents:
14468
diff
changeset
|
470 "Turn on Font Lock mode conditionally. |
15500
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
471 Turn on only if the terminal can display it." |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
472 (when window-system |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
473 (font-lock-mode t))) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
474 |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
475 ;; Global Font Lock mode. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
476 ;; |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
477 ;; A few people have hassled in the past for a way to make it easier to turn on |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
478 ;; Font Lock mode, without the user needing to know for which modes s/he has to |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
479 ;; turn it on, perhaps the same way hilit19.el/hl319.el does. I've always |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
480 ;; balked at that way, as I see it as just re-moulding the same problem in |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
481 ;; another form. That is; some person would still have to keep track of which |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
482 ;; modes (which may not even be distributed with Emacs) support Font Lock mode. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
483 ;; The list would always be out of date. And that person might have to be me. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
484 |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
485 ;; Implementation. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
486 ;; |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
487 ;; In a previous discussion the following hack came to mind. It is a gross |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
488 ;; hack, but it generally works. We use the convention that major modes start |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
489 ;; by calling the function `kill-all-local-variables', which in turn runs |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
490 ;; functions on the hook variable `change-major-mode-hook'. We attach our |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
491 ;; function `font-lock-change-major-mode' to that hook. Of course, when this |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
492 ;; hook is run, the major mode is in the process of being changed and we do not |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
493 ;; know what the final major mode will be. So, `font-lock-change-major-mode' |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
494 ;; only (a) notes the name of the current buffer, and (b) adds our function |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
495 ;; `turn-on-font-lock-if-enabled' to the hook variables `find-file-hooks' and |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
496 ;; `post-command-hook' (for buffers that are not visiting files). By the time |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
497 ;; the functions on the first of these hooks to be run are run, the new major |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
498 ;; mode is assumed to be in place. This way we get a Font Lock function run |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
499 ;; when a major mode is turned on, without knowing major modes or their hooks. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
500 ;; |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
501 ;; Naturally this requires that (a) major modes run `kill-all-local-variables', |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
502 ;; as they are supposed to do, and (b) the major mode is in place after the |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
503 ;; file is visited or the command that ran `kill-all-local-variables' has |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
504 ;; finished, whichever the sooner. Arguably, any major mode that does not |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
505 ;; follow the convension (a) is broken, and I can't think of any reason why (b) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
506 ;; would not be met (except `gnudoit' on non-files). However, it is not clean. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
507 ;; |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
508 ;; Probably the cleanest solution is to have each major mode function run some |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
509 ;; hook, e.g., `major-mode-hook', but maybe implementing that change is |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
510 ;; impractical. I am personally against making `setq' a macro or be advised, |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
511 ;; or have a special function such as `set-major-mode', but maybe someone can |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
512 ;; come up with another solution? |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
513 |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
514 ;; User interface. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
515 ;; |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
516 ;; Although Global Font Lock mode is a pseudo-mode, I think that the user |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
517 ;; interface should conform to the usual Emacs convention for modes, i.e., a |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
518 ;; command to toggle the feature (`global-font-lock-mode') with a variable for |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
519 ;; finer control of the mode's behaviour (`font-lock-global-modes'). |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
520 ;; |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
521 ;; I don't think it is better that the feature be enabled via a variable, since |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
522 ;; it does not conform to the usual convention. I don't think the feature |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
523 ;; should be enabled by loading font-lock.el, since other mechanisms such as |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
524 ;; M-x font-lock-mode RET or (add-hook 'c-mode-hook 'turn-on-font-lock) would |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
525 ;; cause Font Lock mode to be turned on everywhere, and it is not intuitive or |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
526 ;; informative because loading a file tells you nothing about the feature or |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
527 ;; how to control it. It would be contrary to the Principle of Least Surprise. |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
528 |
14780
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
529 (defvar font-lock-buffers nil) ; For remembering buffers. |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
530 (defvar global-font-lock-mode nil) |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
531 |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
532 ;;;###autoload |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
533 (defvar font-lock-global-modes t |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
534 "*Modes for which Font Lock mode is automagically turned on. |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
535 Global Font Lock mode is controlled by the `global-font-lock-mode' command. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
536 If nil, means no modes have Font Lock mode automatically turned on. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
537 If t, all modes that support Font Lock mode have it automatically turned on. |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
538 If a list, it should be a list of `major-mode' symbol names for which Font Lock |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
539 mode should be automatically turned on. The sense of the list is negated if it |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
540 begins with `not'. For example: |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
541 (c-mode c++-mode) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
542 means that Font Lock mode is turned on for buffers in C and C++ modes only.") |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
543 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
544 ;;;###autoload |
14708
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
545 (defun global-font-lock-mode (&optional arg message) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
546 "Toggle Global Font Lock mode. |
14708
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
547 With prefix ARG, turn Global Font Lock mode on if and only if ARG is positive. |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
548 Displays a message saying whether the mode is on or off if MESSAGE is non-nil. |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
549 Returns the new status of Global Font Lock mode (non-nil means on). |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
550 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
551 When Global Font Lock mode is enabled, Font Lock mode is automagically |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
552 turned on in a buffer if its major mode is one of `font-lock-global-modes'." |
14708
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
553 (interactive "P\np") |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
554 (let ((off-p (if arg |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
555 (<= (prefix-numeric-value arg) 0) |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
556 global-font-lock-mode))) |
14708
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
557 (if off-p |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
558 (remove-hook 'find-file-hooks 'turn-on-font-lock-if-enabled) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
559 (add-hook 'find-file-hooks 'turn-on-font-lock-if-enabled) |
14708
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
560 (add-hook 'post-command-hook 'turn-on-font-lock-if-enabled) |
14780
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
561 (setq font-lock-buffers (buffer-list))) |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
562 (when message |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
563 (message "Global Font Lock mode is now %s." (if off-p "OFF" "ON"))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
564 (setq global-font-lock-mode (not off-p)))) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
565 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
566 (defun font-lock-change-major-mode () |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
567 ;; Turn off Font Lock mode if it's on. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
568 (when font-lock-mode |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
569 (font-lock-mode nil)) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
570 ;; Gross hack warning: Delicate readers should avert eyes now. |
14708
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
571 ;; Something is running `kill-all-local-variables', which generally means the |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
572 ;; major mode is being changed. Run `turn-on-font-lock-if-enabled' after the |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
573 ;; file is visited or the current command has finished. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
574 (when global-font-lock-mode |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
575 (add-hook 'post-command-hook 'turn-on-font-lock-if-enabled) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
576 (add-to-list 'font-lock-buffers (current-buffer)))) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
577 |
14516
9360c3107669
Moved `supported' from turn-on-font-lock-if-supported to turn-on-font-lock.
Simon Marshall <simon@gnu.org>
parents:
14468
diff
changeset
|
578 (defun turn-on-font-lock-if-enabled () |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
579 ;; Gross hack warning: Delicate readers should avert eyes now. |
15500
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
580 ;; Turn on Font Lock mode if it's supported by the major mode and enabled by |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
581 ;; the user. |
14516
9360c3107669
Moved `supported' from turn-on-font-lock-if-supported to turn-on-font-lock.
Simon Marshall <simon@gnu.org>
parents:
14468
diff
changeset
|
582 (remove-hook 'post-command-hook 'turn-on-font-lock-if-enabled) |
14780
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
583 (while font-lock-buffers |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
584 (if (buffer-live-p (car font-lock-buffers)) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
585 (save-excursion |
14780
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
586 (set-buffer (car font-lock-buffers)) |
15500
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
587 (if (and (or font-lock-defaults |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
588 (assq major-mode font-lock-defaults-alist)) |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
589 (or (eq font-lock-global-modes t) |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
590 (if (eq (car-safe font-lock-global-modes) 'not) |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
591 (not (memq major-mode (cdr font-lock-global-modes))) |
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
592 (memq major-mode font-lock-global-modes)))) |
14708
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
593 (let (inhibit-quit) |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
594 (turn-on-font-lock))))) |
14780
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
595 (setq font-lock-buffers (cdr font-lock-buffers)))) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
596 |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
597 (add-hook 'change-major-mode-hook 'font-lock-change-major-mode) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
598 |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
599 ;; End of Global Font Lock mode. |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
600 |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
601 ;; Font Lock Support mode. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
602 ;; |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
603 ;; This is the code used to interface font-lock.el with any of its add-on |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
604 ;; packages, and provide the user interface. Packages that have their own |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
605 ;; local buffer fontification functions (see below) may have to call |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
606 ;; `font-lock-after-fontify-buffer' and/or `font-lock-after-unfontify-buffer' |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
607 ;; themselves. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
608 |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
609 ;;;###autoload |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
610 (defvar font-lock-support-mode nil |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
611 "*Support mode for Font Lock mode. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
612 Support modes speed up Font Lock mode by being choosy about when fontification |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
613 occurs. Known support modes are Fast Lock mode (symbol `fast-lock-mode') and |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
614 Lazy Lock mode (symbol `lazy-lock-mode'). See those modes for more info. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
615 If nil, means support for Font Lock mode is never performed. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
616 If a symbol, use that support mode. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
617 If a list, each element should be of the form (MAJOR-MODE . SUPPORT-MODE), |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
618 where MAJOR-MODE is a symbol or t (meaning the default). For example: |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
619 ((c-mode . fast-lock-mode) (c++-mode . fast-lock-mode) (t . lazy-lock-mode)) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
620 means that Fast Lock mode is used to support Font Lock mode for buffers in C or |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
621 C++ modes, and Lazy Lock mode is used to support Font Lock mode otherwise. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
622 |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
623 The value of this variable is used when Font Lock mode is turned on.") |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
624 |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
625 (defun font-lock-turn-on-thing-lock () |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
626 (let ((thing-mode (font-lock-value-in-major-mode font-lock-support-mode))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
627 (cond ((eq thing-mode 'fast-lock-mode) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
628 (fast-lock-mode t)) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
629 ((eq thing-mode 'lazy-lock-mode) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
630 (lazy-lock-mode t))))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
631 |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
632 (defvar fast-lock-mode nil) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
633 (defvar lazy-lock-mode nil) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
634 |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
635 (defun font-lock-turn-off-thing-lock () |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
636 (cond (fast-lock-mode |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
637 (fast-lock-mode nil)) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
638 (lazy-lock-mode |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
639 (lazy-lock-mode nil)))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
640 |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
641 (defun font-lock-after-fontify-buffer () |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
642 (cond (fast-lock-mode |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
643 (fast-lock-after-fontify-buffer)) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
644 (lazy-lock-mode |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
645 (lazy-lock-after-fontify-buffer)))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
646 |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
647 (defun font-lock-after-unfontify-buffer () |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
648 (cond (fast-lock-mode |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
649 (fast-lock-after-unfontify-buffer)) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
650 (lazy-lock-mode |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
651 (lazy-lock-after-unfontify-buffer)))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
652 |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
653 ;; End of Font Lock Support mode. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
654 |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
655 ;; Fontification functions. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
656 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
657 ;;;###autoload |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
658 (defun font-lock-fontify-buffer () |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
659 "Fontify the current buffer the way `font-lock-mode' would." |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
660 (interactive) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
661 (let ((font-lock-verbose (or font-lock-verbose (interactive-p)))) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
662 (funcall font-lock-fontify-buffer-function))) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
663 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
664 (defun font-lock-unfontify-buffer () |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
665 (funcall font-lock-unfontify-buffer-function)) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
666 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
667 (defun font-lock-fontify-region (beg end &optional loudly) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
668 (funcall font-lock-fontify-region-function beg end loudly)) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
669 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
670 (defun font-lock-unfontify-region (beg end) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
671 (funcall font-lock-unfontify-region-function beg end)) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
672 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
673 (defun font-lock-default-fontify-buffer () |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
674 (let ((verbose (if (numberp font-lock-verbose) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
675 (> (buffer-size) font-lock-verbose) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
676 font-lock-verbose))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
677 (if verbose (message "Fontifying %s..." (buffer-name))) |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
678 ;; Make sure we have the right `font-lock-keywords' etc. |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
679 (if (not font-lock-mode) (font-lock-set-defaults)) |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
680 ;; Make sure we fontify etc. in the whole buffer. |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
681 (save-restriction |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
682 (widen) |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
683 (condition-case nil |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
684 (save-excursion |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
685 (save-match-data |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
686 (font-lock-fontify-region (point-min) (point-max) verbose) |
14374
e2423983be05
Support for local fontification.
Simon Marshall <simon@gnu.org>
parents:
14365
diff
changeset
|
687 (font-lock-after-fontify-buffer) |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
688 (setq font-lock-fontified t))) |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
689 ;; We don't restore the old fontification, so it's best to unfontify. |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
690 (quit (font-lock-unfontify-buffer)))) |
15442
b4c8360e450e
(global-font-lock-mode): Set up find-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents:
14780
diff
changeset
|
691 (if verbose (message "Fontifying %s...%s" (buffer-name) |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
692 (if font-lock-fontified "done" "aborted"))))) |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
693 |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
694 (defun font-lock-default-unfontify-buffer () |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
695 (save-restriction |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
696 (widen) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
697 (font-lock-unfontify-region (point-min) (point-max)) |
14374
e2423983be05
Support for local fontification.
Simon Marshall <simon@gnu.org>
parents:
14365
diff
changeset
|
698 (font-lock-after-unfontify-buffer) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
699 (setq font-lock-fontified nil))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
700 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
701 ;; We use this wrapper. However, `font-lock-fontify-region' used to be the |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
702 ;; name used for `font-lock-fontify-syntactically-region', so a change isn't |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
703 ;; back-compatible. But you shouldn't be calling these directly, should you? |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
704 (defun font-lock-default-fontify-region (beg end loudly) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
705 (let ((modified (buffer-modified-p)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
706 (buffer-undo-list t) (inhibit-read-only t) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
707 (old-syntax-table (syntax-table)) |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
708 before-change-functions after-change-functions |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
709 buffer-file-name buffer-file-truename) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
710 (unwind-protect |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
711 (save-restriction |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
712 (widen) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
713 ;; Use the fontification syntax table, if any. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
714 (if font-lock-syntax-table (set-syntax-table font-lock-syntax-table)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
715 ;; Now do the fontification. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
716 (if font-lock-keywords-only |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
717 (font-lock-unfontify-region beg end) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
718 (font-lock-fontify-syntactically-region beg end loudly)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
719 (font-lock-fontify-keywords-region beg end loudly)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
720 ;; Clean up. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
721 (set-syntax-table old-syntax-table) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
722 (and (not modified) (buffer-modified-p) (set-buffer-modified-p nil))))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
723 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
724 ;; The following must be rethought, since keywords can override fontification. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
725 ; ;; Now scan for keywords, but not if we are inside a comment now. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
726 ; (or (and (not font-lock-keywords-only) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
727 ; (let ((state (parse-partial-sexp beg end nil nil |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
728 ; font-lock-cache-state))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
729 ; (or (nth 4 state) (nth 7 state)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
730 ; (font-lock-fontify-keywords-region beg end)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
731 |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
732 (defun font-lock-default-unfontify-region (beg end) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
733 (let ((modified (buffer-modified-p)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
734 (buffer-undo-list t) (inhibit-read-only t) |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
735 before-change-functions after-change-functions |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
736 buffer-file-name buffer-file-truename) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
737 (remove-text-properties beg end '(face nil)) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
738 (and (not modified) (buffer-modified-p) (set-buffer-modified-p nil)))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
739 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
740 ;; Called when any modification is made to buffer text. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
741 (defun font-lock-after-change-function (beg end old-len) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
742 (save-excursion |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
743 (save-match-data |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
744 ;; Rescan between start of line from `beg' and start of line after `end'. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
745 (font-lock-fontify-region |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
746 (progn (goto-char beg) (beginning-of-line) (point)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
747 (progn (goto-char end) (forward-line 1) (point)))))) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
748 |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
749 (defun font-lock-fontify-block (&optional arg) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
750 "Fontify some lines the way `font-lock-fontify-buffer' would. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
751 The lines could be a function or paragraph, or a specified number of lines. |
14516
9360c3107669
Moved `supported' from turn-on-font-lock-if-supported to turn-on-font-lock.
Simon Marshall <simon@gnu.org>
parents:
14468
diff
changeset
|
752 If ARG is given, fontify that many lines before and after point, or 16 lines if |
9360c3107669
Moved `supported' from turn-on-font-lock-if-supported to turn-on-font-lock.
Simon Marshall <simon@gnu.org>
parents:
14468
diff
changeset
|
753 no ARG is given and `font-lock-mark-block-function' is nil. |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
754 If `font-lock-mark-block-function' non-nil and no ARG is given, it is used to |
14516
9360c3107669
Moved `supported' from turn-on-font-lock-if-supported to turn-on-font-lock.
Simon Marshall <simon@gnu.org>
parents:
14468
diff
changeset
|
755 delimit the region to fontify." |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
756 (interactive "P") |
14516
9360c3107669
Moved `supported' from turn-on-font-lock-if-supported to turn-on-font-lock.
Simon Marshall <simon@gnu.org>
parents:
14468
diff
changeset
|
757 (let (font-lock-beginning-of-syntax-function deactivate-mark) |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
758 ;; Make sure we have the right `font-lock-keywords' etc. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
759 (if (not font-lock-mode) (font-lock-set-defaults)) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
760 (save-excursion |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
761 (save-match-data |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
762 (condition-case error-data |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
763 (if (or arg (not font-lock-mark-block-function)) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
764 (let ((lines (if arg (prefix-numeric-value arg) 16))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
765 (font-lock-fontify-region |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
766 (save-excursion (forward-line (- lines)) (point)) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
767 (save-excursion (forward-line lines) (point)))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
768 (funcall font-lock-mark-block-function) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
769 (font-lock-fontify-region (point) (mark))) |
15442
b4c8360e450e
(global-font-lock-mode): Set up find-file-hooks.
Richard M. Stallman <rms@gnu.org>
parents:
14780
diff
changeset
|
770 ((error quit) (message "Fontifying block...%s" error-data))))))) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
771 |
14778
af95abc39d75
(font-lock-fontify-block): Use facemenu-keymap to make the binding.
Richard M. Stallman <rms@gnu.org>
parents:
14735
diff
changeset
|
772 (define-key facemenu-keymap "\M-g" 'font-lock-fontify-block) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
773 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
774 ;; Syntactic fontification functions. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
775 |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
776 ;; These record the parse state at a particular position, always the start of a |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
777 ;; line. Used to make `font-lock-fontify-syntactically-region' faster. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
778 (defvar font-lock-cache-position nil) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
779 (defvar font-lock-cache-state nil) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
780 (make-variable-buffer-local 'font-lock-cache-position) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
781 (make-variable-buffer-local 'font-lock-cache-state) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
782 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
783 (defun font-lock-fontify-syntactically-region (start end &optional loudly) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
784 "Put proper face on each string and comment between START and END. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
785 START should be at the beginning of a line." |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
786 (let ((synstart (if comment-start-skip |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
787 (concat "\\s\"\\|" comment-start-skip) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
788 "\\s\"")) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
789 (comstart (if comment-start-skip |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
790 (concat "\\s<\\|" comment-start-skip) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
791 "\\s<")) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
792 state prev prevstate) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
793 (if loudly (message "Fontifying %s... (syntactically...)" (buffer-name))) |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
794 (goto-char start) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
795 ;; |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
796 ;; Find the state at the `beginning-of-line' before `start'. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
797 (if (eq start font-lock-cache-position) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
798 ;; Use the cache for the state of `start'. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
799 (setq state font-lock-cache-state) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
800 ;; Find the state of `start'. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
801 (if (null font-lock-beginning-of-syntax-function) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
802 ;; Use the state at the previous cache position, if any, or |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
803 ;; otherwise calculate from `point-min'. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
804 (if (or (null font-lock-cache-position) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
805 (< start font-lock-cache-position)) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
806 (setq state (parse-partial-sexp (point-min) start)) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
807 (setq state (parse-partial-sexp font-lock-cache-position start |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
808 nil nil font-lock-cache-state))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
809 ;; Call the function to move outside any syntactic block. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
810 (funcall font-lock-beginning-of-syntax-function) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
811 (setq state (parse-partial-sexp (point) start))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
812 ;; Cache the state and position of `start'. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
813 (setq font-lock-cache-state state |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
814 font-lock-cache-position start)) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
815 ;; |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
816 ;; If the region starts inside a string, show the extent of it. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
817 (if (nth 3 state) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
818 (let ((beg (point))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
819 (while (and (re-search-forward "\\s\"" end 'move) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
820 (nth 3 (parse-partial-sexp beg (point) nil nil state)))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
821 (put-text-property beg (point) 'face font-lock-string-face) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
822 (setq state (parse-partial-sexp beg (point) nil nil state)))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
823 ;; |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
824 ;; Likewise for a comment. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
825 (if (or (nth 4 state) (nth 7 state)) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
826 (let ((beg (point))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
827 (save-restriction |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
828 (narrow-to-region (point-min) end) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
829 (condition-case nil |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
830 (progn |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
831 (re-search-backward comstart (point-min) 'move) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
832 (forward-comment 1) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
833 ;; forward-comment skips all whitespace, |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
834 ;; so go back to the real end of the comment. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
835 (skip-chars-backward " \t")) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
836 (error (goto-char end)))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
837 (put-text-property beg (point) 'face font-lock-comment-face) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
838 (setq state (parse-partial-sexp beg (point) nil nil state)))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
839 ;; |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
840 ;; Find each interesting place between here and `end'. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
841 (while (and (< (point) end) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
842 (setq prev (point) prevstate state) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
843 (re-search-forward synstart end t) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
844 (progn |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
845 ;; Clear out the fonts of what we skip over. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
846 (remove-text-properties prev (point) '(face nil)) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
847 ;; Verify the state at that place |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
848 ;; so we don't get fooled by \" or \;. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
849 (setq state (parse-partial-sexp prev (point) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
850 nil nil state)))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
851 (let ((here (point))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
852 (if (or (nth 4 state) (nth 7 state)) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
853 ;; |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
854 ;; We found a real comment start. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
855 (let ((beg (match-beginning 0))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
856 (goto-char beg) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
857 (save-restriction |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
858 (narrow-to-region (point-min) end) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
859 (condition-case nil |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
860 (progn |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
861 (forward-comment 1) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
862 ;; forward-comment skips all whitespace, |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
863 ;; so go back to the real end of the comment. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
864 (skip-chars-backward " \t")) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
865 (error (goto-char end)))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
866 (put-text-property beg (point) 'face font-lock-comment-face) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
867 (setq state (parse-partial-sexp here (point) nil nil state))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
868 (if (nth 3 state) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
869 ;; |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
870 ;; We found a real string start. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
871 (let ((beg (match-beginning 0))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
872 (while (and (re-search-forward "\\s\"" end 'move) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
873 (nth 3 (parse-partial-sexp here (point) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
874 nil nil state)))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
875 (put-text-property beg (point) 'face font-lock-string-face) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
876 (setq state (parse-partial-sexp here (point) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
877 nil nil state)))))) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
878 ;; |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
879 ;; Make sure `prev' is non-nil after the loop |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
880 ;; only if it was set on the very last iteration. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
881 (setq prev nil)) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
882 ;; |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
883 ;; Clean up. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
884 (and prev (remove-text-properties prev end '(face nil))))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
885 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
886 ;;; Additional text property functions. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
887 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
888 ;; The following three text property functions are not generally available (and |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
889 ;; it's not certain that they should be) so they are inlined for speed. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
890 ;; The case for `fillin-text-property' is simple; it may or not be generally |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
891 ;; useful. (Since it is used here, it is useful in at least one place.;-) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
892 ;; However, the case for `append-text-property' and `prepend-text-property' is |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
893 ;; more complicated. Should they remove duplicate property values or not? If |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
894 ;; so, should the first or last duplicate item remain? Or the one that was |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
895 ;; added? In our implementation, the first duplicate remains. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
896 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
897 (defsubst font-lock-fillin-text-property (start end prop value &optional object) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
898 "Fill in one property of the text from START to END. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
899 Arguments PROP and VALUE specify the property and value to put where none are |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
900 already in place. Therefore existing property values are not overwritten. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
901 Optional argument OBJECT is the string or buffer containing the text." |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
902 (let ((start (text-property-any start end prop nil object)) next) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
903 (while start |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
904 (setq next (next-single-property-change start prop object end)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
905 (put-text-property start next prop value object) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
906 (setq start (text-property-any next end prop nil object))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
907 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
908 ;; This function (from simon's unique.el) is rewritten and inlined for speed. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
909 ;(defun unique (list function) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
910 ; "Uniquify LIST, deleting elements using FUNCTION. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
911 ;Return the list with subsequent duplicate items removed by side effects. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
912 ;FUNCTION is called with an element of LIST and a list of elements from LIST, |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
913 ;and should return the list of elements with occurrences of the element removed, |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
914 ;i.e., a function such as `delete' or `delq'. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
915 ;This function will work even if LIST is unsorted. See also `uniq'." |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
916 ; (let ((list list)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
917 ; (while list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
918 ; (setq list (setcdr list (funcall function (car list) (cdr list)))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
919 ; list) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
920 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
921 (defsubst font-lock-unique (list) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
922 "Uniquify LIST, deleting elements using `delq'. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
923 Return the list with subsequent duplicate items removed by side effects." |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
924 (let ((list list)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
925 (while list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
926 (setq list (setcdr list (delq (car list) (cdr list)))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
927 list) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
928 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
929 ;; A generalisation of `facemenu-add-face' for any property, but without the |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
930 ;; removal of inactive faces via `facemenu-discard-redundant-faces' and special |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
931 ;; treatment of `default'. Uses `unique' to remove duplicate property values. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
932 (defsubst font-lock-prepend-text-property (start end prop value &optional object) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
933 "Prepend to one property of the text from START to END. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
934 Arguments PROP and VALUE specify the property and value to prepend to the value |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
935 already in place. The resulting property values are always lists, and unique. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
936 Optional argument OBJECT is the string or buffer containing the text." |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
937 (let ((val (if (listp value) value (list value))) next prev) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
938 (while (/= start end) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
939 (setq next (next-single-property-change start prop object end) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
940 prev (get-text-property start prop object)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
941 (put-text-property |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
942 start next prop |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
943 (font-lock-unique (append val (if (listp prev) prev (list prev)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
944 object) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
945 (setq start next)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
946 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
947 (defsubst font-lock-append-text-property (start end prop value &optional object) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
948 "Append to one property of the text from START to END. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
949 Arguments PROP and VALUE specify the property and value to append to the value |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
950 already in place. The resulting property values are always lists, and unique. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
951 Optional argument OBJECT is the string or buffer containing the text." |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
952 (let ((val (if (listp value) value (list value))) next prev) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
953 (while (/= start end) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
954 (setq next (next-single-property-change start prop object end) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
955 prev (get-text-property start prop object)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
956 (put-text-property |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
957 start next prop |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
958 (font-lock-unique (append (if (listp prev) prev (list prev)) val)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
959 object) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
960 (setq start next)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
961 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
962 ;;; Regexp fontification functions. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
963 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
964 (defsubst font-lock-apply-highlight (highlight) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
965 "Apply HIGHLIGHT following a match. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
966 HIGHLIGHT should be of the form MATCH-HIGHLIGHT, see `font-lock-keywords'." |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
967 (let* ((match (nth 0 highlight)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
968 (start (match-beginning match)) (end (match-end match)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
969 (override (nth 2 highlight))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
970 (cond ((not start) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
971 ;; No match but we might not signal an error. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
972 (or (nth 3 highlight) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
973 (error "No match %d in highlight %S" match highlight))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
974 ((not override) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
975 ;; Cannot override existing fontification. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
976 (or (text-property-not-all start end 'face nil) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
977 (put-text-property start end 'face (eval (nth 1 highlight))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
978 ((eq override t) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
979 ;; Override existing fontification. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
980 (put-text-property start end 'face (eval (nth 1 highlight)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
981 ((eq override 'keep) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
982 ;; Keep existing fontification. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
983 (font-lock-fillin-text-property start end 'face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
984 (eval (nth 1 highlight)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
985 ((eq override 'prepend) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
986 ;; Prepend to existing fontification. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
987 (font-lock-prepend-text-property start end 'face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
988 (eval (nth 1 highlight)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
989 ((eq override 'append) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
990 ;; Append to existing fontification. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
991 (font-lock-append-text-property start end 'face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
992 (eval (nth 1 highlight))))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
993 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
994 (defsubst font-lock-fontify-anchored-keywords (keywords limit) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
995 "Fontify according to KEYWORDS until LIMIT. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
996 KEYWORDS should be of the form MATCH-ANCHORED, see `font-lock-keywords'." |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
997 (let ((matcher (nth 0 keywords)) (lowdarks (nthcdr 3 keywords)) highlights) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
998 ;; Until we come up with a cleaner solution, we make LIMIT the end of line. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
999 (save-excursion (end-of-line) (setq limit (min limit (point)))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1000 ;; Evaluate PRE-MATCH-FORM. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1001 (eval (nth 1 keywords)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1002 (save-match-data |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1003 ;; Find an occurrence of `matcher' before `limit'. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1004 (while (if (stringp matcher) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1005 (re-search-forward matcher limit t) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1006 (funcall matcher limit)) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1007 ;; Apply each highlight to this instance of `matcher'. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1008 (setq highlights lowdarks) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1009 (while highlights |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1010 (font-lock-apply-highlight (car highlights)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1011 (setq highlights (cdr highlights))))) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1012 ;; Evaluate POST-MATCH-FORM. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1013 (eval (nth 2 keywords)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1014 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1015 (defun font-lock-fontify-keywords-region (start end &optional loudly) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1016 "Fontify according to `font-lock-keywords' between START and END. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1017 START should be at the beginning of a line." |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1018 (let ((case-fold-search font-lock-keywords-case-fold-search) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1019 (keywords (cdr (if (eq (car-safe font-lock-keywords) t) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1020 font-lock-keywords |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1021 (font-lock-compile-keywords)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1022 (bufname (buffer-name)) (count 0) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1023 keyword matcher highlights) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1024 ;; |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1025 ;; Fontify each item in `font-lock-keywords' from `start' to `end'. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1026 (while keywords |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1027 (if loudly (message "Fontifying %s... (regexps..%s)" bufname |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1028 (make-string (setq count (1+ count)) ?.))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1029 ;; |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1030 ;; Find an occurrence of `matcher' from `start' to `end'. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1031 (setq keyword (car keywords) matcher (car keyword)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1032 (goto-char start) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1033 (while (if (stringp matcher) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1034 (re-search-forward matcher end t) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1035 (funcall matcher end)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1036 ;; Apply each highlight to this instance of `matcher', which may be |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1037 ;; specific highlights or more keywords anchored to `matcher'. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1038 (setq highlights (cdr keyword)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1039 (while highlights |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1040 (if (numberp (car (car highlights))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1041 (font-lock-apply-highlight (car highlights)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1042 (font-lock-fontify-anchored-keywords (car highlights) end)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1043 (setq highlights (cdr highlights)))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1044 (setq keywords (cdr keywords))))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1045 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1046 ;; Various functions. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1047 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1048 (defun font-lock-compile-keywords (&optional keywords) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1049 ;; Compile `font-lock-keywords' into the form (t KEYWORD ...) where KEYWORD |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1050 ;; is the (MATCHER HIGHLIGHT ...) shown in the variable's doc string. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1051 (let ((keywords (or keywords font-lock-keywords))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1052 (setq font-lock-keywords |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1053 (if (eq (car-safe keywords) t) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1054 keywords |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1055 (cons t (mapcar 'font-lock-compile-keyword keywords)))))) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1056 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1057 (defun font-lock-compile-keyword (keyword) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1058 (cond ((nlistp keyword) ; Just MATCHER |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1059 (list keyword '(0 font-lock-keyword-face))) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1060 ((eq (car keyword) 'eval) ; Specified (eval . FORM) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1061 (font-lock-compile-keyword (eval (cdr keyword)))) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1062 ((numberp (cdr keyword)) ; Specified (MATCHER . MATCH) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1063 (list (car keyword) (list (cdr keyword) 'font-lock-keyword-face))) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1064 ((symbolp (cdr keyword)) ; Specified (MATCHER . FACENAME) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1065 (list (car keyword) (list 0 (cdr keyword)))) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1066 ((nlistp (nth 1 keyword)) ; Specified (MATCHER . HIGHLIGHT) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1067 (list (car keyword) (cdr keyword))) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1068 (t ; Hopefully (MATCHER HIGHLIGHT ...) |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1069 keyword))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1070 |
14708
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1071 (defun font-lock-value-in-major-mode (alist) |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1072 ;; Return value in ALIST for `major-mode', or ALIST if it is not an alist. |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1073 ;; Alist structure is ((MAJOR-MODE . VALUE)) where MAJOR-MODE may be t. |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1074 (if (consp alist) |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1075 (cdr (or (assq major-mode alist) (assq t alist))) |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1076 alist)) |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1077 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1078 (defun font-lock-choose-keywords (keywords level) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1079 ;; Return LEVELth element of KEYWORDS. A LEVEL of nil is equal to a |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1080 ;; LEVEL of 0, a LEVEL of t is equal to (1- (length KEYWORDS)). |
14708
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1081 (cond ((symbolp keywords) |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1082 keywords) |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1083 ((numberp level) |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1084 (or (nth level keywords) (car (reverse keywords)))) |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1085 ((eq level t) |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1086 (car (reverse keywords))) |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1087 (t |
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1088 (car keywords)))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1089 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1090 (defun font-lock-set-defaults () |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1091 "Set fontification defaults appropriately for this mode. |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1092 Sets various variables using `font-lock-defaults' (or, if nil, using |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1093 `font-lock-defaults-alist') and `font-lock-maximum-decoration'." |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1094 ;; Set face defaults. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1095 (font-lock-make-faces) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1096 ;; Set fontification defaults. |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1097 (make-local-variable 'font-lock-fontified) |
14780
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1098 (if (member font-lock-keywords '(nil (t))) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1099 (let* ((defaults (or font-lock-defaults |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1100 (cdr (assq major-mode font-lock-defaults-alist)))) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1101 (keywords |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1102 (font-lock-choose-keywords (nth 0 defaults) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1103 (font-lock-value-in-major-mode font-lock-maximum-decoration)))) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1104 ;; Regexp fontification? |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1105 (setq font-lock-keywords (if (fboundp keywords) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1106 (funcall keywords) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1107 (eval keywords))) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1108 ;; Syntactic fontification? |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1109 (if (nth 1 defaults) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1110 (set (make-local-variable 'font-lock-keywords-only) t)) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1111 ;; Case fold during regexp fontification? |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1112 (if (nth 2 defaults) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1113 (set (make-local-variable 'font-lock-keywords-case-fold-search) t)) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1114 ;; Syntax table for regexp and syntactic fontification? |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1115 (if (nth 3 defaults) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1116 (let ((slist (nth 3 defaults))) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1117 (set (make-local-variable 'font-lock-syntax-table) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1118 (copy-syntax-table (syntax-table))) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1119 (while slist |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1120 ;; The character to modify may be a single CHAR or a STRING. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1121 (let ((chars (if (numberp (car (car slist))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1122 (list (car (car slist))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1123 (mapcar 'identity (car (car slist))))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1124 (syntax (cdr (car slist)))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1125 (while chars |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1126 (modify-syntax-entry (car chars) syntax |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1127 font-lock-syntax-table) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1128 (setq chars (cdr chars))) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1129 (setq slist (cdr slist)))))) |
14780
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1130 ;; Syntax function for syntactic fontification? |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1131 (if (nth 4 defaults) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1132 (set (make-local-variable 'font-lock-beginning-of-syntax-function) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1133 (nth 4 defaults))) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1134 ;; Variable alist? |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1135 (let ((alist (nthcdr 5 defaults))) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1136 (while alist |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1137 (set (make-local-variable (car (car alist))) (cdr (car alist))) |
1d10e4a2fb51
Treat font-lock-keywords of (t) the same as nil.
Simon Marshall <simon@gnu.org>
parents:
14778
diff
changeset
|
1138 (setq alist (cdr alist))))))) |
14365
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1139 |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1140 (defun font-lock-unset-defaults () |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1141 "Unset fontification defaults. See `font-lock-set-defaults'." |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1142 (setq font-lock-keywords nil |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1143 font-lock-keywords-only nil |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1144 font-lock-keywords-case-fold-search nil |
ef148b168aad
Support for buffer local fontification functions.
Simon Marshall <simon@gnu.org>
parents:
14266
diff
changeset
|
1145 font-lock-syntax-table nil |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1146 font-lock-beginning-of-syntax-function nil) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1147 (let* ((defaults (or font-lock-defaults |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1148 (cdr (assq major-mode font-lock-defaults-alist)))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1149 (alist (nthcdr 5 defaults))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1150 (while alist |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1151 (set (car (car alist)) (default-value (car (car alist)))) |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1152 (setq alist (cdr alist))))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1153 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1154 ;; Colour etc. support. |
4053 | 1155 |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1156 ;; This section of code is crying out for revision. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1157 |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1158 ;; To begin with, `display-type' and `background-mode' are `frame-parameters' |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1159 ;; so we don't have to calculate them here anymore. But all the face stuff |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1160 ;; should be frame-local (and thus display-local) anyway. Because we're not |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1161 ;; sure what support Emacs is going to have for general frame-local face |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1162 ;; attributes, we leave this section of code as it is. For now. --sm. |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1163 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1164 (defvar font-lock-display-type nil |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1165 "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
|
1166 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
|
1167 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
|
1168 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
|
1169 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
|
1170 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1171 (defvar font-lock-background-mode nil |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1172 "A symbol indicating the Emacs background brightness. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1173 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
|
1174 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
|
1175 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
|
1176 `~/.Xdefaults'. |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1177 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
|
1178 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1179 (defvar font-lock-face-attributes nil |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1180 "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
|
1181 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
|
1182 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1183 (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
|
1184 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1185 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
|
1186 `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
|
1187 `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
|
1188 `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
|
1189 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
|
1190 used in highlighting. See `font-lock-keywords'. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1191 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1192 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
|
1193 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
|
1194 \(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
|
1195 corresponding face attributes (yes if non-nil). |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1196 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1197 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
|
1198 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
|
1199 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1200 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
|
1201 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
|
1202 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
|
1203 |
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
|
1204 (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
|
1205 "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
|
1206 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
|
1207 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
|
1208 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
|
1209 ;; 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
|
1210 ;; 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
|
1211 (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
|
1212 (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
|
1213 (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
|
1214 "DisplayType"))) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1215 (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
|
1216 ((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
|
1217 ((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
|
1218 (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
|
1219 (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
|
1220 (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
|
1221 (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
|
1222 "BackgroundMode")) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1223 (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
|
1224 (cond (bg-resource (intern (downcase bg-resource))) |
13641
1233bea2cb02
(font-lock-make-faces): Add special code for ms-dos.
Richard M. Stallman <rms@gnu.org>
parents:
13452
diff
changeset
|
1225 ((eq system-type 'ms-dos) |
1233bea2cb02
(font-lock-make-faces): Add special code for ms-dos.
Richard M. Stallman <rms@gnu.org>
parents:
13452
diff
changeset
|
1226 (if (string-match "light" |
1233bea2cb02
(font-lock-make-faces): Add special code for ms-dos.
Richard M. Stallman <rms@gnu.org>
parents:
13452
diff
changeset
|
1227 (cdr (assq 'background-color params))) |
1233bea2cb02
(font-lock-make-faces): Add special code for ms-dos.
Richard M. Stallman <rms@gnu.org>
parents:
13452
diff
changeset
|
1228 'light |
1233bea2cb02
(font-lock-make-faces): Add special code for ms-dos.
Richard M. Stallman <rms@gnu.org>
parents:
13452
diff
changeset
|
1229 'dark)) |
11467
bb7c9db199ae
(font-lock-make-faces): Determine font-lock-background-mode from color
Richard M. Stallman <rms@gnu.org>
parents:
10879
diff
changeset
|
1230 ((< (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
|
1231 (cdr (assq 'background-color params)))) |
15485
d3b17e7049bf
(font-lock-make-faces): Set threshold for "light color"
Richard M. Stallman <rms@gnu.org>
parents:
15442
diff
changeset
|
1232 (* (apply '+ (x-color-values "white")) .6)) |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1233 'dark) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1234 (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
|
1235 (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
|
1236 (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
|
1237 (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
|
1238 (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
|
1239 ;; 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
|
1240 ;;'((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
|
1241 ;; (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
|
1242 ;; (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
|
1243 ;; (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
|
1244 ;; (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
|
1245 (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
|
1246 '(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
|
1247 '(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
|
1248 (list |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1249 '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
|
1250 (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
|
1251 (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
|
1252 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
|
1253 '(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
|
1254 '(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
|
1255 '(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
|
1256 ((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
|
1257 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
|
1258 (list |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1259 (list 'font-lock-comment-face |
12484
bf638e2849d5
(font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents:
12385
diff
changeset
|
1260 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
|
1261 (list 'font-lock-string-face |
12484
bf638e2849d5
(font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents:
12385
diff
changeset
|
1262 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
|
1263 (list 'font-lock-keyword-face |
12484
bf638e2849d5
(font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents:
12385
diff
changeset
|
1264 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
|
1265 (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
|
1266 (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
|
1267 (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
|
1268 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
|
1269 (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
|
1270 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
|
1271 (list 'font-lock-type-face |
12484
bf638e2849d5
(font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents:
12385
diff
changeset
|
1272 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
|
1273 (list 'font-lock-reference-face |
12484
bf638e2849d5
(font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents:
12385
diff
changeset
|
1274 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
|
1275 (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
|
1276 '((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
|
1277 (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
|
1278 (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
|
1279 (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
|
1280 (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
|
1281 (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
|
1282 (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
|
1283 (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
|
1284 '((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
|
1285 (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
|
1286 (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
|
1287 (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
|
1288 (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
|
1289 (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
|
1290 (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
|
1291 ;; 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
|
1292 (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
|
1293 (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
|
1294 (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
|
1295 (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
|
1296 ;; 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
|
1297 (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
|
1298 ((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
|
1299 ;; 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
|
1300 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
|
1301 ((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
|
1302 ;; 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
|
1303 (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
|
1304 (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
|
1305 ;; 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
|
1306 (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
|
1307 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
|
1308 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1309 (defun font-lock-make-face (face-attributes) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1310 "Make a face from FACE-ATTRIBUTES. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1311 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
|
1312 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
|
1313 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
|
1314 (let* ((face (nth 0 face-attributes)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1315 (face-name (symbol-name face)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1316 (set-p (function (lambda (face-name resource) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1317 (x-get-resource (concat face-name ".attribute" resource) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1318 (concat "Face.Attribute" resource))))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1319 (on-p (function (lambda (face-name resource) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1320 (let ((set (funcall set-p face-name resource))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1321 (and set (member (downcase set) '("on" "true")))))))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1322 (make-face face) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1323 (add-to-list 'facemenu-unlisted-faces face) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1324 ;; 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
|
1325 (or (funcall set-p face-name "Foreground") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1326 (condition-case nil |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1327 (set-face-foreground face (nth 1 face-attributes)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1328 (error nil))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1329 (or (funcall set-p face-name "Background") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1330 (condition-case nil |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1331 (set-face-background face (nth 2 face-attributes)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1332 (error nil))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1333 (if (funcall set-p face-name "Bold") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1334 (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
|
1335 (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
|
1336 (if (funcall set-p face-name "Italic") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1337 (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
|
1338 (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
|
1339 (or (funcall set-p face-name "Underline") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1340 (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
|
1341 (set face face))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1342 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1343 ;;; Various regexp information shared by several modes. |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1344 ;;; Information specific to a single mode should go in its load library. |
4053 | 1345 |
1346 (defconst lisp-font-lock-keywords-1 | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1347 (list |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1348 ;; Anything not a variable or type declaration is fontified as a function. |
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
|
1349 ;; 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
|
1350 ;; 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
|
1351 (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
|
1352 ;; 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
|
1353 "\\(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
|
1354 ;; 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
|
1355 "\\(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
|
1356 ;; 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
|
1357 "\\([^ \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
|
1358 "\\)\\)\\>" |
c9ed95ec05b6
Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
12626
diff
changeset
|
1359 ;; 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
|
1360 "[ \t'\(]*" |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
1361 "\\(\\sw+\\)?") |
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
|
1362 '(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
|
1363 '(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
|
1364 ((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
|
1365 (t font-lock-function-name-face)) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1366 nil t)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1367 ) |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
1368 "Subdued level highlighting for Lisp modes.") |
4053 | 1369 |
1370 (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
|
1371 (append lisp-font-lock-keywords-1 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1372 (list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1373 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1374 ;; 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
|
1375 ; (make-regexp |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
1376 ; '("cond" "if" "while" "let\\*?" "prog[nv12*]?" "inline" "catch" "throw" |
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
|
1377 ; "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
|
1378 ; "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
|
1379 ; "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
|
1380 ; "eval-after-load" "eval-and-compile" "eval-when-compile" |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1381 ; "when" "unless" "do" "flet" "labels" "return" "return-from" |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1382 ; "with-output-to-temp-buffer" "with-timeout")) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1383 (cons |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1384 (concat |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1385 "(\\(" |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1386 "c\\(atch\\|ond\\(\\|ition-case\\)\\)\\|do\\|" |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1387 "eval-\\(a\\(fter-load\\|nd-compile\\)\\|when-compile\\)\\|flet\\|" |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
1388 "i\\(f\\|nline\\)\\|l\\(abels\\|et\\*?\\)\\|prog[nv12*]?\\|" |
14468
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1389 "return\\(\\|-from\\)\\|save-\\(excursion\\|match-data\\|restriction\\|" |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1390 "selected-window\\|window-excursion\\)\\|t\\(hrow\\|rack-mouse\\)\\|" |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1391 "un\\(less\\|wind-protect\\)\\|" |
e41a60d26291
Correct specialised fontification and associated stuff.
Simon Marshall <simon@gnu.org>
parents:
14374
diff
changeset
|
1392 "w\\(h\\(en\\|ile\\)\\|ith-\\(output-to-temp-buffer\\|timeout\\)\\)" |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1393 "\\)\\>") 1) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1394 ;; |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
1395 ;; Feature symbols as references. |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
1396 '("(\\(featurep\\|provide\\|require\\)\\>[ \t']*\\(\\sw+\\)?" |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
1397 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t)) |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
1398 ;; |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1399 ;; Words inside \\[] tend to be for `substitute-command-keys'. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1400 '("\\\\\\\\\\[\\(\\sw+\\)]" 1 font-lock-reference-face prepend) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1401 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1402 ;; Words inside `' tend to be symbol names. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1403 '("`\\(\\sw\\sw+\\)'" 1 font-lock-reference-face prepend) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1404 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1405 ;; CLisp `:' keywords as references. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1406 '("\\<:\\sw+\\>" 0 font-lock-reference-face prepend) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1407 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1408 ;; ELisp and CLisp `&' keywords as types. |
14708
da278f255507
Make global-font-lock-mode show status messages, and fontification interruptable.
Simon Marshall <simon@gnu.org>
parents:
14516
diff
changeset
|
1409 '("\\<\\&\\sw+\\>" . font-lock-type-face) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1410 )) |
12385
c80966dc0b60
Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents:
12268
diff
changeset
|
1411 "Gaudy level highlighting for Lisp modes.") |
4053 | 1412 |
12385
c80966dc0b60
Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents:
12268
diff
changeset
|
1413 (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
|
1414 "Default expressions to highlight in Lisp modes.") |
4053 | 1415 |
1416 | |
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
|
1417 (defvar scheme-font-lock-keywords |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1418 (eval-when-compile |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1419 (list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1420 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1421 ;; Declarations. Hannes Haug <hannes.haug@student.uni-tuebingen.de> says |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1422 ;; this works for SOS, STklos, SCOOPS, Meroon and Tiny CLOS. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1423 (list (concat "(\\(define\\(" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1424 ;; Function names. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1425 "\\(\\|-\\(generic\\(\\|-procedure\\)\\|method\\)\\)\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1426 ;; Macro names, as variable names. A bit dubious, this. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1427 "\\(-syntax\\)\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1428 ;; Class names. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1429 "\\(-class\\)" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1430 "\\)\\)\\>" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1431 ;; Any whitespace and declared object. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1432 "[ \t]*(?" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1433 "\\(\\sw+\\)?") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1434 '(1 font-lock-keyword-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1435 '(8 (cond ((match-beginning 3) font-lock-function-name-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1436 ((match-beginning 6) font-lock-variable-name-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1437 (t font-lock-type-face)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1438 nil t)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1439 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1440 ;; Control structures. |
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
|
1441 ;(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
|
1442 ; "call-with-input-file" "call-with-output-file" "case" "cond" |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1443 ; "do" "else" "for-each" "if" "lambda" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1444 ; "let\\*?" "let-syntax" "letrec" "letrec-syntax" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1445 ; ;; Hannes Haug <hannes.haug@student.uni-tuebingen.de> wants: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1446 ; "and" "or" "delay" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1447 ; ;; Stefan Monnier <stefan.monnier@epfl.ch> says don't bother: |
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
|
1448 ; ;;"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
|
1449 ; "map" "syntax" "syntax-rules")) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1450 (cons |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1451 (concat "(\\(" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1452 "and\\|begin\\|c\\(a\\(ll\\(-with-\\(current-continuation\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1453 "input-file\\|output-file\\)\\|/cc\\)\\|se\\)\\|ond\\)\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1454 "d\\(elay\\|o\\)\\|else\\|for-each\\|if\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1455 "l\\(ambda\\|et\\(-syntax\\|\\*?\\|rec\\(\\|-syntax\\)\\)\\)\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1456 "map\\|or\\|syntax\\(\\|-rules\\)" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1457 "\\)\\>") 1) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1458 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1459 ;; David Fox <fox@graphics.cs.nyu.edu> for SOS/STklos class specifiers. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1460 '("\\<<\\sw+>\\>" . font-lock-type-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1461 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1462 ;; Scheme `:' keywords as references. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1463 '("\\<:\\sw+\\>" . font-lock-reference-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1464 )) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1465 "Default expressions to highlight in Scheme modes.") |
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
|
1466 |
c9ed95ec05b6
Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
12626
diff
changeset
|
1467 |
4053 | 1468 (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
|
1469 "Subdued level highlighting for C modes.") |
4053 | 1470 |
1471 (defconst c-font-lock-keywords-2 nil | |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1472 "Medium level highlighting for C modes.") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1473 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1474 (defconst c-font-lock-keywords-3 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
|
1475 "Gaudy level highlighting for C modes.") |
4053 | 1476 |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
1477 (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
|
1478 "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
|
1479 |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
1480 (defconst c++-font-lock-keywords-2 nil |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1481 "Medium level highlighting for C++ modes.") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1482 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1483 (defconst c++-font-lock-keywords-3 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
|
1484 "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
|
1485 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1486 (defun font-lock-match-c++-style-declaration-item-and-skip-to-next (limit) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1487 ;; Match, and move over, any declaration/definition item after point. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1488 ;; The expect syntax of an item is "word" or "word::word", possibly ending |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1489 ;; with optional whitespace and a "(". Everything following the item (but |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1490 ;; belonging to it) is expected to by skip-able by `forward-sexp', and items |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1491 ;; are expected to be separated with a "," or ";". |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1492 (if (looking-at "[ \t*&]*\\(\\sw+\\)\\(::\\(\\sw+\\)\\)?[ \t]*\\((\\)?") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1493 (save-match-data |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1494 (condition-case nil |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1495 (save-restriction |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1496 ;; Restrict to the end of line, currently guaranteed to be LIMIT. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1497 (narrow-to-region (point-min) limit) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1498 (goto-char (match-end 1)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1499 ;; Move over any item value, etc., to the next item. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1500 (while (not (looking-at "[ \t]*\\([,;]\\|$\\)")) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1501 (goto-char (or (scan-sexps (point) 1) (point-max)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1502 (goto-char (match-end 0))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1503 (error t))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1504 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1505 (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
|
1506 ; ("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
|
1507 "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
|
1508 (c-type-types |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1509 ; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum" |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1510 ; "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
|
1511 ; "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
|
1512 (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
|
1513 "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
|
1514 "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
|
1515 "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
|
1516 (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
|
1517 ; ("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
|
1518 ; "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
|
1519 ; "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
|
1520 (concat "asm\\|break\\|c\\(atch\\|ontinue\\)\\|d\\(elete\\|o\\)\\|" |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1521 "else\\|for\\|if\\|new\\|" |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1522 "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
|
1523 "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
|
1524 (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
|
1525 ; ("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
|
1526 ; "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
|
1527 ; "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
|
1528 ; "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
|
1529 (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
|
1530 "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
|
1531 "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
|
1532 "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
|
1533 "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
|
1534 "v\\(irtual\\|o\\(id\\|latile\\)\\)")) ; 11 ()s deep. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1535 ) |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
1536 (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
|
1537 (list |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
1538 ;; |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1539 ;; These are all anchored at the beginning of line for speed. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1540 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1541 ;; Fontify function name definitions (GNU style; without type on line). |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1542 (list (concat "^\\(\\sw+\\)[ \t]*(") 1 'font-lock-function-name-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1543 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1544 ;; Fontify filenames in #include <...> preprocessor directives as strings. |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
1545 '("^#[ \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
|
1546 ;; |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1547 ;; Fontify function macro names. |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
1548 '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 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
|
1549 ;; |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1550 ;; Fontify symbol names in #elif or #if ... defined preprocessor directives. |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1551 '("^#[ \t]*\\(elif\\|if\\)\\>" |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1552 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1553 (1 font-lock-reference-face) (2 font-lock-variable-name-face nil t))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1554 ;; |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1555 ;; Fontify otherwise as symbol names, and the preprocessor directive names. |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
1556 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?" |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1557 (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
|
1558 )) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
1559 |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
1560 (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
|
1561 (append c-font-lock-keywords-1 |
4053 | 1562 (list |
1563 ;; | |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1564 ;; Simple regexps for speed. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1565 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1566 ;; Fontify all type specifiers. |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1567 (cons (concat "\\<\\(" c-type-types "\\)\\>") 'font-lock-type-face) |
4053 | 1568 ;; |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1569 ;; Fontify all builtin keywords (except case, default and goto; see below). |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1570 (cons (concat "\\<\\(" c-keywords "\\)\\>") 'font-lock-keyword-face) |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1571 ;; |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1572 ;; Fontify case/goto keywords and targets, and case default/goto tags. |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
1573 '("\\<\\(case\\|goto\\)\\>[ \t]*\\(\\sw+\\)?" |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1574 (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
|
1575 '("^[ \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
|
1576 ))) |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
1577 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1578 (setq c-font-lock-keywords-3 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1579 (append c-font-lock-keywords-2 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1580 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1581 ;; More complicated regexps for more complete highlighting for types. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1582 ;; We still have to fontify type specifiers individually, as C is so hairy. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1583 (list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1584 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1585 ;; Fontify all storage classes and type specifiers, plus their items. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1586 (list (concat "\\<\\(" c-type-types "\\)\\>" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1587 "\\([ \t*&]+\\sw+\\>\\)*") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1588 ;; Fontify each declaration item. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1589 '(font-lock-match-c++-style-declaration-item-and-skip-to-next |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1590 ;; Start with point after all type specifiers. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1591 (goto-char (or (match-beginning 8) (match-end 1))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1592 ;; Finish with point after first type specifier. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1593 (goto-char (match-end 1)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1594 ;; Fontify as a variable or function name. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1595 (1 (if (match-beginning 4) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1596 font-lock-function-name-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1597 font-lock-variable-name-face)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1598 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1599 ;; Fontify structures, or typedef names, plus their items. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1600 '("\\(}\\)[ \t*]*\\sw" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1601 (font-lock-match-c++-style-declaration-item-and-skip-to-next |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1602 (goto-char (match-end 1)) nil |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1603 (1 (if (match-beginning 4) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1604 font-lock-function-name-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1605 font-lock-variable-name-face)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1606 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1607 ;; Fontify anything at beginning of line as a declaration or definition. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1608 '("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1609 (1 font-lock-type-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1610 (font-lock-match-c++-style-declaration-item-and-skip-to-next |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1611 (goto-char (or (match-beginning 2) (match-end 1))) nil |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1612 (1 (if (match-beginning 4) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1613 font-lock-function-name-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1614 font-lock-variable-name-face)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1615 ))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1616 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1617 (setq c++-font-lock-keywords-1 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1618 (append |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1619 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1620 ;; The list `c-font-lock-keywords-1' less that for function names. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1621 (cdr c-font-lock-keywords-1) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1622 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1623 ;; Fontify function name definitions, possibly incorporating class name. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1624 (list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1625 '("^\\(\\sw+\\)\\(::\\(\\sw+\\)\\)?[ \t]*(" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1626 (1 (if (match-beginning 2) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1627 font-lock-type-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1628 font-lock-function-name-face)) |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1629 (3 font-lock-function-name-face nil t)) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1630 ))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1631 |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
1632 (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
|
1633 (append c++-font-lock-keywords-1 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1634 (list |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1635 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1636 ;; The list `c-font-lock-keywords-2' for C++ plus operator overloading. |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1637 (cons (concat "\\<\\(" c++-type-types "\\)\\>") 'font-lock-type-face) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1638 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1639 ;; Fontify operator function name overloading. |
15500
5c60db96bc32
Put fewer conditions in turn-on-font-lock and more in turn-on-font-lock-if-enabled, so a user can put the former on hooks.
Simon Marshall <simon@gnu.org>
parents:
15492
diff
changeset
|
1640 '("\\<\\(operator\\)\\>[ \t]*\\([[(><!=+-][])><=+-]?\\)?" |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1641 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1642 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1643 ;; Fontify case/goto keywords and targets, and case default/goto tags. |
13701
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
1644 '("\\<\\(case\\|goto\\)\\>[ \t]*\\(\\sw+\\)?" |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
1645 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t)) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1646 '("^[ \t]*\\(\\sw+\\)[ \t]*:[^:]" 1 font-lock-reference-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1647 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1648 ;; Fontify other builtin keywords. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1649 (cons (concat "\\<\\(" c++-keywords "\\)\\>") 'font-lock-keyword-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1650 ))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1651 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1652 (setq c++-font-lock-keywords-3 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1653 (append c++-font-lock-keywords-2 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1654 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1655 ;; More complicated regexps for more complete highlighting for types. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1656 (list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1657 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1658 ;; Fontify all storage classes and type specifiers, plus their items. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1659 (list (concat "\\<\\(" c++-type-types "\\)\\>" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1660 "\\([ \t*&]+\\sw+\\>\\)*") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1661 ;; Fontify each declaration item. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1662 '(font-lock-match-c++-style-declaration-item-and-skip-to-next |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1663 ;; Start with point after all type specifiers. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1664 (goto-char (or (match-beginning 13) (match-end 1))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1665 ;; Finish with point after first type specifier. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1666 (goto-char (match-end 1)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1667 ;; Fontify as a variable or function name. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1668 (1 (cond ((match-beginning 2) font-lock-type-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1669 ((match-beginning 4) font-lock-function-name-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1670 (t font-lock-variable-name-face))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1671 (3 (if (match-beginning 4) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1672 font-lock-function-name-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1673 font-lock-variable-name-face) nil t))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1674 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1675 ;; Fontify structures, or typedef names, plus their items. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1676 '("\\(}\\)[ \t*]*\\sw" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1677 (font-lock-match-c++-style-declaration-item-and-skip-to-next |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1678 (goto-char (match-end 1)) nil |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1679 (1 (if (match-beginning 4) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1680 font-lock-function-name-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1681 font-lock-variable-name-face)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1682 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1683 ;; Fontify anything at beginning of line as a declaration or definition. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1684 '("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1685 (1 font-lock-type-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1686 (font-lock-match-c++-style-declaration-item-and-skip-to-next |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1687 (goto-char (or (match-beginning 2) (match-end 1))) nil |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1688 (1 (cond ((match-beginning 2) font-lock-type-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1689 ((match-beginning 4) font-lock-function-name-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1690 (t font-lock-variable-name-face))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1691 (3 (if (match-beginning 4) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1692 font-lock-function-name-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1693 font-lock-variable-name-face) nil t))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1694 ))) |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
1695 ) |
4053 | 1696 |
12385
c80966dc0b60
Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents:
12268
diff
changeset
|
1697 (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
|
1698 "Default expressions to highlight in C mode.") |
4053 | 1699 |
12385
c80966dc0b60
Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents:
12268
diff
changeset
|
1700 (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
|
1701 "Default expressions to highlight in C++ mode.") |
4053 | 1702 |
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
|
1703 |
4053 | 1704 (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
|
1705 ; ;; 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
|
1706 ; '(("\\\\\\(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
|
1707 ; 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
|
1708 ; ("\\\\\\(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
|
1709 ; 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
|
1710 ; ;; 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
|
1711 ; ;; 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
|
1712 ; ("{\\\\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
|
1713 ; ("{\\\\\\(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
|
1714 ; ("\\\\\\([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
|
1715 ; ("^[ \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
|
1716 ;; 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
|
1717 '(("\\\\\\(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
|
1718 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
|
1719 ("\\\\\\(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
|
1720 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
|
1721 ("^[ \t]*\\\\def\\\\\\(\\(\\w\\|@\\)+\\)" 1 font-lock-function-name-face) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1722 "\\\\\\([a-zA-Z@]+\\|.\\)" |
11515
0ebfc7701ebf
Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents:
11467
diff
changeset
|
1723 ;; 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
|
1724 ;; 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
|
1725 ;; 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
|
1726 ("\\\\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
|
1727 ;; 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
|
1728 ("\\\\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
|
1729 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
|
1730 ;; 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
|
1731 ("\\\\\\(\\(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
|
1732 3 (if (match-beginning 2) 'bold 'italic) keep)) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1733 "Default expressions to highlight in TeX modes.") |
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
|
1734 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1735 ;; Install ourselves: |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1736 |
15492
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1737 (unless (assq 'font-lock-mode minor-mode-alist) |
348f0896b1e7
(font-lock-verbose): Default to 0. Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
15485
diff
changeset
|
1738 (setq minor-mode-alist (cons '(font-lock-mode " Font") minor-mode-alist))) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1739 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1740 ;; Provide ourselves: |
7491
621c162a80db
(font-lock-no-comments): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
1741 |
4053 | 1742 (provide 'font-lock) |
1743 | |
1744 ;;; font-lock.el ends here |