Mercurial > emacs
annotate lisp/font-lock.el @ 11297:056c7266a614
(resize-minibuffer-window): Make sure minibuffer window is selected.
(resize-minibuffer-window-restore): Likewise.
author | Noah Friedman <friedman@splode.com> |
---|---|
date | Sat, 08 Apr 1995 08:22:07 +0000 |
parents | 73ce8261c2ce |
children | bb7c9db199ae |
rev | line source |
---|---|
4053 | 1 ;; Electric Font Lock Mode |
10879
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
2 ;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. |
4053 | 3 |
10879
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
4 ;; Author: jwz, then rms and sm <simon@gnu.ai.mit.edu> |
4053 | 5 ;; Maintainer: FSF |
6 ;; Keywords: languages, faces | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
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 ;; |
34 ;; To make the text you type be fontified, use M-x font-lock-mode. | |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
35 ;; When this minor mode is on, the faces of the current line are |
4053 | 36 ;; updated with every insertion or deletion. |
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 ;; |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
42 ;; On a Sparc2, `font-lock-fontify-buffer' takes about 10 seconds for a 120k |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
43 ;; file of C code using the default configuration, and about 25 seconds using |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
44 ;; the more extensive configuration, though times also depend on file contents. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
45 ;; You can speed this up substantially by removing some of the patterns that |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
46 ;; are highlighted by default. Fontifying Lisp code is significantly faster, |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
47 ;; because Lisp has a more regular syntax than C, so the expressions don't have |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
48 ;; to be as hairy. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
49 ;; |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
50 ;; 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
|
51 ;; 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
|
52 ;; 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
|
53 ;; |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
54 ;; (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
|
55 ;; '(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
|
56 ;; (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
|
57 ;; |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
58 ;; 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
|
59 ;; 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
|
60 ;; 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
|
61 ;; archive.cis.ohio-state.edu for this and other functions. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
62 |
4053 | 63 ;;; Code: |
64 | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
65 (defvar font-lock-comment-face 'font-lock-comment-face |
4053 | 66 "Face to use for comments.") |
67 | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
68 (defvar font-lock-string-face 'font-lock-string-face |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
69 "Face to use for strings.") |
4053 | 70 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
71 (defvar font-lock-function-name-face 'font-lock-function-name-face |
4053 | 72 "Face to use for function names.") |
73 | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
74 (defvar font-lock-variable-name-face 'font-lock-variable-name-face |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
75 "Face to use for variable names.") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
76 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
77 (defvar font-lock-keyword-face 'font-lock-keyword-face |
4053 | 78 "Face to use for keywords.") |
79 | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
80 (defvar font-lock-type-face 'font-lock-type-face |
4053 | 81 "Face to use for data types.") |
82 | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
83 (defvar font-lock-reference-face 'font-lock-reference-face |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
84 "Face to use for references.") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
85 |
7491
621c162a80db
(font-lock-no-comments): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
86 (defvar font-lock-no-comments 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
|
87 "Non-nil means Font Lock should not fontify comments or strings.") |
7491
621c162a80db
(font-lock-no-comments): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
88 |
4053 | 89 (make-variable-buffer-local 'font-lock-keywords) |
90 (defvar font-lock-keywords nil | |
91 "*The keywords to highlight. | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
92 Elements should be of the form: |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
93 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
94 REGEXP |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
95 (REGEXP . MATCH) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
96 (REGEXP . FACENAME) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
97 (REGEXP . HIGHLIGHT) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
98 (REGEXP HIGHLIGHT ...) |
4053 | 99 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
100 where HIGHLIGHT should be of the form (MATCH FACENAME OVERRIDE LAXMATCH). |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
101 REGEXP is the regexp to search for, MATCH is the subexpression of REGEXP to be |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
102 highlighted, FACENAME is an expression whose value is the face name to use. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
103 FACENAME's default attributes may be defined in `font-lock-face-attributes'. |
4053 | 104 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
105 OVERRIDE and LAXMATCH are flags. If OVERRIDE is t, existing fontification may |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
106 be overriden. If `keep', only parts not already fontified are highlighted. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
107 If LAXMATCH is non-nil, no error is signalled if there is no MATCH in REGEXP. |
4053 | 108 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
109 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
|
110 \\[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
|
111 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
|
112 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
113 Be careful composing regexps for this list; |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
114 the wrong pattern can dramatically slow things down!") |
4053 | 115 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
116 (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
|
117 "If set by a major mode, should be the defaults for Font Lock mode. |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
118 The value should look like the `cdr' of an item in `font-lock-defaults-alist'.") |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
119 |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
120 (defvar font-lock-defaults-alist |
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
|
121 '((bibtex-mode . (tex-font-lock-keywords)) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
122 (c++-c-mode . (c-font-lock-keywords nil nil ((?_ . "w")))) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
123 (c++-mode . (c++-font-lock-keywords nil nil ((?_ . "w")))) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
124 (c-mode . (c-font-lock-keywords nil nil ((?_ . "w")))) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
125 (emacs-lisp-mode . (lisp-font-lock-keywords |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
126 nil nil ((?: . "w") (?- . "w") (?* . "w")))) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
127 (latex-mode . (tex-font-lock-keywords)) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
128 (lisp-mode . (lisp-font-lock-keywords |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
129 nil nil ((?: . "w") (?- . "w") (?* . "w")))) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
130 (plain-tex-mode . (tex-font-lock-keywords)) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
131 (scheme-mode . (lisp-font-lock-keywords |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
132 nil nil ((?: . "w") (?- . "w") (?* . "w")))) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
133 (slitex-mode . (tex-font-lock-keywords)) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
134 (tex-mode . (tex-font-lock-keywords))) |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
135 "*Alist of default major mode and Font Lock defaults. |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
136 Each item should be a list of the form: |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
137 (MAJOR-MODE . (FONT-LOCK-KEYWORDS KEYWORDS-ONLY CASE-FOLD FONT-LOCK-SYNTAX)) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
138 where both MAJOR-MODE and FONT-LOCK-KEYWORDS are symbols. If KEYWORDS-ONLY is |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
139 non-nil, syntactic fontification (strings and comments) is not performed. |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
140 If CASE-FOLD is non-nil, the case of the keywords is ignored when fontifying. |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
141 FONT-LOCK-SYNTAX should be a list of cons pairs of the form (CHAR . STRING), it |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
142 is used to set the local Font Lock syntax table for keyword fontification.") |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
143 |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
144 (defvar font-lock-maximum-size (* 100 1024) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
145 "*If non-nil, the maximum size for buffers. |
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
|
146 Only buffers less than this can be fontified when Font Lock mode is turned on. |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
147 If nil, means size is irrelevant.") |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
148 |
4053 | 149 (defvar font-lock-keywords-case-fold-search nil |
150 "*Non-nil means the patterns in `font-lock-keywords' are case-insensitive.") | |
151 | |
8457
c0492d7043b2
(font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents:
7915
diff
changeset
|
152 (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
|
153 "Non-nil means use this syntax table for fontifying. |
8457
c0492d7043b2
(font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents:
7915
diff
changeset
|
154 If this is nil, the major mode's syntax table is used.") |
c0492d7043b2
(font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents:
7915
diff
changeset
|
155 |
4053 | 156 (defvar font-lock-verbose t |
157 "*Non-nil means `font-lock-fontify-buffer' should print status messages.") | |
158 | |
4054 | 159 ;;;###autoload |
10879
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
160 (defvar font-lock-maximum-decoration nil |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
161 "Non-nil means use the maximum decoration for fontifying.") |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
162 |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
163 ;;;###autoload |
4053 | 164 (defvar font-lock-mode-hook nil |
165 "Function or functions to run on entry to Font Lock mode.") | |
10879
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
166 |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
167 (defvar font-lock-after-fontify-buffer-hook nil |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
168 "Function or functions to run after `font-lock-fontify-buffer'.") |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
169 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
170 ;; Colour etc. support. |
4053 | 171 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
172 (defvar font-lock-display-type nil |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
173 "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
|
174 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
|
175 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
|
176 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
|
177 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
|
178 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
179 (defvar font-lock-background-mode nil |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
180 "A symbol indicating the Emacs background brightness. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
181 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
|
182 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
|
183 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
|
184 `~/.Xdefaults'. |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
185 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
|
186 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
187 (defvar font-lock-face-attributes nil |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
188 "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
|
189 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
|
190 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
191 (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
|
192 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
193 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
|
194 `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
|
195 `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
|
196 `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
|
197 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
|
198 used in highlighting. See `font-lock-keywords'. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
199 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
200 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
|
201 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
|
202 \(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
|
203 corresponding face attributes (yes if non-nil). |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
204 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
205 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
|
206 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
|
207 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
208 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
|
209 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
|
210 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
|
211 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
212 (defun font-lock-make-faces () |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
213 "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
|
214 A default list is used if this is nil. |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
215 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
|
216 ;; 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
|
217 ;; 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
|
218 (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
|
219 (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
|
220 (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
|
221 "DisplayType"))) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
222 (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
|
223 ((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
|
224 ((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
|
225 (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
|
226 (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
|
227 (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
|
228 (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
|
229 "BackgroundMode")) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
230 (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
|
231 (cond (bg-resource (intern (downcase bg-resource))) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
232 ((or (string-equal "white" |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
233 (downcase (cdr (assq 'foreground-color params)))) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
234 (string-equal "black" |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
235 (downcase (cdr (assq 'background-color params))))) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
236 'dark) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
237 (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
|
238 (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
|
239 (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
|
240 (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
|
241 (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
|
242 ;; 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
|
243 ;;'((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
|
244 ;; (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
|
245 ;; (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
|
246 ;; (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
|
247 ;; (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
|
248 (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
|
249 '(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
|
250 '(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
|
251 (list |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
252 '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
|
253 (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
|
254 (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
|
255 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
|
256 '(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
|
257 '(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
|
258 '(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
|
259 ((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
|
260 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
|
261 (list |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
262 (list 'font-lock-comment-face |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
263 (if light-bg "DimGray" "Gray80") 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
|
264 (list 'font-lock-string-face |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
265 (if light-bg "Gray50" "LightGray") 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
|
266 (list 'font-lock-keyword-face |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
267 (if light-bg "DimGray" "Gray90") 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
|
268 (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
|
269 (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
|
270 (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
|
271 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
|
272 (list 'font-lock-variable-name-face |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
273 (if light-bg "DimGray" "Gray90") 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
|
274 (list 'font-lock-type-face |
10099
71e0c3ece2fe
Added defaults for grayscale font-lock-reference-face.
Simon Marshall <simon@gnu.org>
parents:
9909
diff
changeset
|
275 (if light-bg "DimGray" "Gray80") nil t nil t) |
71e0c3ece2fe
Added defaults for grayscale font-lock-reference-face.
Simon Marshall <simon@gnu.org>
parents:
9909
diff
changeset
|
276 (list 'font-lock-reference-face |
71e0c3ece2fe
Added defaults for grayscale font-lock-reference-face.
Simon Marshall <simon@gnu.org>
parents:
9909
diff
changeset
|
277 (if light-bg "Gray50" "LightGray") nil 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
|
278 (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
|
279 '((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
|
280 (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
|
281 (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
|
282 (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
|
283 (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
|
284 (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
|
285 (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
|
286 (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
|
287 '((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
|
288 (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
|
289 (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
|
290 (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
|
291 (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
|
292 (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
|
293 (font-lock-reference-face "Aquamarine"))))))) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
294 (mapcar 'font-lock-make-face 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
|
295 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
296 (defun font-lock-make-face (face-attributes) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
297 "Make a face from FACE-ATTRIBUTES. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
298 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
|
299 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
|
300 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
|
301 (let* ((face (nth 0 face-attributes)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
302 (face-name (symbol-name face)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
303 (set-p (function (lambda (face-name resource) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
304 (x-get-resource (concat face-name ".attribute" resource) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
305 (concat "Face.Attribute" resource))))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
306 (on-p (function (lambda (face-name resource) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
307 (let ((set (funcall set-p face-name resource))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
308 (and set (member (downcase set) '("on" "true")))))))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
309 (make-face face) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
310 ;; 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
|
311 (or (funcall set-p face-name "Foreground") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
312 (condition-case nil |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
313 (set-face-foreground face (nth 1 face-attributes)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
314 (error nil))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
315 (or (funcall set-p face-name "Background") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
316 (condition-case nil |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
317 (set-face-background face (nth 2 face-attributes)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
318 (error nil))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
319 (if (funcall set-p face-name "Bold") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
320 (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
|
321 (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
|
322 (if (funcall set-p face-name "Italic") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
323 (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
|
324 (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
|
325 (or (funcall set-p face-name "Underline") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
326 (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
|
327 (set face face))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
328 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
329 ;; Fontification. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
330 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
331 ;; These variables record, for each buffer, the parse state at a particular |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
332 ;; position, always the start of a line. Used to make font-lock-fontify-region |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
333 ;; faster. |
4053 | 334 (defvar font-lock-cache-position nil) |
335 (defvar font-lock-cache-state nil) | |
336 (make-variable-buffer-local 'font-lock-cache-position) | |
337 (make-variable-buffer-local 'font-lock-cache-state) | |
338 | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
339 (defun font-lock-fontify-region (start end &optional loudly) |
4053 | 340 "Put proper face on each string and comment between START and END." |
341 (save-excursion | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
342 (save-restriction |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
343 (widen) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
344 (goto-char start) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
345 (beginning-of-line) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
346 (if loudly (message "Fontifying %s... (syntactically...)" (buffer-name))) |
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
|
347 (let ((inhibit-read-only t) (buffer-undo-list t) (buffer-file-name) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
348 (modified (buffer-modified-p)) |
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
|
349 (synstart (if comment-start-skip |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
350 (concat "\\s\"\\|" comment-start-skip) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
351 "\\s\"")) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
352 (comstart (if comment-start-skip |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
353 (concat "\\s<\\|" comment-start-skip) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
354 "\\s<")) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
355 (startline (point)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
356 state prev prevstate) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
357 ;; Find the state at the line-beginning before START. |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
358 (if (eq startline font-lock-cache-position) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
359 (setq state font-lock-cache-state) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
360 ;; Find outermost containing sexp. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
361 (beginning-of-defun) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
362 ;; Find the state at STARTLINE. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
363 (while (< (point) startline) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
364 (setq state (parse-partial-sexp (point) startline 0))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
365 (setq font-lock-cache-state state |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
366 font-lock-cache-position (point))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
367 ;; Now find the state precisely at START. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
368 (setq state (parse-partial-sexp (point) start nil nil state)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
369 ;; If the region starts inside a string, show the extent of it. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
370 (if (nth 3 state) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
371 (let ((beg (point))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
372 (while (and (re-search-forward "\\s\"" end 'move) |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
373 (nth 3 (parse-partial-sexp beg (point) 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
|
374 state)))) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
375 (put-text-property beg (point) 'face font-lock-string-face) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
376 (setq state (parse-partial-sexp beg (point) nil nil state)))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
377 ;; Likewise for a comment. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
378 (if (or (nth 4 state) (nth 7 state)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
379 (let ((beg (point))) |
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
|
380 (save-restriction |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
381 (narrow-to-region (point-min) end) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
382 (condition-case nil |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
383 (progn |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
384 (re-search-backward comstart (point-min) 'move) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
385 (forward-comment 1) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
386 ;; forward-comment skips all whitespace, |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
387 ;; so go back to the real end of the comment. |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
388 (skip-chars-backward " \t")) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
389 (error (goto-char end)))) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
390 (put-text-property beg (point) 'face font-lock-comment-face) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
391 (setq state (parse-partial-sexp beg (point) nil nil state)))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
392 ;; Find each interesting place between here and END. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
393 (while (and (< (point) end) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
394 (setq prev (point) prevstate state) |
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
|
395 (re-search-forward synstart end t) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
396 (progn |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
397 ;; Clear out the fonts of what we skip over. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
398 (remove-text-properties prev (point) '(face nil)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
399 ;; Verify the state at that place |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
400 ;; so we don't get fooled by \" or \;. |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
401 (setq state (parse-partial-sexp prev (point) 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
|
402 state)))) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
403 (let ((here (point))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
404 (if (or (nth 4 state) (nth 7 state)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
405 ;; We found a real comment start. |
4053 | 406 (let ((beg (match-beginning 0))) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
407 (goto-char beg) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
408 (save-restriction |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
409 (narrow-to-region (point-min) end) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
410 (condition-case nil |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
411 (progn |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
412 (forward-comment 1) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
413 ;; forward-comment skips all whitespace, |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
414 ;; so go back to the real end of the comment. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
415 (skip-chars-backward " \t")) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
416 (error (goto-char end)))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
417 (put-text-property beg (point) 'face font-lock-comment-face) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
418 (setq state (parse-partial-sexp here (point) nil nil state))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
419 (if (nth 3 state) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
420 (let ((beg (match-beginning 0))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
421 (while (and (re-search-forward "\\s\"" end 'move) |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
422 (nth 3 (parse-partial-sexp here (point) 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
|
423 state)))) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
424 (put-text-property beg (point) 'face font-lock-string-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
|
425 (setq state (parse-partial-sexp here (point) 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
|
426 state)))))) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
427 ;; Make sure PREV is non-nil after the loop |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
428 ;; only if it was set on the very last iteration. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
429 (setq prev nil)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
430 (and prev |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
431 (remove-text-properties prev end '(face nil))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
432 (and (buffer-modified-p) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
433 (not modified) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
434 (set-buffer-modified-p nil)))))) |
4053 | 435 |
436 (defun font-lock-unfontify-region (beg end) | |
4219
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
437 (let ((modified (buffer-modified-p)) |
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
|
438 (buffer-undo-list t) (inhibit-read-only t) (buffer-file-name)) |
4219
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
439 (remove-text-properties beg end '(face nil)) |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
440 (set-buffer-modified-p modified))) |
4053 | 441 |
442 ;; Called when any modification is made to buffer text. | |
443 (defun font-lock-after-change-function (beg end old-len) | |
444 (save-excursion | |
445 (save-match-data | |
446 ;; Discard the cache info if text before it has changed. | |
447 (and font-lock-cache-position | |
448 (> font-lock-cache-position beg) | |
449 (setq font-lock-cache-position nil)) | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
450 ;; Rescan between start of line from `beg' and start of line after `end'. |
4053 | 451 (goto-char beg) |
452 (beginning-of-line) | |
453 (setq beg (point)) | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
454 (goto-char end) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
455 (forward-line 1) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
456 (setq end (point)) |
4239
e8cf7a7d0102
(font-lock-after-change-function):
Richard M. Stallman <rms@gnu.org>
parents:
4219
diff
changeset
|
457 ;; First scan for strings and comments. |
e8cf7a7d0102
(font-lock-after-change-function):
Richard M. Stallman <rms@gnu.org>
parents:
4219
diff
changeset
|
458 ;; Must scan from line start in case of |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
459 ;; inserting space into `intfoo () {}', and after widened. |
7491
621c162a80db
(font-lock-no-comments): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
460 (if font-lock-no-comments |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
461 (remove-text-properties beg end '(face nil)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
462 (font-lock-fontify-region beg end)) |
10879
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
463 ;; Now scan for keywords. |
10116
a8cdb7630b1c
Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents:
10099
diff
changeset
|
464 (font-lock-hack-keywords beg end)))) |
a8cdb7630b1c
Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents:
10099
diff
changeset
|
465 |
a8cdb7630b1c
Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents:
10099
diff
changeset
|
466 ; ;; Now scan for keywords, but not if we are inside a comment now. |
a8cdb7630b1c
Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents:
10099
diff
changeset
|
467 ; (or (and (not font-lock-no-comments) |
a8cdb7630b1c
Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents:
10099
diff
changeset
|
468 ; (let ((state (parse-partial-sexp beg end nil nil |
a8cdb7630b1c
Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents:
10099
diff
changeset
|
469 ; font-lock-cache-state))) |
a8cdb7630b1c
Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents:
10099
diff
changeset
|
470 ; (or (nth 4 state) (nth 7 state)))) |
a8cdb7630b1c
Comment out Oct 18 change to font-lock-after-change-function
Simon Marshall <simon@gnu.org>
parents:
10099
diff
changeset
|
471 ; (font-lock-hack-keywords beg end)) |
4053 | 472 |
473 ;;; Fontifying arbitrary patterns | |
474 | |
475 (defun font-lock-hack-keywords (start end &optional loudly) | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
476 "Fontify according to `font-lock-keywords' between START and END." |
4053 | 477 (let ((case-fold-search font-lock-keywords-case-fold-search) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
478 (keywords font-lock-keywords) |
4053 | 479 (count 0) |
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
|
480 (inhibit-read-only t) (buffer-undo-list t) (buffer-file-name) |
4219
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
481 (modified (buffer-modified-p)) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
482 (old-syntax (syntax-table)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
483 (bufname (buffer-name))) |
8457
c0492d7043b2
(font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents:
7915
diff
changeset
|
484 (unwind-protect |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
485 (let (keyword regexp match highlights hs h s e) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
486 (if loudly (message "Fontifying %s... (regexps...)" bufname)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
487 (if font-lock-syntax-table (set-syntax-table font-lock-syntax-table)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
488 (while keywords |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
489 (setq keyword (car keywords) keywords (cdr keywords) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
490 regexp (if (stringp keyword) keyword (car keyword)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
491 highlights (cond ((stringp keyword) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
492 '((0 font-lock-keyword-face))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
493 ((numberp (cdr keyword)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
494 (list (list (cdr keyword) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
495 'font-lock-keyword-face))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
496 ((symbolp (cdr keyword)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
497 (list (list 0 (cdr keyword)))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
498 ((nlistp (nth 1 keyword)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
499 (list (cdr keyword))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
500 (t |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
501 (cdr keyword)))) |
8457
c0492d7043b2
(font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents:
7915
diff
changeset
|
502 (goto-char start) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
503 (while (re-search-forward regexp end t) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
504 (setq hs highlights) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
505 (while hs |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
506 (setq h (car hs) match (nth 0 h) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
507 s (match-beginning match) e (match-end match) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
508 hs (cdr hs)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
509 (cond ((not s) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
510 ;; No match but we might not signal an error |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
511 (or (nth 3 h) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
512 (error "No subexpression %d in expression %d" |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
513 match (1+ count)))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
514 ((and (not (nth 2 h)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
515 (text-property-not-all s e 'face nil)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
516 ;; Can't override and already fontified |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
517 nil) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
518 ((not (eq (nth 2 h) 'keep)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
519 ;; Can override but need not keep existing fontification |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
520 (put-text-property s e 'face (eval (nth 1 h)))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
521 (t |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
522 ;; Can override but must keep existing fontification |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
523 ;; (Does anyone use this? sm.) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
524 (let ((p (text-property-any s e 'face nil)) n |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
525 (face (eval (nth 1 h)))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
526 (while p |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
527 (setq n (next-single-property-change p 'face nil e)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
528 (put-text-property p n 'face face) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
529 (setq p (text-property-any n e 'face nil)))))))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
530 ;; the above form was: |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
531 ; (save-excursion |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
532 ; (goto-char s) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
533 ; (while (< (point) e) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
534 ; (let ((next (next-single-property-change (point) 'face |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
535 ; nil e))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
536 ; (if (or (null next) (> next e)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
537 ; (setq next e)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
538 ; (if (not (get-text-property (point) 'face)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
539 ; (put-text-property (point) next 'face face)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
540 ; (goto-char next)))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
541 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
542 (if loudly (message "Fontifying %s... (regexps...%s)" bufname |
8457
c0492d7043b2
(font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents:
7915
diff
changeset
|
543 (make-string (setq count (1+ count)) ?.))))) |
c0492d7043b2
(font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents:
7915
diff
changeset
|
544 (set-syntax-table old-syntax)) |
7915
970912d4f413
Don't alter the underline face.
Richard M. Stallman <rms@gnu.org>
parents:
7847
diff
changeset
|
545 (and (buffer-modified-p) |
970912d4f413
Don't alter the underline face.
Richard M. Stallman <rms@gnu.org>
parents:
7847
diff
changeset
|
546 (not modified) |
970912d4f413
Don't alter the underline face.
Richard M. Stallman <rms@gnu.org>
parents:
7847
diff
changeset
|
547 (set-buffer-modified-p nil)))) |
4053 | 548 |
549 ;; The user level functions | |
550 | |
551 (defvar font-lock-mode nil) ; for modeline | |
552 | |
553 (defvar font-lock-fontified nil) ; whether we have hacked this buffer | |
554 (put 'font-lock-fontified 'permanent-local t) | |
555 | |
556 ;;;###autoload | |
557 (defun font-lock-mode (&optional arg) | |
558 "Toggle Font Lock mode. | |
559 With arg, turn Font Lock mode on if and only if arg is positive. | |
560 | |
561 When Font Lock mode is enabled, text is fontified as you type it: | |
562 | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
563 - Comments are displayed in `font-lock-comment-face'; |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
564 - Strings are displayed in `font-lock-string-face'; |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
565 - Certain other expressions are displayed in other faces according to the |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
566 value of the variable `font-lock-keywords'. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
567 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
568 You can enable Font Lock mode in any major mode automatically by turning on in |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
569 the major mode's hook. For example, put in your ~/.emacs: |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
570 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
571 (add-hook 'c-mode-hook 'turn-on-font-lock) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
572 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
573 Or for any visited file with the following in your ~/.emacs: |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
574 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
575 (add-hook 'find-file-hooks 'turn-on-font-lock) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
576 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
577 The default Font Lock mode faces and their attributes are defined in the |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
578 variable `font-lock-face-attributes', and Font Lock mode default settings in |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
579 the variable `font-lock-defaults-alist'. |
4053 | 580 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
581 When you turn Font Lock mode on/off the buffer is fontified/defontified, though |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
582 fontification occurs only if the buffer is less than `font-lock-maximum-size'. |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
583 To fontify a buffer without turning on Font Lock mode, and regardless of buffer |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
584 size, you can use \\[font-lock-fontify-buffer]." |
4053 | 585 (interactive "P") |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
586 (let ((on-p (if arg (> (prefix-numeric-value arg) 0) (not font-lock-mode)))) |
4053 | 587 (if (equal (buffer-name) " *Compiler Input*") ; hack for bytecomp... |
588 (setq on-p nil)) | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
589 (if (not on-p) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
590 (remove-hook 'after-change-functions 'font-lock-after-change-function) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
591 (make-local-variable 'after-change-functions) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
592 (add-hook 'after-change-functions 'font-lock-after-change-function)) |
4053 | 593 (set (make-local-variable 'font-lock-mode) on-p) |
594 (cond (on-p | |
595 (font-lock-set-defaults) | |
5717
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
596 (make-local-variable 'before-revert-hook) |
5625
24f92f49a07f
(font-lock-mode): Set after-revert-hook
Richard M. Stallman <rms@gnu.org>
parents:
5360
diff
changeset
|
597 (make-local-variable 'after-revert-hook) |
5717
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
598 ;; If buffer is reverted, must clean up the state. |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
599 (add-hook 'before-revert-hook 'font-lock-revert-setup) |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
600 (add-hook 'after-revert-hook 'font-lock-revert-cleanup) |
4053 | 601 (run-hooks 'font-lock-mode-hook) |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
602 (cond (font-lock-fontified |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
603 nil) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
604 ((or (null font-lock-maximum-size) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
605 (> font-lock-maximum-size (buffer-size))) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
606 (font-lock-fontify-buffer)) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
607 (font-lock-verbose |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
608 (message "Fontifying %s... buffer too big." (buffer-name))))) |
4053 | 609 (font-lock-fontified |
610 (setq font-lock-fontified nil) | |
5717
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
611 (remove-hook 'before-revert-hook 'font-lock-revert-setup) |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
612 (remove-hook 'after-revert-hook 'font-lock-revert-cleanup) |
10879
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
613 (font-lock-unfontify-region (point-min) (point-max)) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
614 (font-lock-thing-lock-cleanup)) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
615 (t |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
616 (font-lock-thing-lock-cleanup))) |
4053 | 617 (force-mode-line-update))) |
618 | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
619 ;;;###autoload |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
620 (defun turn-on-font-lock () |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
621 "Unconditionally turn on Font Lock mode." |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
622 (font-lock-mode 1)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
623 |
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
|
624 ;; Turn off other related packages if they're on. |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
625 (defun font-lock-thing-lock-cleanup () |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
626 (cond ((and (boundp 'fast-lock-mode) fast-lock-mode) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
627 (fast-lock-mode -1)) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
628 ((and (boundp 'lazy-lock-mode) lazy-lock-mode) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
629 (lazy-lock-mode -1)))) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
630 |
5717
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
631 ;; If the buffer is about to be reverted, it won't be fontified. |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
632 (defun font-lock-revert-setup () |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
633 (setq font-lock-fontified nil)) |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
634 |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
635 ;; If the buffer has just been reverted, we might not even be in font-lock |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
636 ;; mode anymore, and if we are, the buffer may or may not have already been |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
637 ;; refontified. Refontify here if it looks like we need to. |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
638 (defun font-lock-revert-cleanup () |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
639 (and font-lock-mode |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
640 (not font-lock-fontified) |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
641 (font-lock-mode 1))) |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
642 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
643 ;;;###autoload |
4053 | 644 (defun font-lock-fontify-buffer () |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
645 "Fontify the current buffer the way `font-lock-mode' would." |
4053 | 646 (interactive) |
647 (let ((was-on font-lock-mode) | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
648 (verbose (or font-lock-verbose (interactive-p))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
649 (modified (buffer-modified-p))) |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
650 (set (make-local-variable 'font-lock-fontified) nil) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
651 (if verbose (message "Fontifying %s..." (buffer-name))) |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
652 ;; Turn it on to run hooks and get the right `font-lock-keywords' etc. |
4897
c3db6fd69f1f
(font-lock-fontify-buffer): Don't turn
Richard M. Stallman <rms@gnu.org>
parents:
4727
diff
changeset
|
653 (or was-on (font-lock-set-defaults)) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
654 (condition-case nil |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
655 (save-excursion |
10879
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
656 (if font-lock-no-comments |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
657 (font-lock-unfontify-region (point-min) (point-max)) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
658 (font-lock-fontify-region (point-min) (point-max) verbose)) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
659 (font-lock-hack-keywords (point-min) (point-max) verbose) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
660 (setq font-lock-fontified t)) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
661 ;; We don't restore the old fontification, so it's best to unfontify. |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
662 (quit (font-lock-unfontify-region (point-min) (point-max)))) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
663 (if verbose (message "Fontifying %s... %s." (buffer-name) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
664 (if font-lock-fontified "done" "aborted"))) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
665 (and (buffer-modified-p) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
666 (not modified) |
10879
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
667 (set-buffer-modified-p nil)) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
668 (run-hooks 'font-lock-after-fontify-buffer-hook))) |
4053 | 669 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
670 ;;; Various information shared by several modes. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
671 ;;; Information specific to a single mode should go in its load library. |
4053 | 672 |
673 (defconst lisp-font-lock-keywords-1 | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
674 (list |
4053 | 675 ;; highlight defining forms. This doesn't work too nicely for |
676 ;; (defun (setf foo) ...) but it does work for (defvar foo) which | |
677 ;; is more important. | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
678 (list (concat "^(\\(def\\(const\\|ine-key\\(\\|-after\\)\\|var\\)\\)\\>" |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
679 "\\s *\\([^ \t\n\)]+\\)?") |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
680 '(1 font-lock-keyword-face) '(4 font-lock-variable-name-face nil 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
|
681 (list (concat "^(\\(def[^ \t\n\)]+\\)\\>" |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
682 "\\s *\\([^ \t\n\)]+\\)?") |
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
|
683 '(1 font-lock-keyword-face) '(2 font-lock-function-name-face nil t)) |
4053 | 684 ;; |
685 ;; this is highlights things like (def* (setf foo) (bar baz)), but may | |
686 ;; be slower (I haven't really thought about it) | |
687 ; ("^(def[-a-z]+\\s +\\(\\s(\\S)*\\s)\\|\\S(\\S *\\)" | |
688 ; 1 font-lock-function-name-face) | |
689 ) | |
690 "For consideration as a value of `lisp-font-lock-keywords'. | |
691 This does fairly subdued highlighting.") | |
692 | |
693 (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
|
694 (append lisp-font-lock-keywords-1 |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
695 (let ((word-char "[-+a-zA-Z0-9_:*]")) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
696 (list |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
697 ;; |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
698 ;; Control structures. |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
699 ;; ELisp: |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
700 ; ("cond" "if" "while" "let\\*?" "prog[nv12*]?" "catch" "throw" |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
701 ; "save-restriction" "save-excursion" |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
702 ; "save-window-excursion" "save-match-data" "unwind-protect" |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
703 ; "condition-case" "track-mouse") |
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
|
704 (cons |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
705 (concat |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
706 "(\\(" |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
707 "c\\(atch\\|ond\\(\\|ition-case\\)\\)\\|if\\|let\\*?\\|prog[nv12*]?\\|" |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
708 "save-\\(excursion\\|match-data\\|restriction\\|window-excursion\\)\\|" |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
709 "t\\(hrow\\|rack-mouse\\)\\|unwind-protect\\|while" |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
710 "\\)\\>") 1) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
711 ;; CLisp: |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
712 ; ("when" "unless" "do" "flet" "labels" "return" "return-from") |
10879
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
713 '("(\\(do\\|flet\\|labels\\|return\\(\\|-from\\)\\|unless\\|when\\)\\>" |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
714 . 1) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
715 ;; |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
716 ;; Fontify CLisp keywords. |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
717 (concat "\\<:" word-char "*\\>") |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
718 ;; |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
719 ;; Function names in emacs-lisp docstrings (in the syntax that |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
720 ;; `substitute-command-keys' understands). |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
721 '("\\\\\\\\\\[\\([^]\\\n]+\\)]" 1 font-lock-reference-face t) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
722 ;; |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
723 ;; Words inside `' which tend to be symbol names. |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
724 (list (concat "`\\(" word-char word-char "+\\)'") |
10879
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
725 1 'font-lock-reference-face t) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
726 ;; |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
727 ;; & keywords as types |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
728 '("\\&\\(optional\\|rest\\|whole\\)\\>" . font-lock-type-face) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
729 ))) |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
730 "For consideration as a value of `lisp-font-lock-keywords'. |
4053 | 731 This does a lot more highlighting.") |
732 | |
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
|
733 (defvar lisp-font-lock-keywords (if font-lock-maximum-decoration |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
734 lisp-font-lock-keywords-2 |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
735 lisp-font-lock-keywords-1) |
4053 | 736 "Additional expressions to highlight in Lisp modes.") |
737 | |
738 | |
739 (defconst c-font-lock-keywords-1 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
|
740 "For consideration as a value of `c-font-lock-keywords'. |
4053 | 741 This does fairly subdued highlighting.") |
742 | |
743 (defconst c-font-lock-keywords-2 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
|
744 "For consideration as a value of `c-font-lock-keywords'. |
4053 | 745 This does a lot more highlighting.") |
746 | |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
747 (defconst c++-font-lock-keywords-1 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
|
748 "For consideration as a value of `c++-font-lock-keywords'. |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
749 This does fairly subdued highlighting.") |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
750 |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
751 (defconst c++-font-lock-keywords-2 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
|
752 "For consideration as a value of `c++-font-lock-keywords'. |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
753 This does a lot more highlighting.") |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
754 |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
755 (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
|
756 ; ("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
|
757 "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
|
758 (c-type-types |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
759 ; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum" |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
760 ; "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
|
761 ; "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
|
762 (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
|
763 "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
|
764 "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
|
765 "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
|
766 (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
|
767 ; ("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
|
768 ; "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
|
769 ; "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
|
770 (concat "asm\\|break\\|c\\(atch\\|ontinue\\)\\|d\\(elete\\|o\\)\\|" |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
771 "else\\|for\\|if\\|new\\|operator\\|" |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
772 "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
|
773 "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
|
774 (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
|
775 ; ("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
|
776 ; "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
|
777 ; "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
|
778 ; "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
|
779 (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
|
780 "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
|
781 "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
|
782 "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
|
783 "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
|
784 "v\\(irtual\\|o\\(id\\|latile\\)\\)")) ; 11 ()s deep. |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
785 (ctoken "[a-zA-Z0-9_:~]+")) |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
786 (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
|
787 (list |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
788 ;; |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
789 ;; Fontify filenames in #include <...> preprocessor directives. |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
790 '("^#[ \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
|
791 ;; |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
792 ;; Fontify function macro names. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
793 '("^#[ \t]*define[ \t]+\\(\\(\\sw+\\)(\\)" 2 font-lock-function-name-face) |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
794 ;; |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
795 ;; Fontify otherwise as symbol names, and the preprocessor directive names. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
796 '("^\\(#[ \t]*[a-z]+\\)\\>[ \t]*\\(\\sw+\\)?" |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
797 (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
|
798 ;; |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
799 ;; Fontify function name definitions (without type on line). |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
800 (list (concat "^\\(" ctoken "\\)[ \t]*(") 1 'font-lock-function-name-face) |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
801 )) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
802 |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
803 (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
|
804 (append c-font-lock-keywords-1 |
4053 | 805 (list |
806 ;; | |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
807 ;; Fontify all storage classes and type specifiers (before declarations). |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
808 (cons (concat "\\<\\(" c-type-types "\\)\\>") 'font-lock-type-face) |
4053 | 809 ;; |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
810 ;; Fontify variable/structure name declarations and definitions, or |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
811 ;; function name declarations (plus definitions with type on same line). |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
812 (list (concat "\\<\\(" c-type-types "\\)[ \t*]+" |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
813 "\\(" ctoken "[ \t*]+\\)*" |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
814 "\\(" ctoken "\\)[ \t]*\\((\\)?") |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
815 9 |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
816 '(if (match-beginning 10) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
817 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
|
818 font-lock-variable-name-face)) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
819 ;; |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
820 ;; Fontify function/variable name declarations at the start of the line. |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
821 ;; (Not everyone follows the GNU convention of function name at the start.) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
822 (list (concat "^" ctoken "[ \t*]+" |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
823 "\\(" ctoken "[ \t*]+\\)*" |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
824 "\\(" ctoken "\\)[ \t]*\\((\\)?") |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
825 2 |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
826 '(if (match-beginning 3) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
827 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
|
828 font-lock-variable-name-face)) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
829 ;; |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
830 ;; Fontify variable names declared with structures, or typedef names. |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
831 '("}[ \t*]*\\(\\sw+\\)[ \t]*[;,[]" 1 font-lock-variable-name-face) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
832 ;; |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
833 ;; Fontify all builtin keywords (except case, default and goto; see below). |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
834 (concat "\\<\\(" c-keywords "\\)\\>") |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
835 ;; |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
836 ;; Fontify case/goto keywords and targets, and goto tags (incl "default:"). |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
837 '("\\<\\(case\\|goto\\)\\>[ \t]*\\([^ \t\n:;]+\\)?" |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
838 (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
|
839 '("^[ \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
|
840 ))) |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
841 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
842 (setq c++-font-lock-keywords-1 c-font-lock-keywords-1) |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
843 (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
|
844 (append c++-font-lock-keywords-1 |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
845 (list |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
846 ;; We don't just add to the C keywords for subtle differences and speed. |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
847 ;; See the above comments for `c-font-lock-keywords-2'. |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
848 (cons (concat "\\<\\(" c++-type-types "\\)\\>") 'font-lock-type-face) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
849 (list (concat "\\<\\(" c++-type-types "\\)[ \t*&]+" |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
850 "\\(" ctoken "[ \t*&]+\\)*" |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
851 "\\(" ctoken "\\)[ \t]*\\((\\)?") |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
852 14 |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
853 '(if (match-beginning 15) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
854 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
|
855 font-lock-variable-name-face)) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
856 (list (concat "^" ctoken "[ \t*]+" |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
857 "\\(" ctoken "[ \t*]+\\)*" |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
858 "\\(" ctoken "\\)[ \t]*\\((\\)?") |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
859 2 |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
860 '(if (match-beginning 3) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
861 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
|
862 font-lock-variable-name-face)) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
863 '("}[ \t*]*\\(\\sw+\\)[ \t]*[;,[]" 1 font-lock-variable-name-face) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
864 (concat "\\<\\(" c++-keywords "\\)\\>") |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
865 '("\\<\\(case\\|goto\\)\\>[ \t]*\\([^ \t\n:;]+\\)?" |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
866 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t)) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
867 '("^[ \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
|
868 ) |
4053 | 869 |
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
|
870 (defvar c-font-lock-keywords (if font-lock-maximum-decoration |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
871 c-font-lock-keywords-2 |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
872 c-font-lock-keywords-1) |
4053 | 873 "Additional expressions to highlight in C mode.") |
874 | |
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
|
875 (defvar c++-font-lock-keywords (if font-lock-maximum-decoration |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
876 c++-font-lock-keywords-2 |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
877 c++-font-lock-keywords-1) |
4053 | 878 "Additional expressions to highlight in C++ mode.") |
879 | |
880 (defvar tex-font-lock-keywords | |
881 (list | |
7847
43045a12cb34
(tex-font-lock-keywords): Make the pattern for
Richard M. Stallman <rms@gnu.org>
parents:
7751
diff
changeset
|
882 '("\\(\\\\\\([a-zA-Z@]+\\|.\\)\\)" 1 font-lock-keyword-face t) |
4053 | 883 '("{\\\\em\\([^}]+\\)}" 1 font-lock-comment-face t) |
884 '("{\\\\bf\\([^}]+\\)}" 1 font-lock-keyword-face t) | |
885 '("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" 1 font-lock-function-name-face t) | |
886 '("\\\\\\(begin\\|end\\){\\([a-zA-Z0-9\\*]+\\)}" | |
887 2 font-lock-function-name-face t) | |
888 '("[^\\\\]\\$\\([^$]*\\)\\$" 1 font-lock-string-face t) | |
889 ; '("\\$\\([^$]*\\)\\$" 1 font-lock-string-face t) | |
890 ) | |
891 "Additional expressions to highlight in TeX mode.") | |
892 | |
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
|
893 ;; There is no html-mode.el shipped with Emacs; its `font-lock-defaults' entry |
73ce8261c2ce
Added font-lock-maximum-decoration; use it to set lisp-font-lock-keywords, and
Simon Marshall <simon@gnu.org>
parents:
10545
diff
changeset
|
894 ;; could be: (html-font-lock-keywords 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
|
895 ;(defconst html-font-lock-keywords |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
896 ; '(("<!--[^>]*>" 0 font-lock-comment-face t) ; Comment. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
897 ; ("</?\\sw+" . font-lock-type-face) ; Normal tag start. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
898 ; (">" . font-lock-type-face) ; Normal tag end. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
899 ; ("<\\(/?\\(a\\|form\\|img\\|input\\)\\)\\>" ; Special tag name. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
900 ; 1 font-lock-function-name-face t) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
901 ; ("\\<\\(\\sw+\\)[>=]" 1 font-lock-keyword-face)) ; Tag attribute. |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
902 ; "Additional expressions to highlight in HTML mode.") |
5726
781af712e68c
(font-lock-set-defaults): Handle shell mode.
Richard M. Stallman <rms@gnu.org>
parents:
5717
diff
changeset
|
903 |
7491
621c162a80db
(font-lock-no-comments): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
904 (defun font-lock-set-defaults () |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
905 "Set fontification defaults appropriately for this mode. |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
906 Sets `font-lock-keywords', `font-lock-no-comments', `font-lock-syntax-table' |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
907 and `font-lock-keywords-case-fold-search' using `font-lock-defaults-alist'." |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
908 (or font-lock-keywords ; if not already set. |
9444
e21d4ebc3160
(font-lock-set-defaults): Do nothing if font-lock-keywords already non-nil.
Richard M. Stallman <rms@gnu.org>
parents:
9390
diff
changeset
|
909 (let ((defaults (or font-lock-defaults |
e21d4ebc3160
(font-lock-set-defaults): Do nothing if font-lock-keywords already non-nil.
Richard M. Stallman <rms@gnu.org>
parents:
9390
diff
changeset
|
910 (cdr (assq major-mode font-lock-defaults-alist))))) |
e21d4ebc3160
(font-lock-set-defaults): Do nothing if font-lock-keywords already non-nil.
Richard M. Stallman <rms@gnu.org>
parents:
9390
diff
changeset
|
911 ;; Keywords? |
e21d4ebc3160
(font-lock-set-defaults): Do nothing if font-lock-keywords already non-nil.
Richard M. Stallman <rms@gnu.org>
parents:
9390
diff
changeset
|
912 (setq font-lock-keywords (eval (nth 0 defaults))) |
e21d4ebc3160
(font-lock-set-defaults): Do nothing if font-lock-keywords already non-nil.
Richard M. Stallman <rms@gnu.org>
parents:
9390
diff
changeset
|
913 ;; Syntactic? |
e21d4ebc3160
(font-lock-set-defaults): Do nothing if font-lock-keywords already non-nil.
Richard M. Stallman <rms@gnu.org>
parents:
9390
diff
changeset
|
914 (if (nth 1 defaults) |
e21d4ebc3160
(font-lock-set-defaults): Do nothing if font-lock-keywords already non-nil.
Richard M. Stallman <rms@gnu.org>
parents:
9390
diff
changeset
|
915 (set (make-local-variable 'font-lock-no-comments) t)) |
e21d4ebc3160
(font-lock-set-defaults): Do nothing if font-lock-keywords already non-nil.
Richard M. Stallman <rms@gnu.org>
parents:
9390
diff
changeset
|
916 ;; Case fold? |
e21d4ebc3160
(font-lock-set-defaults): Do nothing if font-lock-keywords already non-nil.
Richard M. Stallman <rms@gnu.org>
parents:
9390
diff
changeset
|
917 (if (nth 2 defaults) |
e21d4ebc3160
(font-lock-set-defaults): Do nothing if font-lock-keywords already non-nil.
Richard M. Stallman <rms@gnu.org>
parents:
9390
diff
changeset
|
918 (set (make-local-variable 'font-lock-keywords-case-fold-search) t)) |
e21d4ebc3160
(font-lock-set-defaults): Do nothing if font-lock-keywords already non-nil.
Richard M. Stallman <rms@gnu.org>
parents:
9390
diff
changeset
|
919 ;; Syntax table? |
9487
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 (nth 3 defaults) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
921 (let ((slist (nth 3 defaults))) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
922 (make-local-variable 'font-lock-syntax-table) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
923 (setq font-lock-syntax-table (copy-syntax-table (syntax-table))) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
924 (while slist |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
925 (modify-syntax-entry (car (car slist)) (cdr (car slist)) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
926 font-lock-syntax-table) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
927 (setq slist (cdr slist)))))))) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
928 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
929 ;; Install ourselves: |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
930 |
9513
76ce1230257f
Use purify-flag not noninteractive.
Simon Marshall <simon@gnu.org>
parents:
9487
diff
changeset
|
931 (if purify-flag |
9487
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
932 (add-hook 'after-init-hook 'font-lock-make-faces) |
f80b2a33df03
* font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents:
9444
diff
changeset
|
933 (font-lock-make-faces)) |
9389
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
934 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
935 (or (assq 'font-lock-mode minor-mode-alist) |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
936 (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
|
937 |
fec6bd86e836
(compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents:
9350
diff
changeset
|
938 ;; Provide ourselves: |
7491
621c162a80db
(font-lock-no-comments): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
939 |
4053 | 940 (provide 'font-lock) |
941 | |
942 ;;; font-lock.el ends here |