Mercurial > emacs
annotate lisp/font-lock.el @ 14025:c73d14ef6a6a
(interpreter-mode-alist): Add most shells, with sh-mode.
Add tail, more, less, pg with text-mode.
(auto-mode-alist): Recognize extensions that indicate
shell scripts, as well as common init file names.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 05 Jan 1996 02:34:37 +0000 |
parents | baba81b17362 |
children | 83f275dcd93a |
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 |
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
|
3 ;; Copyright (C) 1992, 1993, 1994, 1995 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 | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
27 ;; 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
|
28 ;; one face, strings in another, reserved words in another, and so on. |
4053 | 29 ;; |
30 ;; Comments will be displayed in `font-lock-comment-face'. | |
31 ;; 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
|
32 ;; Regexps are used to display selected patterns in other faces. |
4053 | 33 ;; |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
34 ;; 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
|
35 ;; 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
|
36 ;; every insertion or deletion. |
4053 | 37 ;; |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
38 ;; To turn Font Lock mode on automatically, add this to your .emacs file: |
4053 | 39 ;; |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
40 ;; (add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock) |
4053 | 41 ;; |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
42 ;; 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
|
43 ;; 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
|
44 ;; it takes to fontify. See the variable `font-lock-maximum-decoration', and |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
45 ;; also the variable `font-lock-maximum-size'. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
46 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
47 ;; 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
|
48 ;; 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
|
49 ;; 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
|
50 ;; |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
51 ;; (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
|
52 ;; '(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
|
53 ;; (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
|
54 ;; |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
55 ;; 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
|
56 ;; 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
|
57 ;; 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
|
58 ;; 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
|
59 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
60 ;; 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
|
61 ;; 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
|
62 ;; 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
|
63 ;; 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
|
64 ;; 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
|
65 ;; 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
|
66 ;; 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
|
67 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
68 ;; So, here are my opinions/advice/guidelines: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
69 ;; |
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
|
70 ;; - 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
|
71 ;; 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
|
72 ;; 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
|
73 ;; - 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
|
74 ;; i.e., (a) above. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
75 ;; - 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
|
76 ;; 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
|
77 ;; 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
|
78 ;; - 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
|
79 ;; 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
|
80 ;; 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
|
81 ;; 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
|
82 ;; - 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
|
83 ;; 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
|
84 ;; 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
|
85 ;; 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
|
86 ;; - Err, that's it. |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
87 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
88 ;; User variables. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
89 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
90 (defvar font-lock-verbose t |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
91 "*If non-nil, means show status messages when fontifying.") |
4053 | 92 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
93 ;;;###autoload |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
94 (defvar font-lock-maximum-decoration nil |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
95 "*If non-nil, the maximum decoration level for fontifying. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
96 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
|
97 If t, use the maximum decoration available. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
98 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
|
99 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
|
100 where MAJOR-MODE is a symbol or t (meaning the default). For example: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
101 ((c++-mode . 2) (c-mode . t) (t . 1)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
102 means use level 2 decoration for buffers in `c++-mode', the maximum decoration |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
103 available for buffers in `c-mode', and level 1 decoration otherwise.") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
104 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
105 ;;;###autoload |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
106 (defvar font-lock-maximum-size (* 250 1024) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
107 "*If non-nil, the maximum size for buffers for fontifying. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
108 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
|
109 If nil, means size is irrelevant. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
110 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
|
111 where MAJOR-MODE is a symbol or t (meaning the default). For example: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
112 ((c++-mode . 256000) (c-mode . 256000) (rmail-mode . 1048576)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
113 means that the maximum size is 250K for buffers in `c++-mode' or `c-mode', one |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
114 megabyte for buffers in `rmail-mode', and size is irrelevant otherwise.") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
115 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
116 ;; Fontification variables: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
117 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
118 (defvar font-lock-comment-face 'font-lock-comment-face |
4053 | 119 "Face to use for comments.") |
120 | |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
121 (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
|
122 "Face to use for strings.") |
4053 | 123 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
124 (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
|
125 "Face to use for keywords.") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
126 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
127 (defvar font-lock-function-name-face 'font-lock-function-name-face |
4053 | 128 "Face to use for function names.") |
129 | |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
130 (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
|
131 "Face to use for variable names.") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
132 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
133 (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
|
134 "Face to use for type names.") |
4053 | 135 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
136 (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
|
137 "Face to use for reference names.") |
4053 | 138 |
139 (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
|
140 "*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
|
141 Each element should be of the form: |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
142 |
11515
0ebfc7701ebf
Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents:
11467
diff
changeset
|
143 MATCHER |
0ebfc7701ebf
Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents:
11467
diff
changeset
|
144 (MATCHER . MATCH) |
0ebfc7701ebf
Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents:
11467
diff
changeset
|
145 (MATCHER . FACENAME) |
0ebfc7701ebf
Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents:
11467
diff
changeset
|
146 (MATCHER . HIGHLIGHT) |
0ebfc7701ebf
Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents:
11467
diff
changeset
|
147 (MATCHER HIGHLIGHT ...) |
4053 | 148 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
149 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
|
150 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
151 For highlighting single items, typically only MATCH-HIGHLIGHT is required. |
13982 | 152 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
|
153 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
|
154 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
155 MATCH-HIGHLIGHT should be of the form: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
156 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
157 (MATCH FACENAME OVERRIDE LAXMATCH) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
158 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
159 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
|
160 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
|
161 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
|
162 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
|
163 may be defined in `font-lock-face-attributes'. |
4053 | 164 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
165 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
|
166 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
|
167 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
|
168 which the new or existing fontification, respectively, takes precedence. |
13982 | 169 If LAXMATCH is non-nil, no error is signaled if there is no MATCH in MATCHER. |
4053 | 170 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
171 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
|
172 |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
173 \"\\\\\\=<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
|
174 variable `font-lock-keyword-face'. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
175 (\"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
|
176 the value of `font-lock-keyword-face'. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
177 (\"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
|
178 (\"foo\\\\|bar\" 0 foo-bar-face t) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
179 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
|
180 of `foo-bar-face', even if already highlighted. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
181 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
182 MATCH-ANCHORED should be of the form: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
183 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
184 (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
|
185 |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
186 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
|
187 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
195 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
|
196 |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
197 (\"\\\\\\=<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
|
198 |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
199 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
|
200 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
|
201 (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
|
202 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
|
203 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
|
204 for \"item\" concluded.) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
205 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
206 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
|
207 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
|
208 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
209 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
|
210 \\[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
|
211 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
|
212 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
213 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
|
214 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
|
215 (make-variable-buffer-local 'font-lock-keywords) |
4053 | 216 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
217 (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
|
218 "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
|
219 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
|
220 |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
221 (defvar font-lock-defaults-alist |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
222 (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
|
223 ;; 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
|
224 ;; 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
|
225 (c-mode-defaults |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
226 '((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
|
227 c-font-lock-keywords-2 c-font-lock-keywords-3) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
228 nil nil ((?_ . "w")) beginning-of-defun)) |
12385
c80966dc0b60
Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents:
12268
diff
changeset
|
229 (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
|
230 '((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
|
231 c++-font-lock-keywords-2 c++-font-lock-keywords-3) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
232 nil nil ((?_ . "w") (?~ . "w")) beginning-of-defun)) |
12385
c80966dc0b60
Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents:
12268
diff
changeset
|
233 (lisp-mode-defaults |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
234 '((lisp-font-lock-keywords |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
235 lisp-font-lock-keywords-1 lisp-font-lock-keywords-2) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
236 nil nil |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
237 ((?: . "w") (?- . "w") (?* . "w") (?+ . "w") (?. . "w") (?< . "w") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
238 (?> . "w") (?= . "w") (?! . "w") (?? . "w") (?$ . "w") (?% . "w") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
239 (?_ . "w") (?& . "w") (?~ . "w") (?^ . "w") (?/ . "w")) |
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
|
240 beginning-of-defun)) |
c9ed95ec05b6
Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
12626
diff
changeset
|
241 (scheme-mode-defaults |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
242 '(scheme-font-lock-keywords nil t |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
243 ((?: . "w") (?- . "w") (?* . "w") (?+ . "w") (?. . "w") (?< . "w") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
244 (?> . "w") (?= . "w") (?! . "w") (?? . "w") (?$ . "w") (?% . "w") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
245 (?_ . "w") (?& . "w") (?~ . "w") (?^ . "w") (?/ . "w")) |
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
|
246 beginning-of-defun)) |
c9ed95ec05b6
Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
12626
diff
changeset
|
247 ;; For TeX modes we could use `backward-paragraph' for the same reason. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
248 (tex-mode-defaults '(tex-font-lock-keywords nil 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
|
249 ) |
11515
0ebfc7701ebf
Make font-lock.el use compiled keywords; added FN as possible matcher.
Simon Marshall <simon@gnu.org>
parents:
11467
diff
changeset
|
250 (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
|
251 (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
|
252 (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
|
253 (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
|
254 (cons 'c-mode c-mode-defaults) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
255 (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
|
256 (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
|
257 (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
|
258 (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
|
259 (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
|
260 (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
|
261 (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
|
262 (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
|
263 (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
|
264 (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
|
265 (cons 'tex-mode tex-mode-defaults))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
266 "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
|
267 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
|
268 |
c9ed95ec05b6
Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
12626
diff
changeset
|
269 (MAJOR-MODE . (KEYWORDS KEYWORDS-ONLY CASE-FOLD SYNTAX-ALIST SYNTAX-BEGIN)) |
c9ed95ec05b6
Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
12626
diff
changeset
|
270 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
271 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
|
272 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
|
273 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
|
274 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
|
275 when fontifying. If SYNTAX-ALIST is non-nil, it should be a list of cons pairs |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
276 of the form (CHAR . STRING) used to set the local Font Lock syntax table, for |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
277 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
|
278 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
279 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
|
280 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
|
281 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
|
282 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
|
283 `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
|
284 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
|
285 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
|
286 |
c9ed95ec05b6
Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
12626
diff
changeset
|
287 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
|
288 `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
|
289 `font-lock-keywords-case-fold-search', `font-lock-syntax-table' and |
c9ed95ec05b6
Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
12626
diff
changeset
|
290 `font-lock-beginning-of-syntax-function', respectively.") |
c9ed95ec05b6
Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
12626
diff
changeset
|
291 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
292 (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
|
293 "*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
|
294 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
|
295 |
4053 | 296 (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
|
297 "*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
|
298 This is normally set via `font-lock-defaults'.") |
4053 | 299 |
8457
c0492d7043b2
(font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents:
7915
diff
changeset
|
300 (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
|
301 "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
|
302 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
|
303 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
|
304 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
305 ;; 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
|
306 ;; `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
|
307 (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
|
308 "*Non-nil means use this function to move back outside of a syntactic block. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
309 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
|
310 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
|
311 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
312 ;; These record the parse state at a particular position, always the start of a |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
313 ;; line. Used to make `font-lock-fontify-syntactically-region' faster. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
314 (defvar font-lock-cache-position nil) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
315 (defvar font-lock-cache-state nil) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
316 (make-variable-buffer-local 'font-lock-cache-position) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
317 (make-variable-buffer-local 'font-lock-cache-state) |
4053 | 318 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
319 (defvar font-lock-mode nil) ; For the modeline. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
320 (defvar font-lock-fontified nil) ; Whether we have fontified the buffer. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
321 (put 'font-lock-fontified 'permanent-local t) |
10879
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
322 |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
323 ;;;###autoload |
4053 | 324 (defvar font-lock-mode-hook nil |
325 "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
|
326 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
327 ;; User functions. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
328 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
329 ;;;###autoload |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
330 (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
|
331 "Toggle Font Lock mode. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
332 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
|
333 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
334 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
|
335 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
336 - Comments are displayed in `font-lock-comment-face'; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
337 - Strings are displayed in `font-lock-string-face'; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
338 - 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
|
339 value of the variable `font-lock-keywords'. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
340 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
341 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
|
342 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
|
343 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
344 (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
|
345 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
346 Or for any visited file with the following in your ~/.emacs: |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
347 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
348 (add-hook 'find-file-hooks 'turn-on-font-lock) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
349 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
350 The default Font Lock mode faces and their attributes are defined in the |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
351 variable `font-lock-face-attributes', and Font Lock mode default settings in |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
352 the variable `font-lock-defaults-alist'. You can set your own default settings |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
353 for some mode, by setting a buffer local value for `font-lock-defaults', via |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
354 its mode hook. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
355 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
356 Where modes support different levels of fontification, you can use the variable |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
357 `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
|
358 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
|
359 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
|
360 |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
361 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
|
362 size, you can use \\[font-lock-fontify-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
|
363 To fontify a window, perhaps because modification on the current line caused |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
364 syntactic change on other lines, you can use \\[font-lock-fontify-window]." |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
365 (interactive "P") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
366 (let ((on-p (if arg (> (prefix-numeric-value arg) 0) (not font-lock-mode))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
367 (maximum-size (if (not (consp font-lock-maximum-size)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
368 font-lock-maximum-size |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
369 (cdr (or (assq major-mode font-lock-maximum-size) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
370 (assq t 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
|
371 ;; Don't turn on Font Lock mode if we don't have a display (we're running a |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
372 ;; batch job) or if the buffer is invisible (the name starts with a space). |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
373 (if (or noninteractive (eq (aref (buffer-name) 0) ?\ )) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
374 (setq on-p nil)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
375 (if (not on-p) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
376 (remove-hook 'after-change-functions 'font-lock-after-change-function |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
377 t) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
378 (make-local-hook 'after-change-functions) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
379 (add-hook 'after-change-functions 'font-lock-after-change-function |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
380 nil t)) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
381 (set (make-local-variable 'font-lock-mode) on-p) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
382 (cond (on-p |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
383 (font-lock-set-defaults) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
384 (make-local-hook 'before-revert-hook) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
385 (make-local-hook 'after-revert-hook) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
386 ;; If buffer is reverted, must clean up the state. |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
387 (add-hook 'before-revert-hook 'font-lock-revert-setup nil t) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
388 (add-hook 'after-revert-hook 'font-lock-revert-cleanup nil t) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
389 (run-hooks 'font-lock-mode-hook) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
390 (cond (font-lock-fontified |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
391 nil) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
392 ((or (null maximum-size) (<= (buffer-size) maximum-size)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
393 (font-lock-fontify-buffer)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
394 (font-lock-verbose |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
395 (message "Fontifying %s... buffer too big." (buffer-name))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
396 (font-lock-fontified |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
397 (setq font-lock-fontified nil) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
398 (remove-hook 'before-revert-hook 'font-lock-revert-setup t) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
399 (remove-hook 'after-revert-hook 'font-lock-revert-cleanup 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
|
400 ;; Make sure we unfontify 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
|
401 (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
|
402 (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
|
403 (font-lock-unfontify-region (point-min) (point-max)) |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
404 (font-lock-thing-lock-cleanup))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
405 (t |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
406 (remove-hook 'before-revert-hook 'font-lock-revert-setup t) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
407 (remove-hook 'after-revert-hook 'font-lock-revert-cleanup t) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
408 (font-lock-thing-lock-cleanup))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
409 (force-mode-line-update))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
410 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
411 ;;;###autoload |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
412 (defun turn-on-font-lock () |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
413 "Unconditionally turn on Font Lock mode." |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
414 (font-lock-mode 1)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
415 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
416 ;;;###autoload |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
417 (defun font-lock-fontify-buffer () |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
418 "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
|
419 (interactive) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
420 (let ((verbose (and (or font-lock-verbose (interactive-p)) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
421 (not (zerop (buffer-size)))))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
422 (set (make-local-variable 'font-lock-fontified) nil) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
423 (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
|
424 ;; 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
|
425 (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
|
426 ;; 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
|
427 (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
|
428 (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
|
429 (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
|
430 (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
|
431 (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
|
432 (font-lock-fontify-region (point-min) (point-max) verbose) |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
433 (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
|
434 ;; We don't restore the old fontification, so it's best to unfontify. |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
435 (quit (font-lock-unfontify-region (point-min) (point-max)))) |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
436 (if verbose (message "Fontifying %s... %s." (buffer-name) |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
437 (if font-lock-fontified "done" "aborted"))) |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
438 (font-lock-after-fontify-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
|
439 |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
440 (defun font-lock-fontify-window () |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
441 "Fontify the current window the way `font-lock-mode' would." |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
442 (interactive) |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
443 (let ((font-lock-beginning-of-syntax-function 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
|
444 (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
|
445 (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
|
446 (font-lock-fontify-region (window-start) (window-end)))))) |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
447 |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
448 (define-key global-map [?\C-\S-l] 'font-lock-fontify-window) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
449 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
450 ;; Fontification functions. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
451 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
452 ;; 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
|
453 ;; 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
|
454 ;; back-compatible. But you shouldn't be calling these directly, should you? |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
455 (defun font-lock-fontify-region (beg end &optional loudly) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
456 (let ((modified (buffer-modified-p)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
457 (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
|
458 (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
|
459 before-change-functions after-change-functions |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
460 buffer-file-name buffer-file-truename) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
461 (unwind-protect |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
462 (progn |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
463 ;; Use the fontification syntax table, if any. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
464 (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
|
465 ;; Now do the fontification. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
466 (if font-lock-keywords-only |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
467 (font-lock-unfontify-region beg end) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
468 (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
|
469 (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
|
470 ;; Clean up. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
471 (set-syntax-table old-syntax-table) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
472 (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
|
473 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
474 ;; 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
|
475 ; ;; 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
|
476 ; (or (and (not font-lock-keywords-only) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
477 ; (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
|
478 ; font-lock-cache-state))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
479 ; (or (nth 4 state) (nth 7 state)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
480 ; (font-lock-fontify-keywords-region beg end)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
481 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
482 (defun font-lock-unfontify-region (beg end) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
483 (let ((modified (buffer-modified-p)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
484 (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
|
485 before-change-functions after-change-functions |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
486 buffer-file-name buffer-file-truename) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
487 (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
|
488 (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
|
489 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
490 ;; 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
|
491 (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
|
492 (save-excursion |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
493 (save-match-data |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
494 ;; 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
|
495 (font-lock-fontify-region |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
496 (progn (goto-char beg) (beginning-of-line) (point)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
497 (progn (goto-char end) (forward-line 1) (point)))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
498 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
499 ;; Syntactic fontification functions. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
500 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
501 (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
|
502 "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
|
503 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
|
504 (let ((synstart (if comment-start-skip |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
505 (concat "\\s\"\\|" comment-start-skip) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
506 "\\s\"")) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
507 (comstart (if comment-start-skip |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
508 (concat "\\s<\\|" comment-start-skip) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
509 "\\s<")) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
510 state prev prevstate) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
511 (if loudly (message "Fontifying %s... (syntactically...)" (buffer-name))) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
512 (save-restriction |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
513 (widen) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
514 (goto-char start) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
515 ;; |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
516 ;; Find the state at the `beginning-of-line' before `start'. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
517 (if (eq start font-lock-cache-position) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
518 ;; Use the cache for the state of `start'. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
519 (setq state font-lock-cache-state) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
520 ;; Find the state of `start'. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
521 (if (null font-lock-beginning-of-syntax-function) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
522 ;; Use the state at the previous cache position, if any, or |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
523 ;; otherwise calculate from `point-min'. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
524 (if (or (null font-lock-cache-position) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
525 (< start font-lock-cache-position)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
526 (setq state (parse-partial-sexp (point-min) start)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
527 (setq state (parse-partial-sexp font-lock-cache-position start |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
528 nil nil font-lock-cache-state))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
529 ;; Call the function to move outside any syntactic block. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
530 (funcall font-lock-beginning-of-syntax-function) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
531 (setq state (parse-partial-sexp (point) start))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
532 ;; Cache the state and position of `start'. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
533 (setq font-lock-cache-state state |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
534 font-lock-cache-position start)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
535 ;; |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
536 ;; If the region starts inside a string, show the extent of it. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
537 (if (nth 3 state) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
538 (let ((beg (point))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
539 (while (and (re-search-forward "\\s\"" end 'move) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
540 (nth 3 (parse-partial-sexp beg (point) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
541 nil nil state)))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
542 (put-text-property beg (point) 'face font-lock-string-face) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
543 (setq state (parse-partial-sexp beg (point) nil nil state)))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
544 ;; |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
545 ;; Likewise for a comment. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
546 (if (or (nth 4 state) (nth 7 state)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
547 (let ((beg (point))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
548 (save-restriction |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
549 (narrow-to-region (point-min) end) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
550 (condition-case nil |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
551 (progn |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
552 (re-search-backward comstart (point-min) 'move) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
553 (forward-comment 1) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
554 ;; forward-comment skips all whitespace, |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
555 ;; so go back to the real end of the comment. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
556 (skip-chars-backward " \t")) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
557 (error (goto-char end)))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
558 (put-text-property beg (point) 'face font-lock-comment-face) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
559 (setq state (parse-partial-sexp beg (point) nil nil state)))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
560 ;; |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
561 ;; Find each interesting place between here and `end'. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
562 (while (and (< (point) end) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
563 (setq prev (point) prevstate state) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
564 (re-search-forward synstart end t) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
565 (progn |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
566 ;; Clear out the fonts of what we skip over. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
567 (remove-text-properties prev (point) '(face nil)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
568 ;; Verify the state at that place |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
569 ;; so we don't get fooled by \" or \;. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
570 (setq state (parse-partial-sexp prev (point) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
571 nil nil state)))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
572 (let ((here (point))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
573 (if (or (nth 4 state) (nth 7 state)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
574 ;; |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
575 ;; We found a real comment start. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
576 (let ((beg (match-beginning 0))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
577 (goto-char beg) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
578 (save-restriction |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
579 (narrow-to-region (point-min) end) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
580 (condition-case nil |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
581 (progn |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
582 (forward-comment 1) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
583 ;; forward-comment skips all whitespace, |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
584 ;; so go back to the real end of the comment. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
585 (skip-chars-backward " \t")) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
586 (error (goto-char end)))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
587 (put-text-property beg (point) 'face |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
588 font-lock-comment-face) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
589 (setq state (parse-partial-sexp here (point) nil nil state))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
590 (if (nth 3 state) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
591 ;; |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
592 ;; We found a real string start. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
593 (let ((beg (match-beginning 0))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
594 (while (and (re-search-forward "\\s\"" end 'move) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
595 (nth 3 (parse-partial-sexp here (point) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
596 nil nil state)))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
597 (put-text-property beg (point) 'face font-lock-string-face) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
598 (setq state (parse-partial-sexp here (point) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
599 nil nil state)))))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
600 ;; |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
601 ;; Make sure `prev' is non-nil after the loop |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
602 ;; only if it was set on the very last iteration. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
603 (setq prev nil))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
604 ;; |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
605 ;; Clean up. |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
606 (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
|
607 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
608 ;;; Additional text property functions. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
609 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
610 ;; 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
|
611 ;; 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
|
612 ;; 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
|
613 ;; 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
|
614 ;; 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
|
615 ;; 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
|
616 ;; 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
|
617 ;; added? In our implementation, the first duplicate remains. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
618 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
619 (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
|
620 "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
|
621 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
|
622 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
|
623 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
|
624 (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
|
625 (while start |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
626 (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
|
627 (put-text-property start next prop value object) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
628 (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
|
629 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
630 ;; 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
|
631 ;(defun unique (list function) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
632 ; "Uniquify LIST, deleting elements using FUNCTION. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
633 ;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
|
634 ;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
|
635 ;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
|
636 ;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
|
637 ;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
|
638 ; (let ((list list)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
639 ; (while list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
640 ; (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
|
641 ; list) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
642 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
643 (defsubst font-lock-unique (list) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
644 "Uniquify LIST, deleting elements using `delq'. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
645 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
|
646 (let ((list list)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
647 (while list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
648 (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
|
649 list) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
650 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
651 ;; 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
|
652 ;; 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
|
653 ;; 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
|
654 (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
|
655 "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
|
656 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
|
657 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
|
658 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
|
659 (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
|
660 (while (/= start end) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
661 (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
|
662 prev (get-text-property start prop object)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
663 (put-text-property |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
664 start next prop |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
665 (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
|
666 object) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
667 (setq start next)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
668 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
669 (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
|
670 "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
|
671 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
|
672 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
|
673 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
|
674 (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
|
675 (while (/= start end) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
676 (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
|
677 prev (get-text-property start prop object)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
678 (put-text-property |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
679 start next prop |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
680 (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
|
681 object) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
682 (setq start next)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
683 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
684 ;;; Regexp fontification functions. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
685 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
686 (defsubst font-lock-apply-highlight (highlight) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
687 "Apply HIGHLIGHT following a match. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
688 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
|
689 (let* ((match (nth 0 highlight)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
690 (start (match-beginning match)) (end (match-end match)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
691 (override (nth 2 highlight))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
692 (cond ((not start) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
693 ;; 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
|
694 (or (nth 3 highlight) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
695 (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
|
696 ((not override) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
697 ;; Cannot override existing fontification. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
698 (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
|
699 (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
|
700 ((eq override t) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
701 ;; Override existing fontification. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
702 (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
|
703 ((eq override 'keep) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
704 ;; Keep existing fontification. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
705 (font-lock-fillin-text-property start end 'face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
706 (eval (nth 1 highlight)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
707 ((eq override 'prepend) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
708 ;; Prepend to existing fontification. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
709 (font-lock-prepend-text-property start end 'face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
710 (eval (nth 1 highlight)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
711 ((eq override 'append) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
712 ;; Append to existing fontification. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
713 (font-lock-append-text-property start end 'face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
714 (eval (nth 1 highlight))))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
715 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
716 (defsubst font-lock-fontify-anchored-keywords (keywords limit) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
717 "Fontify according to KEYWORDS until LIMIT. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
718 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
|
719 (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
|
720 ;; 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
|
721 (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
|
722 ;; Evaluate PRE-MATCH-FORM. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
723 (eval (nth 1 keywords)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
724 (save-match-data |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
725 ;; Find an occurrence of `matcher' before `limit'. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
726 (while (if (stringp matcher) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
727 (re-search-forward matcher limit t) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
728 (funcall matcher limit)) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
729 ;; 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
|
730 (setq highlights lowdarks) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
731 (while highlights |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
732 (font-lock-apply-highlight (car highlights)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
733 (setq highlights (cdr highlights))))) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
734 ;; Evaluate POST-MATCH-FORM. |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
735 (eval (nth 2 keywords)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
736 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
737 (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
|
738 "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
|
739 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
|
740 (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
|
741 (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
|
742 font-lock-keywords |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
743 (font-lock-compile-keywords)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
744 (bufname (buffer-name)) (count 0) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
745 keyword matcher highlights) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
746 ;; |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
747 ;; 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
|
748 (while keywords |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
749 (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
|
750 (make-string (setq count (1+ count)) ?.))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
751 ;; |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
752 ;; 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
|
753 (setq keyword (car keywords) matcher (car keyword)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
754 (goto-char start) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
755 (while (if (stringp matcher) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
756 (re-search-forward matcher end t) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
757 (funcall matcher end)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
758 ;; 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
|
759 ;; 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
|
760 (setq highlights (cdr keyword)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
761 (while highlights |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
762 (if (numberp (car (car highlights))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
763 (font-lock-apply-highlight (car highlights)) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
764 (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
|
765 (setq highlights (cdr highlights)))) |
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
766 (setq keywords (cdr keywords))))) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
767 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
768 ;; Various functions. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
769 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
770 ;; Turn off other related packages if they're on. I prefer a hook. --sm. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
771 ;; These explicit calls are easier to understand |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
772 ;; because people know what they will do. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
773 ;; A hook is a mystery because it might do anything whatever. --rms. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
774 (defun font-lock-thing-lock-cleanup () |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
775 (cond ((and (boundp 'fast-lock-mode) fast-lock-mode) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
776 (fast-lock-mode -1)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
777 ((and (boundp 'lazy-lock-mode) lazy-lock-mode) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
778 (lazy-lock-mode -1)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
779 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
780 ;; Do something special for these packages after fontifying. I prefer a hook. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
781 (defun font-lock-after-fontify-buffer () |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
782 (cond ((and (boundp 'fast-lock-mode) fast-lock-mode) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
783 (fast-lock-after-fontify-buffer)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
784 ((and (boundp 'lazy-lock-mode) lazy-lock-mode) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
785 (lazy-lock-after-fontify-buffer)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
786 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
787 ;; If the buffer is about to be reverted, it won't be fontified afterward. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
788 (defun font-lock-revert-setup () |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
789 (setq font-lock-fontified nil)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
790 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
791 ;; If the buffer has just been reverted, normally that turns off |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
792 ;; Font Lock mode. So turn the mode back on if necessary. |
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
|
793 (defalias 'font-lock-revert-cleanup |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
794 'turn-on-font-lock) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
795 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
796 (defun font-lock-compile-keywords (&optional keywords) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
797 ;; 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
|
798 ;; 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
|
799 (let ((keywords (or keywords font-lock-keywords))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
800 (setq font-lock-keywords |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
801 (if (eq (car-safe keywords) t) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
802 keywords |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
803 (cons t |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
804 (mapcar |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
805 (function (lambda (item) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
806 (cond ((nlistp item) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
807 (list item '(0 font-lock-keyword-face))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
808 ((numberp (cdr item)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
809 (list (car item) (list (cdr item) 'font-lock-keyword-face))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
810 ((symbolp (cdr item)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
811 (list (car item) (list 0 (cdr item)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
812 ((nlistp (nth 1 item)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
813 (list (car item) (cdr item))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
814 (t |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
815 item)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
816 keywords)))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
817 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
818 (defun font-lock-choose-keywords (keywords level) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
819 ;; 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
|
820 ;; LEVEL of 0, a LEVEL of t is equal to (1- (length KEYWORDS)). |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
821 (let ((level (if (not (consp level)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
822 level |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
823 (cdr (or (assq major-mode level) (assq t level)))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
824 (cond ((symbolp keywords) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
825 keywords) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
826 ((numberp level) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
827 (or (nth level keywords) (car (reverse keywords)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
828 ((eq level t) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
829 (car (reverse keywords))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
830 (t |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
831 (car keywords))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
832 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
833 (defun font-lock-set-defaults () |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
834 "Set fontification defaults appropriately for this mode. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
835 Sets `font-lock-keywords', `font-lock-keywords-only', `font-lock-syntax-table', |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
836 `font-lock-beginning-of-syntax-function' and |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
837 `font-lock-keywords-case-fold-search' using `font-lock-defaults' (or, if nil, |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
838 using `font-lock-defaults-alist') and `font-lock-maximum-decoration'." |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
839 ;; Set face defaults. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
840 (font-lock-make-faces) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
841 ;; Set fontification defaults. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
842 (or font-lock-keywords |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
843 (let* ((defaults (or font-lock-defaults |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
844 (cdr (assq major-mode font-lock-defaults-alist)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
845 (keywords (font-lock-choose-keywords |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
846 (nth 0 defaults) font-lock-maximum-decoration))) |
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
|
847 ;; Regexp fontification? |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
848 (setq font-lock-keywords (if (fboundp keywords) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
849 (funcall keywords) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
850 (eval keywords))) |
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
|
851 ;; Syntactic fontification? |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
852 (if (nth 1 defaults) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
853 (set (make-local-variable 'font-lock-keywords-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
|
854 ;; Case fold during regexp fontification? |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
855 (if (nth 2 defaults) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
856 (set (make-local-variable 'font-lock-keywords-case-fold-search) 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
|
857 ;; Syntax table for regexp and syntactic fontification? |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
858 (if (nth 3 defaults) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
859 (let ((slist (nth 3 defaults))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
860 (set (make-local-variable 'font-lock-syntax-table) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
861 (copy-syntax-table (syntax-table))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
862 (while slist |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
863 (modify-syntax-entry (car (car slist)) (cdr (car slist)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
864 font-lock-syntax-table) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
865 (setq slist (cdr slist))))) |
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
|
866 ;; Syntax function for syntactic fontification? |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
867 (if (nth 4 defaults) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
868 (set (make-local-variable 'font-lock-beginning-of-syntax-function) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
869 (nth 4 defaults)))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
870 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
871 ;; Colour etc. support. |
4053 | 872 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
873 (defvar font-lock-display-type nil |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
874 "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
|
875 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
|
876 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
|
877 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
|
878 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
|
879 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
880 (defvar font-lock-background-mode nil |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
881 "A symbol indicating the Emacs background brightness. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
882 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
|
883 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
|
884 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
|
885 `~/.Xdefaults'. |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
886 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
|
887 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
888 (defvar font-lock-face-attributes nil |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
889 "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
|
890 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
|
891 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
892 (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
|
893 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
894 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
|
895 `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
|
896 `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
|
897 `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
|
898 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
|
899 used in highlighting. See `font-lock-keywords'. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
900 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
901 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
|
902 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
|
903 \(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
|
904 corresponding face attributes (yes if non-nil). |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
905 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
906 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
|
907 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
|
908 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
909 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
|
910 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
|
911 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
|
912 |
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
|
913 (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
|
914 "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
|
915 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
|
916 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
|
917 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
|
918 ;; 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
|
919 ;; 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
|
920 (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
|
921 (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
|
922 (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
|
923 "DisplayType"))) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
924 (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
|
925 ((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
|
926 ((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
|
927 (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
|
928 (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
|
929 (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
|
930 (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
|
931 "BackgroundMode")) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
932 (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
|
933 (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
|
934 ((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
|
935 (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
|
936 (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
|
937 'light |
1233bea2cb02
(font-lock-make-faces): Add special code for ms-dos.
Richard M. Stallman <rms@gnu.org>
parents:
13452
diff
changeset
|
938 'dark)) |
11467
bb7c9db199ae
(font-lock-make-faces): Determine font-lock-background-mode from color
Richard M. Stallman <rms@gnu.org>
parents:
10879
diff
changeset
|
939 ((< (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
|
940 (cdr (assq 'background-color params)))) |
bb7c9db199ae
(font-lock-make-faces): Determine font-lock-background-mode from color
Richard M. Stallman <rms@gnu.org>
parents:
10879
diff
changeset
|
941 (/ (apply '+ (x-color-values "white")) 3)) |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
942 'dark) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
943 (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
|
944 (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
|
945 (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
|
946 (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
|
947 (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
|
948 ;; 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
|
949 ;;'((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
|
950 ;; (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
|
951 ;; (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
|
952 ;; (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
|
953 ;; (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
|
954 (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
|
955 '(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
|
956 '(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
|
957 (list |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
958 '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
|
959 (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
|
960 (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
|
961 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
|
962 '(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
|
963 '(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
|
964 '(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
|
965 ((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
|
966 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
|
967 (list |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
968 (list 'font-lock-comment-face |
12484
bf638e2849d5
(font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents:
12385
diff
changeset
|
969 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
|
970 (list 'font-lock-string-face |
12484
bf638e2849d5
(font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents:
12385
diff
changeset
|
971 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
|
972 (list 'font-lock-keyword-face |
12484
bf638e2849d5
(font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents:
12385
diff
changeset
|
973 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
|
974 (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
|
975 (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
|
976 (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
|
977 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
|
978 (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
|
979 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
|
980 (list 'font-lock-type-face |
12484
bf638e2849d5
(font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents:
12385
diff
changeset
|
981 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
|
982 (list 'font-lock-reference-face |
12484
bf638e2849d5
(font-lock-make-faces): On grayscale screen,
Richard M. Stallman <rms@gnu.org>
parents:
12385
diff
changeset
|
983 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
|
984 (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
|
985 '((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
|
986 (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
|
987 (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
|
988 (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
|
989 (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
|
990 (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
|
991 (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
|
992 (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
|
993 '((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
|
994 (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
|
995 (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
|
996 (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
|
997 (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
|
998 (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
|
999 (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
|
1000 ;; 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
|
1001 (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
|
1002 (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
|
1003 (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
|
1004 (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
|
1005 ;; 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
|
1006 (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
|
1007 ((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
|
1008 ;; 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
|
1009 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
|
1010 ((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
|
1011 ;; 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
|
1012 (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
|
1013 (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
|
1014 ;; 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
|
1015 (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
|
1016 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
|
1017 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1018 (defun font-lock-make-face (face-attributes) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1019 "Make a face from FACE-ATTRIBUTES. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1020 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
|
1021 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
|
1022 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
|
1023 (let* ((face (nth 0 face-attributes)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1024 (face-name (symbol-name face)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1025 (set-p (function (lambda (face-name resource) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1026 (x-get-resource (concat face-name ".attribute" resource) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1027 (concat "Face.Attribute" resource))))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1028 (on-p (function (lambda (face-name resource) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1029 (let ((set (funcall set-p face-name resource))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1030 (and set (member (downcase set) '("on" "true")))))))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1031 (make-face face) |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1032 (add-to-list 'facemenu-unlisted-faces face) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1033 ;; 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
|
1034 (or (funcall set-p face-name "Foreground") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1035 (condition-case nil |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1036 (set-face-foreground face (nth 1 face-attributes)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1037 (error nil))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1038 (or (funcall set-p face-name "Background") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1039 (condition-case nil |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1040 (set-face-background face (nth 2 face-attributes)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1041 (error nil))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1042 (if (funcall set-p face-name "Bold") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1043 (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
|
1044 (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
|
1045 (if (funcall set-p face-name "Italic") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1046 (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
|
1047 (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
|
1048 (or (funcall set-p face-name "Underline") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1049 (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
|
1050 (set face face))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1051 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1052 ;;; Various regexp information shared by several modes. |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1053 ;;; Information specific to a single mode should go in its load library. |
4053 | 1054 |
1055 (defconst lisp-font-lock-keywords-1 | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1056 (list |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1057 ;; 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
|
1058 ;; 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
|
1059 ;; 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
|
1060 (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
|
1061 ;; 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
|
1062 "\\(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
|
1063 ;; 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
|
1064 "\\(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
|
1065 ;; 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
|
1066 "\\([^ \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
|
1067 "\\)\\)\\>" |
c9ed95ec05b6
Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
12626
diff
changeset
|
1068 ;; 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
|
1069 "[ \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
|
1070 "\\(\\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
|
1071 '(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
|
1072 '(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
|
1073 ((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
|
1074 (t font-lock-function-name-face)) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1075 nil t)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1076 ) |
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
|
1077 "Subdued level highlighting for Lisp modes.") |
4053 | 1078 |
1079 (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
|
1080 (append lisp-font-lock-keywords-1 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1081 (list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1082 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1083 ;; 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
|
1084 ; (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
|
1085 ; '("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
|
1086 ; "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
|
1087 ; "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
|
1088 ; "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
|
1089 ; "eval-after-load" "eval-and-compile" "eval-when-compile" |
c9ed95ec05b6
Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
12626
diff
changeset
|
1090 ; "when" "unless" "do" "flet" "labels" "return" "return-from")) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1091 (cons |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1092 (concat |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1093 "(\\(" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1094 "\\(c\\(atch\\|ond\\(\\|ition-case\\)\\)\\|do\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1095 "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
|
1096 "i\\(f\\|nline\\)\\|l\\(abels\\|et\\*?\\)\\|prog[nv12*]?\\|" |
1dab6f0d9239
Don't turn on in any buffer with a leading space in its name.
Simon Marshall <simon@gnu.org>
parents:
13641
diff
changeset
|
1097 "return\\(\\|-from\\)\\|" |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1098 "save-\\(excursion\\|match-data\\|restriction\\|selected-window\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1099 "window-excursion\\)\\|t\\(hrow\\|rack-mouse\\)\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1100 "un\\(less\\|wind-protect\\)\\|wh\\(en\\|ile\\)\\)" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1101 "\\)\\>") 1) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1102 ;; |
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
|
1103 ;; 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
|
1104 '("(\\(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
|
1105 (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
|
1106 ;; |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1107 ;; 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
|
1108 '("\\\\\\\\\\[\\(\\sw+\\)]" 1 font-lock-reference-face prepend) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1109 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1110 ;; Words inside `' tend to be symbol names. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1111 '("`\\(\\sw\\sw+\\)'" 1 font-lock-reference-face prepend) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1112 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1113 ;; CLisp `:' keywords as references. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1114 '("\\<:\\sw+\\>" 0 font-lock-reference-face prepend) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1115 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1116 ;; ELisp and CLisp `&' keywords as types. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1117 '("\\<\\&\\(optional\\|rest\\|whole\\)\\>" . font-lock-type-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1118 )) |
12385
c80966dc0b60
Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents:
12268
diff
changeset
|
1119 "Gaudy level highlighting for Lisp modes.") |
4053 | 1120 |
12385
c80966dc0b60
Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents:
12268
diff
changeset
|
1121 (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
|
1122 "Default expressions to highlight in Lisp modes.") |
4053 | 1123 |
1124 | |
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
|
1125 (defvar scheme-font-lock-keywords |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1126 (eval-when-compile |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1127 (list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1128 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1129 ;; 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
|
1130 ;; 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
|
1131 (list (concat "(\\(define\\(" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1132 ;; Function names. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1133 "\\(\\|-\\(generic\\(\\|-procedure\\)\\|method\\)\\)\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1134 ;; 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
|
1135 "\\(-syntax\\)\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1136 ;; Class names. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1137 "\\(-class\\)" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1138 "\\)\\)\\>" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1139 ;; Any whitespace and declared object. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1140 "[ \t]*(?" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1141 "\\(\\sw+\\)?") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1142 '(1 font-lock-keyword-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1143 '(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
|
1144 ((match-beginning 6) font-lock-variable-name-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1145 (t font-lock-type-face)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1146 nil t)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1147 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1148 ;; 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
|
1149 ;(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
|
1150 ; "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
|
1151 ; "do" "else" "for-each" "if" "lambda" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1152 ; "let\\*?" "let-syntax" "letrec" "letrec-syntax" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1153 ; ;; 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
|
1154 ; "and" "or" "delay" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1155 ; ;; 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
|
1156 ; ;;"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
|
1157 ; "map" "syntax" "syntax-rules")) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1158 (cons |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1159 (concat "(\\(" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1160 "and\\|begin\\|c\\(a\\(ll\\(-with-\\(current-continuation\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1161 "input-file\\|output-file\\)\\|/cc\\)\\|se\\)\\|ond\\)\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1162 "d\\(elay\\|o\\)\\|else\\|for-each\\|if\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1163 "l\\(ambda\\|et\\(-syntax\\|\\*?\\|rec\\(\\|-syntax\\)\\)\\)\\|" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1164 "map\\|or\\|syntax\\(\\|-rules\\)" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1165 "\\)\\>") 1) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1166 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1167 ;; 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
|
1168 '("\\<<\\sw+>\\>" . font-lock-type-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1169 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1170 ;; Scheme `:' keywords as references. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1171 '("\\<:\\sw+\\>" . font-lock-reference-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1172 )) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1173 "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
|
1174 |
c9ed95ec05b6
Functionality for font-lock-beginning-of-syntax-function to be used by font-lock-fontify-region when calculating the cache state. Also wrap value of buffer-file-truename to guard against clash detection. Also add scheme-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
12626
diff
changeset
|
1175 |
4053 | 1176 (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
|
1177 "Subdued level highlighting for C modes.") |
4053 | 1178 |
1179 (defconst c-font-lock-keywords-2 nil | |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1180 "Medium level highlighting for C modes.") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1181 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1182 (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
|
1183 "Gaudy level highlighting for C modes.") |
4053 | 1184 |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
1185 (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
|
1186 "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
|
1187 |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
1188 (defconst c++-font-lock-keywords-2 nil |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1189 "Medium level highlighting for C++ modes.") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1190 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1191 (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
|
1192 "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
|
1193 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1194 (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
|
1195 ;; 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
|
1196 ;; 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
|
1197 ;; 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
|
1198 ;; 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
|
1199 ;; are expected to be separated with a "," or ";". |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1200 (if (looking-at "[ \t*&]*\\(\\sw+\\)\\(::\\(\\sw+\\)\\)?[ \t]*\\((\\)?") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1201 (save-match-data |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1202 (condition-case nil |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1203 (save-restriction |
13440
e8cd2c9309c8
1. Use local hooks, not local variables.
Simon Marshall <simon@gnu.org>
parents:
13337
diff
changeset
|
1204 ;; 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
|
1205 (narrow-to-region (point-min) limit) |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1206 (goto-char (match-end 1)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1207 ;; 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
|
1208 (while (not (looking-at "[ \t]*\\([,;]\\|$\\)")) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1209 (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
|
1210 (goto-char (match-end 0))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1211 (error t))))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1212 |
9487
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 ((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
|
1214 ; ("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
|
1215 "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
|
1216 (c-type-types |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1217 ; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum" |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1218 ; "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
|
1219 ; "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
|
1220 (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
|
1221 "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
|
1222 "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
|
1223 "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
|
1224 (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
|
1225 ; ("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
|
1226 ; "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
|
1227 ; "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
|
1228 (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
|
1229 "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
|
1230 "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
|
1231 "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
|
1232 (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
|
1233 ; ("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
|
1234 ; "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
|
1235 ; "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
|
1236 ; "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
|
1237 (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
|
1238 "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
|
1239 "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
|
1240 "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
|
1241 "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
|
1242 "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
|
1243 ) |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
1244 (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
|
1245 (list |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
1246 ;; |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1247 ;; 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
|
1248 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1249 ;; 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
|
1250 (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
|
1251 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1252 ;; 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
|
1253 '("^#[ \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
|
1254 ;; |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1255 ;; 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
|
1256 '("^#[ \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
|
1257 ;; |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1258 ;; Fontify symbol names in #if ... defined preprocessor directives. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1259 '("^#[ \t]*if\\>" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1260 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1261 (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
|
1262 ;; |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1263 ;; 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
|
1264 '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?" |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1265 (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
|
1266 )) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
1267 |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
1268 (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
|
1269 (append c-font-lock-keywords-1 |
4053 | 1270 (list |
1271 ;; | |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1272 ;; Simple regexps for speed. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1273 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1274 ;; 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
|
1275 (cons (concat "\\<\\(" c-type-types "\\)\\>") 'font-lock-type-face) |
4053 | 1276 ;; |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1277 ;; 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
|
1278 (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
|
1279 ;; |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1280 ;; 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
|
1281 '("\\<\\(case\\|goto\\)\\>[ \t]*\\(\\sw+\\)?" |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1282 (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
|
1283 '("^[ \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
|
1284 ))) |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
1285 |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1286 (setq c-font-lock-keywords-3 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1287 (append c-font-lock-keywords-2 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1288 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1289 ;; 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
|
1290 ;; 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
|
1291 (list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1292 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1293 ;; 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
|
1294 (list (concat "\\<\\(" c-type-types "\\)\\>" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1295 "\\([ \t*&]+\\sw+\\>\\)*") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1296 ;; Fontify each declaration item. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1297 '(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
|
1298 ;; Start with point after all type specifiers. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1299 (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
|
1300 ;; Finish with point after first type specifier. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1301 (goto-char (match-end 1)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1302 ;; Fontify as a variable or function name. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1303 (1 (if (match-beginning 4) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1304 font-lock-function-name-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1305 font-lock-variable-name-face)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1306 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1307 ;; Fontify structures, or typedef names, plus their items. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1308 '("\\(}\\)[ \t*]*\\sw" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1309 (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
|
1310 (goto-char (match-end 1)) nil |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1311 (1 (if (match-beginning 4) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1312 font-lock-function-name-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1313 font-lock-variable-name-face)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1314 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1315 ;; 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
|
1316 '("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1317 (1 font-lock-type-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1318 (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
|
1319 (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
|
1320 (1 (if (match-beginning 4) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1321 font-lock-function-name-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1322 font-lock-variable-name-face)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1323 ))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1324 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1325 (setq c++-font-lock-keywords-1 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1326 (append |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1327 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1328 ;; 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
|
1329 (cdr c-font-lock-keywords-1) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1330 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1331 ;; Fontify function name definitions, possibly incorporating class name. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1332 (list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1333 '("^\\(\\sw+\\)\\(::\\(\\sw+\\)\\)?[ \t]*(" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1334 (1 (if (match-beginning 2) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1335 font-lock-type-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1336 font-lock-function-name-face)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1337 (3 (if (match-beginning 2) font-lock-function-name-face) nil t)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1338 ))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1339 |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
1340 (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
|
1341 (append c++-font-lock-keywords-1 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1342 (list |
13299
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1343 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1344 ;; 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
|
1345 (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
|
1346 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1347 ;; Fontify operator function name overloading. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1348 '("\\<\\(operator\\)\\>[ \t]*\\([][)(><!=+-][][)(><!=+-]?\\)?" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1349 (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
|
1350 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1351 ;; 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
|
1352 '("\\<\\(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
|
1353 (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
|
1354 '("^[ \t]*\\(\\sw+\\)[ \t]*:[^:]" 1 font-lock-reference-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1355 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1356 ;; Fontify other builtin keywords. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1357 (cons (concat "\\<\\(" c++-keywords "\\)\\>") 'font-lock-keyword-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1358 ))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1359 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1360 (setq c++-font-lock-keywords-3 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1361 (append c++-font-lock-keywords-2 |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1362 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1363 ;; 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
|
1364 (list |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1365 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1366 ;; 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
|
1367 (list (concat "\\<\\(" c++-type-types "\\)\\>" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1368 "\\([ \t*&]+\\sw+\\>\\)*") |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1369 ;; Fontify each declaration item. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1370 '(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
|
1371 ;; Start with point after all type specifiers. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1372 (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
|
1373 ;; Finish with point after first type specifier. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1374 (goto-char (match-end 1)) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1375 ;; Fontify as a variable or function name. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1376 (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
|
1377 ((match-beginning 4) font-lock-function-name-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1378 (t font-lock-variable-name-face))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1379 (3 (if (match-beginning 4) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1380 font-lock-function-name-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1381 font-lock-variable-name-face) nil t))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1382 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1383 ;; Fontify structures, or typedef names, plus their items. |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1384 '("\\(}\\)[ \t*]*\\sw" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1385 (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
|
1386 (goto-char (match-end 1)) nil |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1387 (1 (if (match-beginning 4) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1388 font-lock-function-name-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1389 font-lock-variable-name-face)))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1390 ;; |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1391 ;; 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
|
1392 '("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*" |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1393 (1 font-lock-type-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1394 (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
|
1395 (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
|
1396 (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
|
1397 ((match-beginning 4) font-lock-function-name-face) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1398 (t font-lock-variable-name-face))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1399 (3 (if (match-beginning 4) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1400 font-lock-function-name-face |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1401 font-lock-variable-name-face) nil t))) |
d6bfe124472c
General reorganisation; moving and renaming etc.
Simon Marshall <simon@gnu.org>
parents:
12813
diff
changeset
|
1402 ))) |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
1403 ) |
4053 | 1404 |
12385
c80966dc0b60
Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents:
12268
diff
changeset
|
1405 (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
|
1406 "Default expressions to highlight in C mode.") |
4053 | 1407 |
12385
c80966dc0b60
Specify in font-lock-defaults/font-lock-defaults-alist which keywords we can
Simon Marshall <simon@gnu.org>
parents:
12268
diff
changeset
|
1408 (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
|
1409 "Default expressions to highlight in C++ mode.") |
4053 | 1410 |
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
|
1411 |
4053 | 1412 (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
|
1413 ; ;; 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
|
1414 ; '(("\\\\\\(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
|
1415 ; 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
|
1416 ; ("\\\\\\(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
|
1417 ; 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
|
1418 ; ;; 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
|
1419 ; ;; 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
|
1420 ; ("{\\\\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
|
1421 ; ("{\\\\\\(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
|
1422 ; ("\\\\\\([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
|
1423 ; ("^[ \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
|
1424 ;; 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
|
1425 '(("\\\\\\(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
|
1426 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
|
1427 ("\\\\\\(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
|
1428 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
|
1429 ("^[ \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
|
1430 "\\\\\\([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
|
1431 ;; 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
|
1432 ;; 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
|
1433 ;; 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
|
1434 ("\\\\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
|
1435 ;; 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
|
1436 ("\\\\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
|
1437 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
|
1438 ;; 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
|
1439 ("\\\\\\(\\(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
|
1440 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
|
1441 "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
|
1442 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1443 ;; Install ourselves: |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1444 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1445 (or (assq 'font-lock-mode minor-mode-alist) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1446 (setq minor-mode-alist (cons '(font-lock-mode " Font") minor-mode-alist))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1447 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
1448 ;; Provide ourselves: |
7491
621c162a80db
(font-lock-no-comments): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
1449 |
4053 | 1450 (provide 'font-lock) |
1451 | |
1452 ;;; font-lock.el ends here |