annotate lisp/font-lock.el @ 9630:5410efcb7b6e

PopServer renamed to popserver throughout.
author Richard M. Stallman <rms@gnu.org>
date Thu, 20 Oct 1994 20:35:57 +0000
parents d352bebc9103
children 5ae33de679f6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;; Electric Font Lock Mode
7298
4fd40bd394fe Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 7018
diff changeset
2 ;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
4 ;; Author: jwz, then rms and sm (simon.marshall@mail.esrin.esa.it)
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Maintainer: FSF
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Keywords: languages, faces
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;;
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; Comments will be displayed in `font-lock-comment-face'.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;;
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; updated with every insertion or deletion.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;;; Code:
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 "Face to use for comments.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 "Face to use for function names.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 "Face to use for keywords.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 "Face to use for data types.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (make-variable-buffer-local 'font-lock-keywords)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (defvar font-lock-keywords nil
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
121 '((bibtex-mode . (tex-font-lock-keywords))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
122 (c++-c-mode . (c-font-lock-keywords nil nil ((?\_ . "w"))))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
123 (c++-mode . (c++-font-lock-keywords nil nil ((?\_ . "w"))))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
124 (c-mode . (c-font-lock-keywords nil nil ((?\_ . "w"))))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
125 (emacs-lisp-mode . (lisp-font-lock-keywords))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
126 (latex-mode . (tex-font-lock-keywords))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
127 (lisp-mode . (lisp-font-lock-keywords))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
128 (plain-tex-mode . (tex-font-lock-keywords))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
129 (slitex-mode . (tex-font-lock-keywords))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
130 (tex-mode . (tex-font-lock-keywords)))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
131 "*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
132 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
133 (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
134 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
135 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
136 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
137 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
138 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
139
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
140 (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
141 "*If non-nil, the maximum size for buffers.
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
142 Only buffers less than are fontified when Font Lock mode is turned on.
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
143 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
144
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (defvar font-lock-keywords-case-fold-search nil
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 "*Non-nil means the patterns in `font-lock-keywords' are case-insensitive.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147
8457
c0492d7043b2 (font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents: 7915
diff changeset
148 (defvar font-lock-syntax-table nil
c0492d7043b2 (font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents: 7915
diff changeset
149 "*Non-nil means use this syntax table for fontifying.
c0492d7043b2 (font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents: 7915
diff changeset
150 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
151
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (defvar font-lock-verbose t
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 "*Non-nil means `font-lock-fontify-buffer' should print status messages.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154
4054
074035743fc9 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 4053
diff changeset
155 ;;;###autoload
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (defvar font-lock-mode-hook nil
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 "Function or functions to run on entry to Font Lock mode.")
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
158
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
159 ;; Colour etc. support.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
161 (defvar font-lock-display-type nil
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
162 "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
163 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
164 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
165 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
166 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
167
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
168 (defvar font-lock-background-mode nil
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
169 "A symbol indicating the Emacs background brightness.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
170 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
171 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
172 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
173 `~/.Xdefaults'.
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
174 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
175
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 (defvar font-lock-face-attributes nil
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
177 "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
178 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
179
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
180 (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
181
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
182 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
183 `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
184 `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
185 `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
186 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
187 used in highlighting. See `font-lock-keywords'.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
188
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
189 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
190 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
191 \(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
192 corresponding face attributes (yes if non-nil).
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
193
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
194 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
195 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
196
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
197 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
198 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
199 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
200
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
201 (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
202 "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
203 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
204 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
205 ;; 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
206 ;; 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
207 (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
208 (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
209 (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
210 "DisplayType")))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
211 (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
212 ((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
213 ((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
214 (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
215 (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
216 (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
217 (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
218 "BackgroundMode"))
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
219 (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
220 (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
221 ((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
222 (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
223 (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
224 (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
225 'dark)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
226 (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
227 (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
228 (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
229 (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
230 (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
231 ;; 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
232 ;;'((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
233 ;; (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
234 ;; (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
235 ;; (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
236 ;; (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
237 (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
238 '(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
239 '(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
240 (list
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
241 '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
242 (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
243 (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
244 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
245 '(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
246 '(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
247 '(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
248 ((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
249 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
250 (list
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 '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
252 (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
253 (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
254 (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
255 (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
256 (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
257 (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
258 (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
259 (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
260 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
261 (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
262 (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
263 (list '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
264 (if light-bg "DimGray" "Gray80") 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
265 (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
266 '((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
267 (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
268 (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
269 (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
270 (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
271 (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
272 (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
273 (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
274 '((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
275 (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
276 (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
277 (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
278 (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
279 (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
280 (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
281 (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
282
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
283 (defun font-lock-make-face (face-attributes)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
284 "Make a face from FACE-ATTRIBUTES.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
285 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
286 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
287 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
288 (let* ((face (nth 0 face-attributes))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
289 (face-name (symbol-name face))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
290 (set-p (function (lambda (face-name resource)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
291 (x-get-resource (concat face-name ".attribute" resource)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
292 (concat "Face.Attribute" resource)))))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
293 (on-p (function (lambda (face-name resource)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
294 (let ((set (funcall set-p face-name resource)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
295 (and set (member (downcase set) '("on" "true"))))))))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
296 (make-face face)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
297 ;; 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
298 (or (funcall set-p face-name "Foreground")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
299 (condition-case nil
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
300 (set-face-foreground face (nth 1 face-attributes))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
301 (error nil)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
302 (or (funcall set-p face-name "Background")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
303 (condition-case nil
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
304 (set-face-background face (nth 2 face-attributes))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
305 (error nil)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
306 (if (funcall set-p face-name "Bold")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
307 (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
308 (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
309 (if (funcall set-p face-name "Italic")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
310 (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
311 (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
312 (or (funcall set-p face-name "Underline")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
313 (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
314 (set face face)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
315
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
316 ;; Fontification.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
317
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
318 ;; 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
319 ;; 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
320 ;; faster.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (defvar font-lock-cache-position nil)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (defvar font-lock-cache-state nil)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (make-variable-buffer-local 'font-lock-cache-position)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (make-variable-buffer-local 'font-lock-cache-state)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
326 (defun font-lock-fontify-region (start end &optional loudly)
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 "Put proper face on each string and comment between START and END."
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (save-excursion
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
329 (save-restriction
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
330 (widen)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
331 (goto-char start)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
332 (beginning-of-line)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
333 (if loudly (message "Fontifying %s... (syntactically...)" (buffer-name)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
334 (let ((buffer-read-only nil)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
335 (modified (buffer-modified-p))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
336 (cstart (if comment-start-skip
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
337 (concat "\\s\"\\|" comment-start-skip)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
338 "\\s\""))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
339 (cend (if comment-end
9597
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
340 (concat "\\s>\\|"
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
341 (regexp-quote
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
342 ;; Discard leading spaces from comment-end.
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
343 ;; In C mode, it is " */"
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
344 ;; and we don't want to fail to notice a */
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
345 ;; just because there's no space there.
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
346 (if (string-match "^ +" comment-end)
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
347 (substring comment-end (match-end 0))
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
348 comment-end)))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
349 "\\s>"))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
350 (startline (point))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
351 state prev prevstate)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
352 ;; 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
353 (if (eq startline font-lock-cache-position)
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
354 (setq state font-lock-cache-state)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
355 ;; Find outermost containing sexp.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
356 (beginning-of-defun)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
357 ;; Find the state at STARTLINE.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
358 (while (< (point) startline)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
359 (setq state (parse-partial-sexp (point) startline 0)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
360 (setq font-lock-cache-state state
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
361 font-lock-cache-position (point)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
362 ;; Now find the state precisely at START.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
363 (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
364 ;; 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
365 (if (nth 3 state)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
366 (let ((beg (point)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
367 (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
368 (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
369 state))))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
370 (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
371 (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
372 ;; Likewise for a comment.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
373 (if (or (nth 4 state) (nth 7 state))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
374 (let ((beg (point)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
375 (while (and (re-search-forward cend 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
376 (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
377 state))))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
378 (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
379 (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
380 ;; Find each interesting place between here and END.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
381 (while (and (< (point) end)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
382 (setq prev (point) prevstate state)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
383 (re-search-forward cstart end t)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
384 (progn
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
385 ;; 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
386 (remove-text-properties prev (point) '(face nil))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
387 ;; Verify the state at that place
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
388 ;; 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
389 (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
390 state))))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
391 (let ((here (point)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
392 (if (or (nth 4 state) (nth 7 state))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
393 ;; We found a real comment start.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (let ((beg (match-beginning 0)))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
395 (goto-char beg)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
396 (save-restriction
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
397 (narrow-to-region (point-min) end)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
398 (condition-case nil
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
399 (progn
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
400 (forward-comment 1)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
401 ;; forward-comment skips all whitespace,
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
402 ;; 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
403 (skip-chars-backward " \t"))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
404 (error (goto-char end))))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
405 (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
406 (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
407 (if (nth 3 state)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
408 (let ((beg (match-beginning 0)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
409 (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
410 (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
411 state))))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
412 (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
413 (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
414 state))))))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
415 ;; 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
416 ;; 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
417 (setq prev nil))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
418 (and prev
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
419 (remove-text-properties prev end '(face nil)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
420 (and (buffer-modified-p)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
421 (not modified)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
422 (set-buffer-modified-p nil))))))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 ;; This code used to be used to show a string on reaching the end of it.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 ;; It is probably not needed due to later changes to handle strings
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 ;; starting before the region in question.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 ;; (if (and (null (nth 3 state))
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 ;; (eq (char-syntax (preceding-char)) ?\")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 ;; (save-excursion
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 ;; (nth 3 (parse-partial-sexp prev (1- (point))
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 ;; nil nil prevstate))))
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 ;; ;; We found the end of a string.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 ;; (save-excursion
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 ;; (setq foo2 (point))
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 ;; (let ((ept (point)))
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 ;; (forward-sexp -1)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 ;; ;; Highlight the string when we see the end.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 ;; ;; Doing it at the start leads to trouble:
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 ;; ;; either it fails to handle multiline strings
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 ;; ;; or it can run away when an unmatched " is inserted.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 ;; (put-text-property (point) ept 'face
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 ;; (if (= (car state) 1)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 ;; font-lock-doc-string-face
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 ;; font-lock-string-face)))))
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (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
447 (let ((modified (buffer-modified-p))
24f3ca095be9 (perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents: 4054
diff changeset
448 (buffer-read-only nil))
24f3ca095be9 (perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents: 4054
diff changeset
449 (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
450 (set-buffer-modified-p modified)))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 ;; Called when any modification is made to buffer text.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 (defun font-lock-after-change-function (beg end old-len)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (save-excursion
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 (save-match-data
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 ;; Discard the cache info if text before it has changed.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (and font-lock-cache-position
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 (> font-lock-cache-position beg)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (setq font-lock-cache-position nil))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
460 ;; Rescan between start of line from `beg' and start of line after `end'.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (goto-char beg)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 (beginning-of-line)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 (setq beg (point))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
464 (goto-char end)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
465 (forward-line 1)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
466 (setq end (point))
4239
e8cf7a7d0102 (font-lock-after-change-function):
Richard M. Stallman <rms@gnu.org>
parents: 4219
diff changeset
467 ;; First scan for strings and comments.
e8cf7a7d0102 (font-lock-after-change-function):
Richard M. Stallman <rms@gnu.org>
parents: 4219
diff changeset
468 ;; 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
469 ;; 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
470 (if font-lock-no-comments
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
471 (remove-text-properties beg end '(face nil))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
472 (font-lock-fontify-region beg end))
9597
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
473 ;; Now scan for keywords, but not if we are inside a comment now.
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
474 (or (and (not font-lock-no-comments)
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
475 (let ((state (parse-partial-sexp beg end nil nil
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
476 font-lock-cache-state)))
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
477 (or (nth 4 state) (nth 7 state))))
d352bebc9103 (font-lock-after-change-function): If inside a comment,
Richard M. Stallman <rms@gnu.org>
parents: 9513
diff changeset
478 (font-lock-hack-keywords beg end)))))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 ;;; Fontifying arbitrary patterns
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 (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
483 "Fontify according to `font-lock-keywords' between START and END."
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (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
485 (keywords font-lock-keywords)
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (count 0)
4219
24f3ca095be9 (perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents: 4054
diff changeset
487 (buffer-read-only nil)
24f3ca095be9 (perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents: 4054
diff changeset
488 (modified (buffer-modified-p))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
489 (old-syntax (syntax-table))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
490 (bufname (buffer-name)))
8457
c0492d7043b2 (font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents: 7915
diff changeset
491 (unwind-protect
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
492 (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
493 (if loudly (message "Fontifying %s... (regexps...)" bufname))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
494 (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
495 (while keywords
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
496 (setq keyword (car keywords) keywords (cdr keywords)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
497 regexp (if (stringp keyword) keyword (car keyword))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
498 highlights (cond ((stringp keyword)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
499 '((0 font-lock-keyword-face)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
500 ((numberp (cdr keyword))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
501 (list (list (cdr keyword)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
502 'font-lock-keyword-face)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
503 ((symbolp (cdr keyword))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
504 (list (list 0 (cdr keyword))))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
505 ((nlistp (nth 1 keyword))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
506 (list (cdr keyword)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
507 (t
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
508 (cdr keyword))))
8457
c0492d7043b2 (font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents: 7915
diff changeset
509 (goto-char start)
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
510 (while (re-search-forward regexp end t)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
511 (setq hs highlights)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
512 (while hs
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
513 (setq h (car hs) match (nth 0 h)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
514 s (match-beginning match) e (match-end match)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
515 hs (cdr hs))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
516 (cond ((not s)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
517 ;; 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
518 (or (nth 3 h)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
519 (error "No subexpression %d in expression %d"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
520 match (1+ count))))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
521 ((and (not (nth 2 h))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
522 (text-property-not-all s e 'face nil))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
523 ;; Can't override and already fontified
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
524 nil)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
525 ((not (eq (nth 2 h) 'keep))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
526 ;; Can override but need not keep existing fontification
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
527 (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
528 (t
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
529 ;; Can override but must keep existing fontification
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
530 ;; (Does anyone use this? sm.)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
531 (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
532 (face (eval (nth 1 h))))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
533 (while p
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
534 (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
535 (put-text-property p n 'face face)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
536 (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
537 ;; the above form was:
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
538 ; (save-excursion
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
539 ; (goto-char s)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
540 ; (while (< (point) e)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
541 ; (let ((next (next-single-property-change (point) 'face
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
542 ; nil e)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
543 ; (if (or (null next) (> next e))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
544 ; (setq next e))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
545 ; (if (not (get-text-property (point) 'face))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
546 ; (put-text-property (point) next 'face face))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
547 ; (goto-char next))))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
548
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
549 (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
550 (make-string (setq count (1+ count)) ?.)))))
c0492d7043b2 (font-lock-syntax-table): New syntax table.
Richard M. Stallman <rms@gnu.org>
parents: 7915
diff changeset
551 (set-syntax-table old-syntax))
7915
970912d4f413 Don't alter the underline face.
Richard M. Stallman <rms@gnu.org>
parents: 7847
diff changeset
552 (and (buffer-modified-p)
970912d4f413 Don't alter the underline face.
Richard M. Stallman <rms@gnu.org>
parents: 7847
diff changeset
553 (not modified)
970912d4f413 Don't alter the underline face.
Richard M. Stallman <rms@gnu.org>
parents: 7847
diff changeset
554 (set-buffer-modified-p nil))))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 ;; The user level functions
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 (defvar font-lock-mode nil) ; for modeline
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 (defvar font-lock-fontified nil) ; whether we have hacked this buffer
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 (put 'font-lock-fontified 'permanent-local t)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 ;;;###autoload
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (defun font-lock-mode (&optional arg)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 "Toggle Font Lock mode.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 With arg, turn Font Lock mode on if and only if arg is positive.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 When Font Lock mode is enabled, text is fontified as you type it:
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
570 - Comments are displayed in `font-lock-comment-face';
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
571 - Strings are displayed in `font-lock-string-face';
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
572 - 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
573 value of the variable `font-lock-keywords'.
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 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
576 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
577
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
578 (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
579
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
580 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
581
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
582 (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
583
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
584 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
585 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
586 the variable `font-lock-defaults-alist'.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
588 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
589 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
590 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
591 size, you can use \\[font-lock-fontify-buffer]."
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 (interactive "P")
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
593 (let ((on-p (if arg (> (prefix-numeric-value arg) 0) (not font-lock-mode))))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 (if (equal (buffer-name) " *Compiler Input*") ; hack for bytecomp...
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 (setq on-p nil))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
596 (if (not on-p)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
597 (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
598 (make-local-variable 'after-change-functions)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
599 (add-hook 'after-change-functions 'font-lock-after-change-function))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (set (make-local-variable 'font-lock-mode) on-p)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 (cond (on-p
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 (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
603 (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
604 (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
605 ;; 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
606 (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
607 (add-hook 'after-revert-hook 'font-lock-revert-cleanup)
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (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
609 (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
610 nil)
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
611 ((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
612 (> 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
613 (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
614 (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
615 (message "Fontifying %s... buffer too big." (buffer-name)))))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 (font-lock-fontified
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 (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
618 (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
619 (remove-hook 'after-revert-hook 'font-lock-revert-cleanup)
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 (font-lock-unfontify-region (point-min) (point-max))))
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 (force-mode-line-update)))
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
623 ;;;###autoload
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
624 (defun turn-on-font-lock ()
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
625 "Unconditionally turn on Font Lock mode."
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
626 (font-lock-mode 1))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
627
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
628 ;; 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
629 (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
630 (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
631
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 ;; 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
633 ;; 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
634 ;; 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
635 (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
636 (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
637 (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
638 (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
639
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
640 ;;;###autoload
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 (defun font-lock-fontify-buffer ()
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
642 "Fontify the current buffer the way `font-lock-mode' would."
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 (interactive)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 (let ((was-on font-lock-mode)
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
645 (verbose (or font-lock-verbose (interactive-p)))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
646 (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
647 (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
648 (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
649 ;; 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
650 (or was-on (font-lock-set-defaults))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
651 (condition-case nil
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
652 (save-excursion
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
653 (font-lock-unfontify-region (point-min) (point-max))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
654 (if (not font-lock-no-comments)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
655 (font-lock-fontify-region (point-min) (point-max) verbose))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
656 (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
657 (setq font-lock-fontified t))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
658 ;; 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
659 (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
660 (if verbose (message "Fontifying %s... %s." (buffer-name)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
661 (if font-lock-fontified "done" "aborted")))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
662 (and (buffer-modified-p)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
663 (not modified)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
664 (set-buffer-modified-p nil))))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
667 ;;; Various information shared by several modes.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
668 ;;; Information specific to a single mode should go in its load library.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 (defconst lisp-font-lock-keywords-1
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
671 (list
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 ;; highlight defining forms. This doesn't work too nicely for
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 ;; (defun (setf foo) ...) but it does work for (defvar foo) which
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 ;; is more important.
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
675 (list (concat "^(\\(def\\(const\\|ine-key\\(\\|-after\\)\\|var\\)\\)\\>"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
676 "\\s *\\([^ \t\n\)]+\\)?")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
677 '(1 font-lock-keyword-face) '(4 font-lock-variable-name-face nil t))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
678 (list (concat "^(\\(def\\(a\\(dvice\\|lias\\)\\|macro\\|subst\\|un\\)\\)\\>"
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-function-name-face nil t))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 ;;
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 ;; this is highlights things like (def* (setf foo) (bar baz)), but may
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 ;; be slower (I haven't really thought about it)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 ; ("^(def[-a-z]+\\s +\\(\\s(\\S)*\\s)\\|\\S(\\S *\\)"
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 ; 1 font-lock-function-name-face)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 )
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 "For consideration as a value of `lisp-font-lock-keywords'.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 This does fairly subdued highlighting.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 (defconst lisp-font-lock-keywords-2
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 (append
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 lisp-font-lock-keywords-1
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
693 (list
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
694 ;;
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
695 ;; Control structures.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
696 ;; ELisp:
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
697 ; ("cond" "if" "while" "let\\*?" "prog[nv12*]?" "catch" "throw"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
698 ; "save-restriction" "save-excursion"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
699 ; "save-window-excursion" "save-match-data" "unwind-protect"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
700 ; "condition-case" "track-mouse")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
701 (cons
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
702 (concat "(\\("
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
703 "c\\(atch\\|ond\\(\\|ition-case\\)\\)\\|if\\|let\\*?\\|prog[nv12*]?\\|"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
704 "save-\\(excursion\\|match-data\\|restriction\\|window-excursion\\)\\|"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
705 "t\\(hrow\\|rack-mouse\\)\\|unwind-protect\\|while"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
706 "\\)[ \t\n]") 1)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
707 ;; CLisp:
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
708 ; ("when" "unless" "do" "flet" "labels" "return" "return-from")
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
709 '("(\\(do\\|flet\\|labels\\|return\\(\\|-from\\)\\|unless\\|when\\)[ \t\n]"
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
710 . 1)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
711 ;;
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
712 ;; Fontify CLisp keywords.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
713 '("\\s :\\([-a-zA-Z0-9]+\\)\\>" . 1)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
714 ;;
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
715 ;; Function names in emacs-lisp docstrings (in the syntax that
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
716 ;; substitute-command-keys understands.)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
717 '("\\\\\\\\\\[\\([^]\\\n]+\\)]" 1 font-lock-reference-face t)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
718 ;;
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
719 ;; Words inside `' which tend to be function names
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
720 (let ((word-char "[-+a-zA-Z0-9_.*]"))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
721 (list (concat "`\\(" word-char word-char "+\\)'")
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
722 1 'font-lock-reference-face t))
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
723 ;;
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
724 ;; & keywords as types
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
725 '("\\&\\(optional\\|rest\\)\\>" . font-lock-type-face)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
726 ))
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 "For consideration as a value of `lisp-font-lock-keywords'.
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 This does a lot more highlighting.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 ;; default to the gaudier variety?
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 ;(defvar lisp-font-lock-keywords lisp-font-lock-keywords-2
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 ; "Additional expressions to highlight in Lisp modes.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 (defvar lisp-font-lock-keywords lisp-font-lock-keywords-1
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 "Additional expressions to highlight in Lisp modes.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 (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
738 "For consideration as a value of `c-font-lock-keywords'.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 This does fairly subdued highlighting.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 (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
742 "For consideration as a value of `c-font-lock-keywords'.
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 This does a lot more highlighting.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744
6219
d960f0463014 (c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 6093
diff changeset
745 (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
746 "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
747 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
748
d960f0463014 (c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 6093
diff changeset
749 (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
750 "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
751 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
752
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
753 (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
754 ; ("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
755 "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
756 (c-type-types
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
757 ; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
758 ; "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
759 ; "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
760 (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
761 "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
762 "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
763 "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
764 (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
765 ; ("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
766 ; "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
767 ; "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
768 (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
769 "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
770 "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
771 "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
772 (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
773 ; ("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
774 ; "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
775 ; "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
776 ; "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
777 (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
778 "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
779 "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
780 "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
781 "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
782 "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
783 (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
784 (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
785 (list
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
786 ;;
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
787 ;; 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
788 '("^#[ \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
789 ;;
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
790 ;; Fontify function macro names.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
791 '("^#[ \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
792 ;;
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
793 ;; 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
794 '("^\\(#[ \t]*[a-z]+\\)\\>[ \t]*\\(\\sw+\\)?"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
795 (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
796 ;;
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
797 ;; Fontify function name definitions (without type on line).
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
798 (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
799 ))
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
800
00cee8387866 Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents: 5878
diff changeset
801 (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
802 (append c-font-lock-keywords-1
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803 (list
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 ;;
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
805 ;; 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
806 (cons (concat "\\<\\(" c-type-types "\\)\\>") 'font-lock-type-face)
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 ;;
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
808 ;; Fontify variable/structure name declarations and definitions, or
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
809 ;; 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
810 (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
811 "\\(" ctoken "[ \t*]+\\)*"
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
812 "\\(" 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
813 9
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
814 '(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
815 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
816 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
817 ;;
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
818 ;; 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
819 ;; (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
820 (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
821 "\\(" 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
822 "\\(" 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 2
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
824 '(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
825 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
826 font-lock-variable-name-face))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
827 ;;
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
828 ;; 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
829 '("}[ \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
830 ;;
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 ;; 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
832 (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
833 ;;
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
834 ;; 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
835 '("\\<\\(case\\|goto\\)\\>[ \t]*\\([^ \t\n:;]+\\)?"
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
836 (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
837 '("^[ \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
838 )))
6219
d960f0463014 (c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 6093
diff changeset
839
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
840 (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
841 (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
842 (append c++-font-lock-keywords-1
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
843 (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
844 ;; 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
845 ;; 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
846 (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
847 (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
848 "\\(" 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
849 "\\(" 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
850 14
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
851 '(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
852 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
853 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
854 (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
855 "\\(" 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
856 "\\(" 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 2
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
858 '(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
859 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
860 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
861 '("}[ \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
862 (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
863 '("\\<\\(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
864 (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
865 '("^[ \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
866 )
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 ; default to the gaudier variety?
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 (defvar c-font-lock-keywords c-font-lock-keywords-1
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 "Additional expressions to highlight in C mode.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871
6219
d960f0463014 (c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 6093
diff changeset
872 (defvar c++-font-lock-keywords c++-font-lock-keywords-1
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 "Additional expressions to highlight in C++ mode.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 (defvar tex-font-lock-keywords
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 (list
7847
43045a12cb34 (tex-font-lock-keywords): Make the pattern for
Richard M. Stallman <rms@gnu.org>
parents: 7751
diff changeset
877 '("\\(\\\\\\([a-zA-Z@]+\\|.\\)\\)" 1 font-lock-keyword-face t)
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 '("{\\\\em\\([^}]+\\)}" 1 font-lock-comment-face t)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 '("{\\\\bf\\([^}]+\\)}" 1 font-lock-keyword-face t)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 '("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" 1 font-lock-function-name-face t)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 '("\\\\\\(begin\\|end\\){\\([a-zA-Z0-9\\*]+\\)}"
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 2 font-lock-function-name-face t)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 '("[^\\\\]\\$\\([^$]*\\)\\$" 1 font-lock-string-face t)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 ; '("\\$\\([^$]*\\)\\$" 1 font-lock-string-face t)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 )
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 "Additional expressions to highlight in TeX mode.")
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887
9487
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
888 ;; There is no html-mode.el shipped with Emacs; `font-lock-defaults' entry
f80b2a33df03 * font-lock.el: To make font-lock.el dumpable: (font-lock-display-type,
Simon Marshall <simon@gnu.org>
parents: 9444
diff changeset
889 ; would be: (html-font-lock-keywords 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
890 ;(defconst html-font-lock-keywords
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
891 ; '(("<!--[^>]*>" 0 font-lock-comment-face t) ; Comment.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
892 ; ("</?\\sw+" . font-lock-type-face) ; Normal tag start.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
893 ; (">" . font-lock-type-face) ; Normal tag end.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
894 ; ("<\\(/?\\(a\\|form\\|img\\|input\\)\\)\\>" ; Special tag name.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
895 ; 1 font-lock-function-name-face t)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
896 ; ("\\<\\(\\sw+\\)[>=]" 1 font-lock-keyword-face)) ; Tag attribute.
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
897 ; "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
898
7491
621c162a80db (font-lock-no-comments): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
899 (defun font-lock-set-defaults ()
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
900 "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
901 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
902 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
903 (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
904 (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
905 (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
906 ;; 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
907 (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
908 ;; 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
909 (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
910 (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
911 ;; 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
912 (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
913 (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
914 ;; 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
915 (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
916 (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
917 (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
918 (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
919 (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
920 (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
921 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
922 (setq slist (cdr slist))))))))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
923
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
924 ;; Install ourselves:
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
925
9513
76ce1230257f Use purify-flag not noninteractive.
Simon Marshall <simon@gnu.org>
parents: 9487
diff changeset
926 (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
927 (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
928 (font-lock-make-faces))
9389
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
929
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
930 (or (assq 'font-lock-mode minor-mode-alist)
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
931 (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
932
fec6bd86e836 (compilation-mode-font-lock-keywords,
Richard M. Stallman <rms@gnu.org>
parents: 9350
diff changeset
933 ;; Provide ourselves:
7491
621c162a80db (font-lock-no-comments): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 7298
diff changeset
934
4053
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 (provide 'font-lock)
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936
c142db721726 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 ;;; font-lock.el ends here