annotate lisp/font-lock.el @ 219:262b8bb4a523 r20-4b8

Import from CVS: tag r20-4b8
author cvs
date Mon, 13 Aug 2007 10:09:35 +0200
parents d44af0c54775
children 6c0ae1f9357f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1 ;;; font-lock.el --- decorating source files with fonts/colors based on syntax
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992-1995, 1997 Free Software Foundation, Inc.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Amdahl Corporation.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
5 ;; Copyright (C) 1996 Ben Wing.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
6
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
7 ;; Author: Jamie Zawinski <jwz@netscape.com>, for the LISPM Preservation Society.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
8 ;; Minimally merged with FSF 19.34 by Barry Warsaw <bwarsaw@python.org>
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
9 ;; Then (partially) synched with FSF 19.30, leading to:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
10 ;; Next Author: RMS
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
11 ;; Next Author: Simon Marshall <simon@gnu.ai.mit.edu>
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
12 ;; Latest XEmacs Author: Ben Wing
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
13 ;; Maintainer: XEmacs Development Team
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
14 ;; Keywords: languages, faces
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
15
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
16 ;; This file is part of XEmacs.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
17
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
18 ;; XEmacs is free software; you can redistribute it and/or modify it
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
19 ;; under the terms of the GNU General Public License as published by
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
20 ;; the Free Software Foundation; either version 2, or (at your option)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
21 ;; any later version.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
22
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
23 ;; XEmacs is distributed in the hope that it will be useful, but
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
24 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
25 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
26 ;; General Public License for more details.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
27
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
28 ;; You should have received a copy of the GNU General Public License
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
29 ;; along with XEmacs; see the file COPYING. If not, write to the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
30 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
31 ;; Boston, MA 02111-1307, USA.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
32
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
33 ;;; Synched up with: FSF 19.30 except for the code to initialize the faces.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
34
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
35 ;;; Commentary:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
36
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
37 ;; Font-lock-mode is a minor mode that causes your comments to be
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
38 ;; displayed in one face, strings in another, reserved words in another,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
39 ;; documentation strings in another, and so on.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
40 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
41 ;; Comments will be displayed in `font-lock-comment-face'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
42 ;; Strings will be displayed in `font-lock-string-face'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
43 ;; Doc strings will be displayed in `font-lock-doc-string-face'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
44 ;; Function and variable names (in their defining forms) will be
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
45 ;; displayed in `font-lock-function-name-face'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
46 ;; Reserved words will be displayed in `font-lock-keyword-face'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
47 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
48 ;; Don't let the name fool you: you can highlight things using different
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
49 ;; colors or background stipples instead of fonts, though that is not the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
50 ;; default. See the variables `font-lock-use-colors' and
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
51 ;; `font-lock-use-fonts' for broad control over this, or see the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
52 ;; documentation on faces and how to change their attributes for
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
53 ;; fine-grained control.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
54 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
55 ;; To make the text you type be fontified, use M-x font-lock-mode. When
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
56 ;; this minor mode is on, the fonts of the current line will be updated
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
57 ;; with every insertion or deletion.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
58 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
59 ;; By default, font-lock will automatically put newly loaded files
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
60 ;; into font-lock-mode if it knows about the file's mode. See the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
61 ;; variables `font-lock-auto-fontify', `font-lock-mode-enable-list',
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
62 ;; and `font-lock-mode-disable-list' for control over this.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
63 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
64 ;; The `font-lock-keywords' variable defines other patterns to highlight.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
65 ;; The default font-lock-mode-hook sets it to the value of the variables
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
66 ;; lisp-font-lock-keywords, c-font-lock-keywords, etc, as appropriate.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
67 ;; The easiest way to change the highlighting patterns is to change the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
68 ;; values of c-font-lock-keywords and related variables. See the doc
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
69 ;; string of the variable `font-lock-keywords' for the appropriate syntax.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
70 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
71 ;; The default value for `lisp-font-lock-keywords' is the value of the variable
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
72 ;; `lisp-font-lock-keywords-1'. You may like `lisp-font-lock-keywords-2'
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
73 ;; better; it highlights many more words, but is slower and makes your buffers
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
74 ;; be very visually noisy.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
75 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
76 ;; The same is true of `c-font-lock-keywords-1' and `c-font-lock-keywords-2';
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
77 ;; the former is subdued, the latter is loud.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
78 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
79 ;; You can make font-lock default to the gaudier variety of keyword
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
80 ;; highlighting by setting the variable `font-lock-maximum-decoration'
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
81 ;; before loading font-lock, or by calling the functions
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
82 ;; `font-lock-use-default-maximal-decoration' or
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
83 ;; `font-lock-use-default-minimal-decoration'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
84 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
85 ;; On a Sparc10, the initial fontification takes about 6 seconds for a typical
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
86 ;; 140k file of C code, using the default configuration. The actual speed
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
87 ;; depends heavily on the type of code in the file, and how many non-syntactic
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
88 ;; patterns match; for example, Xlib.h takes 23 seconds for 101k, because many
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
89 ;; patterns match in it. You can speed this up substantially by removing some
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
90 ;; of the patterns that are highlighted by default. Fontifying lisp code is
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
91 ;; significantly faster, because lisp has a more regular syntax than C, so the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
92 ;; regular expressions don't have to be as complicated.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
93 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
94 ;; It's called font-lock-mode here because on the Lispms it was called
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
95 ;; "Electric Font Lock Mode." It was called that because there was an older
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
96 ;; mode called "Electric Caps Lock Mode" which had the function of causing all
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
97 ;; of your source code to be in upper case except for strings and comments,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
98 ;; without you having to blip the caps lock key by hand all the time (thus the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
99 ;; "electric", as in `electric-c-brace'.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
100
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
101 ;; See also the related packages `fast-lock' and `lazy-lock'. Both
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
102 ;; attempt to speed up the initial fontification. `fast-lock' saves
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
103 ;; the fontification info when you exit Emacs and reloads it next time
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
104 ;; you load the file, so that the file doesn't have to be fontified
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
105 ;; again. `lazy-lock' does "lazy" fontification -- i.e. it only
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
106 ;; fontifies the text as it becomes visible rather than fontifying
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
107 ;; the whole file when it's first loaded in.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
108
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
109 ;; Further comments from the FSF:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
110
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
111 ;; Nasty regexps of the form "bar\\(\\|lo\\)\\|f\\(oo\\|u\\(\\|bar\\)\\)\\|lo"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
112 ;; are made thusly: (regexp-opt '("foo" "fu" "fubar" "bar" "barlo" "lo")) for
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
113 ;; efficiency.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
114
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
115 ;; What is fontification for? You might say, "It's to make my code look nice."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
116 ;; I think it should be for adding information in the form of cues. These cues
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
117 ;; should provide you with enough information to both (a) distinguish between
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
118 ;; different items, and (b) identify the item meanings, without having to read
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
119 ;; the items and think about it. Therefore, fontification allows you to think
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
120 ;; less about, say, the structure of code, and more about, say, why the code
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
121 ;; doesn't work. Or maybe it allows you to think less and drift off to sleep.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
122 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
123 ;; So, here are my opinions/advice/guidelines:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
124 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
125 ;; - Use the same face for the same conceptual object, across all modes.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
126 ;; i.e., (b) above, all modes that have items that can be thought of as, say,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
127 ;; keywords, should be highlighted with the same face, etc.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
128 ;; - Keep the faces distinct from each other as far as possible.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
129 ;; i.e., (a) above.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
130 ;; - Make the face attributes fit the concept as far as possible.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
131 ;; i.e., function names might be a bold colour such as blue, comments might
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
132 ;; be a bright colour such as red, character strings might be brown, because,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
133 ;; err, strings are brown (that was not the reason, please believe me).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
134 ;; - Don't use a non-nil OVERRIDE unless you have a good reason.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
135 ;; Only use OVERRIDE for special things that are easy to define, such as the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
136 ;; way `...' quotes are treated in strings and comments in Emacs Lisp mode.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
137 ;; Don't use it to, say, highlight keywords in commented out code or strings.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
138 ;; - Err, that's it.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
139
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
140
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
141 ;;; Code:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
142
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
143 (require 'fontl-hooks)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
144
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
145 ;;;;;;;;;;;;;;;;;;;;;; user variables ;;;;;;;;;;;;;;;;;;;;;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
146
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
147 (defgroup font-lock nil
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
148 "Decorate source files with fonts/colors based on syntax.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
149 Font-lock-mode is a minor mode that causes your comments to be
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
150 displayed in one face, strings in another, reserved words in another,
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
151 documentation strings in another, and so on.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
152
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
153 Comments will be displayed in `font-lock-comment-face'.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
154 Strings will be displayed in `font-lock-string-face'.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
155 Doc strings will be displayed in `font-lock-doc-string-face'.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
156 Function and variable names (in their defining forms) will be
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
157 displayed in `font-lock-function-name-face'.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
158 Reserved words will be displayed in `font-lock-keyword-face'."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
159 :group 'languages)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
160
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
161 (defgroup font-lock-faces nil
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
162 "Faces used by the font-lock package."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
163 :group 'font-lock
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
164 :group 'faces)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
165
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
166
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
167 (defcustom font-lock-verbose t
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
168 "*If non-nil, means show status messages when fontifying.
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
169 See also `font-lock-message-threshold'."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
170 :type 'boolean
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
171 :group 'font-lock)
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
172
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
173 (defcustom font-lock-message-threshold 6000
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
174 "*Minimum size of region being fontified for status messages to appear.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
175
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
176 The size is measured in characters. This affects `font-lock-fontify-region'
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
177 but not `font-lock-fontify-buffer'. (In other words, when you first visit
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
178 a file and it gets fontified, you will see status messages no matter what
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
179 size the file is. However, if you do something else like paste a
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
180 chunk of text or revert a buffer, you will see status messages only if the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
181 changed region is large enough.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
182
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
183 Note that setting `font-lock-verbose' to nil disables the status
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
184 messages entirely."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
185 :type 'integer
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
186 :group 'font-lock)
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
187
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
188 ;;;###autoload
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
189 (defcustom font-lock-auto-fontify t
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
190 "*Whether font-lock should automatically fontify files as they're loaded.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
191 This will only happen if font-lock has fontifying keywords for the major
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
192 mode of the file. You can get finer-grained control over auto-fontification
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
193 by using this variable in combination with `font-lock-mode-enable-list' or
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
194 `font-lock-mode-disable-list'."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
195 :type 'boolean
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
196 :group 'font-lock)
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
197
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
198 ;;;###autoload
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
199 (defcustom font-lock-mode-enable-list nil
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
200 "*List of modes to auto-fontify, if `font-lock-auto-fontify' is nil."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
201 :type '(repeat (symbol :tag "Mode"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
202 :group 'font-lock)
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
203
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
204 ;;;###autoload
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
205 (defcustom font-lock-mode-disable-list nil
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
206 "*List of modes not to auto-fontify, if `font-lock-auto-fontify' is t."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
207 :type '(repeat (symbol :tag "Mode"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
208 :group 'font-lock)
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
209
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
210 ;;;###autoload
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
211 (defcustom font-lock-use-colors '(color)
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
212 "*Specification for when Font Lock will set up color defaults.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
213 Normally this should be '(color), meaning that Font Lock will set up
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
214 color defaults that are only used on color displays. Set this to nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
215 if you don't want Font Lock to set up color defaults at all. This
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
216 should be one of
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
218 -- a list of valid tags, meaning that the color defaults will be used
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
219 when all of the tags apply. (e.g. '(color x))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
220 -- a list whose first element is 'or and whose remaining elements are
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
221 lists of valid tags, meaning that the defaults will be used when
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
222 any of the tag lists apply.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
223 -- nil, meaning that the defaults should not be set up at all.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
224
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
225 \(If you specify face values in your init file, they will override any
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
226 that Font Lock specifies, regardless of whether you specify the face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
227 values before or after loading Font Lock.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
228
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
229 See also `font-lock-use-fonts'. If you want more control over the faces
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
230 used for fontification, see the documentation of `font-lock-mode' for
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
231 how to do it."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
232 ;; Hard to do right.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
233 :type 'sexp
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
234 :group 'font-lock)
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
235
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
236 ;;;###autoload
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
237 (defcustom font-lock-use-fonts '(or (mono) (grayscale))
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
238 "*Specification for when Font Lock will set up non-color defaults.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
239
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
240 Normally this should be '(or (mono) (grayscale)), meaning that Font
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
241 Lock will set up non-color defaults that are only used on either mono
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
242 or grayscale displays. Set this to nil if you don't want Font Lock to
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
243 set up non-color defaults at all. This should be one of
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
244
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
245 -- a list of valid tags, meaning that the non-color defaults will be used
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
246 when all of the tags apply. (e.g. '(grayscale x))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
247 -- a list whose first element is 'or and whose remaining elements are
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
248 lists of valid tags, meaning that the defaults will be used when
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
249 any of the tag lists apply.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
250 -- nil, meaning that the defaults should not be set up at all.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
251
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
252 \(If you specify face values in your init file, they will override any
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
253 that Font Lock specifies, regardless of whether you specify the face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
254 values before or after loading Font Lock.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
255
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
256 See also `font-lock-use-colors'. If you want more control over the faces
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
257 used for fontification, see the documentation of `font-lock-mode' for
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
258 how to do it."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
259 :type 'sexp
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
260 :group 'font-lock)
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
261
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
262 ;;;###autoload
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
263 (defcustom font-lock-maximum-decoration t
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
264 "*If non-nil, the maximum decoration level for fontifying.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
265 If nil, use the minimum decoration (equivalent to level 0).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
266 If t, use the maximum decoration available.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
267 If a number, use that level of decoration (or if not available the maximum).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
268 If a list, each element should be a cons pair of the form (MAJOR-MODE . LEVEL),
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
269 where MAJOR-MODE is a symbol or t (meaning the default). For example:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
270 ((c++-mode . 2) (c-mode . t) (t . 1))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
271 means use level 2 decoration for buffers in `c++-mode', the maximum decoration
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
272 available for buffers in `c-mode', and level 1 decoration otherwise."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
273 :type '(choice (const :tag "default" nil)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
274 (const :tag "maximum" t)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
275 (integer :tag "level" 1)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
276 (repeat :menu-tag "mode specific" :tag "mode specific"
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
277 :value ((t . t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
278 (cons :tag "Instance"
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
279 (radio :tag "Mode"
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
280 (const :tag "all" t)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
281 (symbol :tag "name"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
282 (radio :tag "Decoration"
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
283 (const :tag "default" nil)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
284 (const :tag "maximum" t)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
285 (integer :tag "level" 1)))))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
286 :group 'font-lock)
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
287
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
288 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
289 (define-obsolete-variable-alias 'font-lock-use-maximal-decoration
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
290 'font-lock-maximum-decoration)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
291
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
292 ;;;###autoload
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
293 (defcustom font-lock-maximum-size (* 250 1024)
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
294 "*If non-nil, the maximum size for buffers for fontifying.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
295 Only buffers less than this can be fontified when Font Lock mode is turned on.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
296 If nil, means size is irrelevant.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
297 If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE),
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
298 where MAJOR-MODE is a symbol or t (meaning the default). For example:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
299 ((c++-mode . 256000) (c-mode . 256000) (rmail-mode . 1048576))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
300 means that the maximum size is 250K for buffers in `c++-mode' or `c-mode', one
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
301 megabyte for buffers in `rmail-mode', and size is irrelevant otherwise."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
302 :type '(choice (const :tag "none" nil)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
303 (integer :tag "size")
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
304 (repeat :menu-tag "mode specific" :tag "mode specific"
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
305 :value ((t . nil))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
306 (cons :tag "Instance"
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
307 (radio :tag "Mode"
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
308 (const :tag "all" t)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
309 (symbol :tag "name"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
310 (radio :tag "Size"
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
311 (const :tag "none" nil)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
312 (integer :tag "size")))))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
313 :group 'font-lock)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
314
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
315
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
316 ;; Fontification variables:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
317
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
318 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
319 (defvar font-lock-keywords nil
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
320 "A list of the keywords to highlight.
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
321 Each element should be of the form:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
322
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
323 MATCHER
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
324 (MATCHER . MATCH)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
325 (MATCHER . FACENAME)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
326 (MATCHER . HIGHLIGHT)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
327 (MATCHER HIGHLIGHT ...)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
328 (eval . FORM)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
329
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
330 where HIGHLIGHT should be either MATCH-HIGHLIGHT or MATCH-ANCHORED.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
331
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
332 FORM is an expression, whose value should be a keyword element,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
333 evaluated when the keyword is (first) used in a buffer. This feature
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
334 can be used to provide a keyword that can only be generated when Font
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
335 Lock mode is actually turned on.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
336
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
337 For highlighting single items, typically only MATCH-HIGHLIGHT is required.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
338 However, if an item or (typically) items is to be highlighted following the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
339 instance of another item (the anchor) then MATCH-ANCHORED may be required.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
340
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
341 MATCH-HIGHLIGHT should be of the form:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
342
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
343 (MATCH FACENAME OVERRIDE LAXMATCH)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
344
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
345 Where MATCHER can be either the regexp to search for, a variable
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
346 containing the regexp to search for, or the function to call to make
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
347 the search (called with one argument, the limit of the search). MATCH
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
348 is the subexpression of MATCHER to be highlighted. FACENAME is either
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
349 a symbol naming a face, or an expression whose value is the face name
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
350 to use. If you want FACENAME to be a symbol that evaluates to a face,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
351 use a form like \"(progn sym)\".
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
352
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
353 OVERRIDE and LAXMATCH are flags. If OVERRIDE is t, existing fontification may
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
354 be overwritten. If `keep', only parts not already fontified are highlighted.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
355 If `prepend' or `append', existing fontification is merged with the new, in
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
356 which the new or existing fontification, respectively, takes precedence.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
357 If LAXMATCH is non-nil, no error is signalled if there is no MATCH in MATCHER.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
358
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
359 For example, an element of the form highlights (if not already highlighted):
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
360
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
361 \"\\\\\\=<foo\\\\\\=>\" Discrete occurrences of \"foo\" in the value of the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
362 variable `font-lock-keyword-face'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
363 (\"fu\\\\(bar\\\\)\" . 1) Substring \"bar\" within all occurrences of \"fubar\" in
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
364 the value of `font-lock-keyword-face'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
365 (\"fubar\" . fubar-face) Occurrences of \"fubar\" in the value of `fubar-face'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
366 (\"foo\\\\|bar\" 0 foo-bar-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
367 Occurrences of either \"foo\" or \"bar\" in the value
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
368 of `foo-bar-face', even if already highlighted.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
369
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
370 MATCH-ANCHORED should be of the form:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
371
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
372 (MATCHER PRE-MATCH-FORM POST-MATCH-FORM MATCH-HIGHLIGHT ...)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
373
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
374 Where MATCHER is as for MATCH-HIGHLIGHT with one exception; see below.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
375 PRE-MATCH-FORM and POST-MATCH-FORM are evaluated before the first, and after
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
376 the last, instance MATCH-ANCHORED's MATCHER is used. Therefore they can be
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
377 used to initialise before, and cleanup after, MATCHER is used. Typically,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
378 PRE-MATCH-FORM is used to move to some position relative to the original
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
379 MATCHER, before starting with MATCH-ANCHORED's MATCHER. POST-MATCH-FORM might
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
380 be used to move, before resuming with MATCH-ANCHORED's parent's MATCHER.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
381
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
382 For example, an element of the form highlights (if not already highlighted):
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
383
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
384 (\"\\\\\\=<anchor\\\\\\=>\" (0 anchor-face) (\"\\\\\\=<item\\\\\\=>\" nil nil (0 item-face)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
385
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
386 Discrete occurrences of \"anchor\" in the value of `anchor-face', and subsequent
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
387 discrete occurrences of \"item\" (on the same line) in the value of `item-face'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
388 (Here PRE-MATCH-FORM and POST-MATCH-FORM are nil. Therefore \"item\" is
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
389 initially searched for starting from the end of the match of \"anchor\", and
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
390 searching for subsequent instance of \"anchor\" resumes from where searching
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
391 for \"item\" concluded.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
392
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
393 The above-mentioned exception is as follows. The limit of the MATCHER search
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
394 defaults to the end of the line after PRE-MATCH-FORM is evaluated.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
395 However, if PRE-MATCH-FORM returns a position greater than the position after
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
396 PRE-MATCH-FORM is evaluated, that position is used as the limit of the search.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
397 It is generally a bad idea to return a position greater than the end of the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
398 line, i.e., cause the MATCHER search to span lines.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
399
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
400 Note that the MATCH-ANCHORED feature is experimental; in the future, we may
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
401 replace it with other ways of providing this functionality.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
402
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
403 These regular expressions should not match text which spans lines. While
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
404 \\[font-lock-fontify-buffer] handles multi-line patterns correctly, updating
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
405 when you edit the buffer does not, since it considers text one line at a time.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
406
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
407 Be very careful composing regexps for this list;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
408 the wrong pattern can dramatically slow things down!")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
409 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
410 (make-variable-buffer-local 'font-lock-keywords)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
411
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
412 (defvar font-lock-defaults nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
413 "The defaults font Font Lock mode for the current buffer.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
414 Normally, do not set this directly. If you are writing a major mode,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
415 put a property of `font-lock-defaults' on the major-mode symbol with
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
416 the desired value.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
417
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
418 It should be a list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
419
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
420 \(KEYWORDS KEYWORDS-ONLY CASE-FOLD SYNTAX-ALIST SYNTAX-BEGIN)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
421
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
422 KEYWORDS may be a symbol (a variable or function whose value is the keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
423 to use for fontification) or a list of symbols. If KEYWORDS-ONLY is non-nil,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
424 syntactic fontification (strings and comments) is not performed. If CASE-FOLD
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
425 is non-nil, the case of the keywords is ignored when fontifying. If
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
426 SYNTAX-ALIST is non-nil, it should be a list of cons pairs of the form (CHAR
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
427 . STRING) used to set the local Font Lock syntax table, for keyword and
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
428 syntactic fontification (see `modify-syntax-entry').
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
429
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
430 If SYNTAX-BEGIN is non-nil, it should be a function with no args used to move
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
431 backwards outside any enclosing syntactic block, for syntactic fontification.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
432 Typical values are `beginning-of-line' (i.e., the start of the line is known to
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
433 be outside a syntactic block), or `beginning-of-defun' for programming modes or
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
434 `backward-paragraph' for textual modes (i.e., the mode-dependent function is
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
435 known to move outside a syntactic block). If nil, the beginning of the buffer
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
436 is used as a position outside of a syntactic block, in the worst case.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
437
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
438 These item elements are used by Font Lock mode to set the variables
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
439 `font-lock-keywords', `font-lock-keywords-only',
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
440 `font-lock-keywords-case-fold-search', `font-lock-syntax-table' and
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
441 `font-lock-beginning-of-syntax-function', respectively.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
442
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
443 Alternatively, if the value is a symbol, it should name a major mode,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
444 and the defaults for that mode will apply.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
445 (make-variable-buffer-local 'font-lock-defaults)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
446
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
447 ;; FSF uses `font-lock-defaults-alist' and expects the major mode to
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
448 ;; set a value for `font-lock-defaults', but I don't like either of
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
449 ;; these -- requiring the mode to set `font-lock-defaults' makes it
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
450 ;; impossible to have defaults for a minor mode, and using an alist is
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
451 ;; generally a bad idea for information that really should be
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
452 ;; decentralized. (Who knows what strange modes might want
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
453 ;; font-locking?)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
454
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
455 (defvar font-lock-keywords-only nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
456 "Non-nil means Font Lock should not do syntactic fontification.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
457 This is normally set via `font-lock-defaults'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
458
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
459 This should be nil for all ``language'' modes, but other modes, like
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
460 dired, do not have anything useful in the syntax tables (no comment
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
461 or string delimiters, etc) and so there is no need to use them and
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
462 this variable should have a value of t.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
463
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
464 You should not set this variable directly; its value is computed
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
465 from `font-lock-defaults', or (if that does not specify anything)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
466 by examining the syntax table to see whether it appears to contain
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
467 anything useful.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
468 (make-variable-buffer-local 'font-lock-keywords-only)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
469
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
470 (defvar font-lock-keywords-case-fold-search nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
471 "Whether the strings in `font-lock-keywords' should be case-folded.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
472 This variable is automatically buffer-local, as the correct value depends
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
473 on the language in use.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
474 (make-variable-buffer-local 'font-lock-keywords-case-fold-search)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
475
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
476 (defvar font-lock-after-fontify-buffer-hook nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
477 "Function or functions to run after completion of font-lock-fontify-buffer.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
478
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
479 (defvar font-lock-syntax-table nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
480 "Non-nil means use this syntax table for fontifying.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
481 If this is nil, the major mode's syntax table is used.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
482 This is normally set via `font-lock-defaults'.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
483 (make-variable-buffer-local 'font-lock-syntax-table)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
484
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
485 ;; These are used in the FSF version in syntactic font-locking.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
486 ;; We do this all in C.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
487 ;;; These record the parse state at a particular position, always the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
488 ;;; start of a line. Used to make
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
489 ;;; `font-lock-fontify-syntactically-region' faster.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
490 ;(defvar font-lock-cache-position nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
491 ;(defvar font-lock-cache-state nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
492 ;(make-variable-buffer-local 'font-lock-cache-position)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
493 ;(make-variable-buffer-local 'font-lock-cache-state)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
494
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
495 ;; If this is nil, we only use the beginning of the buffer if we can't use
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
496 ;; `font-lock-cache-position' and `font-lock-cache-state'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
497 (defvar font-lock-beginning-of-syntax-function nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
498 "Non-nil means use this function to move back outside of a syntactic block.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
499 If this is nil, the beginning of the buffer is used (in the worst case).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
500 This is normally set via `font-lock-defaults'.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
501 (make-variable-buffer-local 'font-lock-beginning-of-syntax-function)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
502
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
503 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
504 (defvar font-lock-mode nil) ; for modeline
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
505 (defvar font-lock-fontified nil) ; whether we have hacked this buffer
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
506 (put 'font-lock-fontified 'permanent-local t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
507
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
508 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
509 (defvar font-lock-mode-hook nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
510 "Function or functions to run on entry to font-lock-mode.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
511
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
512 ; whether font-lock-set-defaults has already been run.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
513 (defvar font-lock-defaults-computed nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
514 (make-variable-buffer-local 'font-lock-defaults-computed)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
515
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
516
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
517 ;;; Initialization of faces.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
518
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
519 ;; #### barf gag retch. Horrid FSF lossage that we need to
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
520 ;; keep around for compatibility with font-lock-keywords that
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
521 ;; forget to properly quote their faces.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
522 (defvar font-lock-comment-face 'font-lock-comment-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
523 "Don't even think of using this.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
524 (defvar font-lock-doc-string-face 'font-lock-doc-string-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
525 "Don't even think of using this.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
526 (defvar font-lock-string-face 'font-lock-string-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
527 "Don't even think of using this.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
528 (defvar font-lock-keyword-face 'font-lock-keyword-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
529 "Don't even think of using this.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
530 (defvar font-lock-function-name-face 'font-lock-function-name-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
531 "Don't even think of using this.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
532 (defvar font-lock-variable-name-face 'font-lock-variable-name-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
533 "Don't even think of using this.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
534 (defvar font-lock-type-face 'font-lock-type-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
535 "Don't even think of using this.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
536 (defvar font-lock-reference-face 'font-lock-reference-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
537 "Don't even think of using this.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
538 (defvar font-lock-preprocessor-face 'font-lock-preprocessor-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
539 "Don't even think of using this.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
540
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
541 (defconst font-lock-face-list
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
542 '(font-lock-comment-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
543 font-lock-string-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
544 font-lock-doc-string-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
545 font-lock-keyword-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
546 font-lock-function-name-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
547 font-lock-variable-name-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
548 font-lock-type-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
549 font-lock-reference-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
550 font-lock-preprocessor-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
551 font-lock-warning-face))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
552
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
553 ;; #### There should be an emulation for the old font-lock-use-*
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
554 ;; settings!
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
555
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
556 (defface font-lock-comment-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
557 '((((class color) (background dark)) (:foreground "gray80"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
558 (((class color) (background light)) (:foreground "blue4"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
559 (((class grayscale) (background light))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
560 (:foreground "DimGray" :bold t :italic t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
561 (((class grayscale) (background dark))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
562 (:foreground "LightGray" :bold t :italic t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
563 (t (:bold t)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
564 "Font Lock mode face used to highlight comments."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
565 :group 'font-lock-faces)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
566
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
567 (defface font-lock-string-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
568 '((((class color) (background dark)) (:foreground "tan"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
569 (((class color) (background light)) (:foreground "green4"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
570 (((class grayscale) (background light)) (:foreground "DimGray" :italic t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
571 (((class grayscale) (background dark)) (:foreground "LightGray" :italic t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
572 (t (:bold t)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
573 "Font Lock mode face used to highlight strings."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
574 :group 'font-lock-faces)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
575
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
576 (defface font-lock-doc-string-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
577 '((((class color) (background dark)) (:foreground "light coral"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
578 (((class color) (background light)) (:foreground "green4"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
579 (t (:bold t)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
580 "Font Lock mode face used to highlight documentation strings."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
581 :group 'font-lock-faces)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
582
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
583 (defface font-lock-keyword-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
584 '((((class color) (background dark)) (:foreground "cyan"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
585 (((class color) (background light)) (:foreground "red4"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
586 (((class grayscale) (background light)) (:foreground "LightGray" :bold t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
587 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
588 (t (:bold t)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
589 "Font Lock mode face used to highlight keywords."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
590 :group 'font-lock-faces)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
591
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
592 (defface font-lock-function-name-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
593 '((((class color) (background dark)) (:foreground "aquamarine"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
594 (((class color) (background light)) (:foreground "brown4"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
595 (t (:bold t :underline t)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
596 "Font Lock mode face used to highlight function names."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
597 :group 'font-lock-faces)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
598
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
599 (defface font-lock-variable-name-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
600 '((((class color) (background dark)) (:foreground "cyan3"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
601 (((class color) (background light)) (:foreground "magenta4"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
602 (((class grayscale) (background light))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
603 (:foreground "Gray90" :bold t :italic t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
604 (((class grayscale) (background dark))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
605 (:foreground "DimGray" :bold t :italic t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
606 (t (:underline t)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
607 "Font Lock mode face used to highlight variable names."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
608 :group 'font-lock-faces)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
609
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
610 (defface font-lock-type-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
611 '((((class color) (background dark)) (:foreground "wheat"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
612 (((class color) (background light)) (:foreground "steelblue"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
613 (((class grayscale) (background light)) (:foreground "Gray90" :bold t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
614 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
615 (t (:bold t)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
616 "Font Lock mode face used to highlight types."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
617 :group 'font-lock-faces)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
618
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
619 (defface font-lock-reference-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
620 '((((class color) (background dark)) (:foreground "cadetblue2"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
621 (((class color) (background light)) (:foreground "red3"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
622 (((class grayscale) (background light))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
623 (:foreground "LightGray" :bold t :underline t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
624 (((class grayscale) (background dark))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
625 (:foreground "Gray50" :bold t :underline t)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
626 "Font Lock mode face used to highlight references."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
627 :group 'font-lock-faces)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
628
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
629 ;; #### FSF has font-lock-builtin-face.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
630
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
631 (defface font-lock-preprocessor-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
632 '((((class color) (background dark)) (:foreground "steelblue1"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
633 (((class color) (background black)) (:foreground "blue3"))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
634 (t (:underline t)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
635 "Font Lock Mode face used to highlight preprocessor conditionals."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
636 :group 'font-lock-faces)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
637
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
638 ;; #### Currently unused
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
639 (defface font-lock-warning-face
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
640 '((((class color) (background light)) (:foreground "Red" :bold t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
641 (((class color) (background dark)) (:foreground "Pink" :bold t))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
642 (t (:inverse-video t :bold t)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
643 "Font Lock mode face used to highlight warnings."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
644 :group 'font-lock-faces)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
645
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
646 (defun font-lock-recompute-variables ()
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
647 ;; Is this a Draconian thing to do?
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
648 (mapc #'(lambda (buffer)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
649 (with-current-buffer buffer
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
650 (font-lock-mode 0)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
651 (font-lock-set-defaults t)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
652 (buffer-list)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
653
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
654 ;; Backwards-compatible crud.
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
655
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
656 (defun font-lock-reset-all-faces ()
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
657 (dolist (face font-lock-face-list)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
658 (face-spec-set face (get face 'face-defface-spec))))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
659
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
660 (defun font-lock-use-default-fonts ()
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
661 "Reset the font-lock faces to a default set of fonts."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
662 (interactive)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
663 ;; #### !!!!
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
664 (font-lock-reset-all-faces))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
665
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
666 (defun font-lock-use-default-colors ()
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
667 "Reset the font-lock faces to a default set of colors."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
668 (interactive)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
669 ;; #### !!!!
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
670 (font-lock-reset-all-faces))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
671
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
672 (defun font-lock-use-default-minimal-decoration ()
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
673 "Reset the font-lock patterns to a fast, minimal set of decorations."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
674 (and font-lock-maximum-decoration
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
675 (setq font-lock-maximum-decoration nil)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
676 (font-lock-recompute-variables)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
677
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
678 (defun font-lock-use-default-maximal-decoration ()
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
679 "Reset the font-lock patterns to a larger set of decorations."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
680 (and (not (eq t font-lock-maximum-decoration))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
681 (setq font-lock-maximum-decoration t)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
682 (font-lock-recompute-variables)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
683
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
684
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
685 ;;;;;;;;;;;;;;;;;;;;;; actual code ;;;;;;;;;;;;;;;;;;;;;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
686
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
687 ;;; To fontify the whole buffer by language syntax, we go through it a
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
688 ;;; character at a time, creating extents on the boundary of each syntactic
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
689 ;;; unit (that is, one extent for each block comment, one for each line
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
690 ;;; comment, one for each string, etc.) This is done with the C function
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
691 ;;; syntactically-sectionize. It's in C for speed (the speed of lisp function
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
692 ;;; calls was a real bottleneck for this task since it involves examining each
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
693 ;;; character in turn.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
694 ;;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
695 ;;; Then we make a second pass, to fontify the buffer based on other patterns
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
696 ;;; specified by regexp. When we find a match for a region of text, we need
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
697 ;;; to change the fonts on those characters. This is done with the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
698 ;;; put-text-property function, which knows how to efficiently share extents.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
699 ;;; Conceptually, we are attaching some particular face to each of the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
700 ;;; characters in a range, but the implementation of this involves creating
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
701 ;;; extents, or resizing existing ones.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
702 ;;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
703 ;;; Each time a modification happens to a line, we re-fontify the entire line.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
704 ;;; We do this by first removing the extents (text properties) on the line,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
705 ;;; and then doing the syntactic and keyword passes again on that line. (More
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
706 ;;; generally, each modified region is extended to include the preceding and
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
707 ;;; following BOL or EOL.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
708 ;;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
709 ;;; This means that, as the user types, we repeatedly go back to the beginning
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
710 ;;; of the line, doing more work the longer the line gets. This doesn't cost
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
711 ;;; much in practice, and if we don't, then we incorrectly fontify things when,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
712 ;;; for example, inserting spaces into `intfoo () {}'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
713 ;;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
714
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
715
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
716 ;; The user level functions
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
717
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
718 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
719 (defun font-lock-mode (&optional arg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
720 "Toggle Font Lock Mode.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
721 With arg, turn font-lock mode on if and only if arg is positive.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
722
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
723 When Font Lock mode is enabled, text is fontified as you type it:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
724
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
725 - Comments are displayed in `font-lock-comment-face';
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
726 - Strings are displayed in `font-lock-string-face';
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
727 - Documentation strings (in Lisp-like languages) are displayed in
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
728 `font-lock-doc-string-face';
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
729 - Language keywords (\"reserved words\") are displayed in
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
730 `font-lock-keyword-face';
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
731 - Function names in their defining form are displayed in
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
732 `font-lock-function-name-face';
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
733 - Variable names in their defining form are displayed in
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
734 `font-lock-variable-name-face';
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
735 - Type names are displayed in `font-lock-type-face';
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
736 - References appearing in help files and the like are displayed
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
737 in `font-lock-reference-face';
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
738 - Preprocessor declarations are displayed in
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
739 `font-lock-preprocessor-face';
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
740
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
741 and
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
742
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
743 - Certain other expressions are displayed in other faces according
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
744 to the value of the variable `font-lock-keywords'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
745
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
746 Where modes support different levels of fontification, you can use the variable
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
747 `font-lock-maximum-decoration' to specify which level you generally prefer.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
748 When you turn Font Lock mode on/off the buffer is fontified/defontified, though
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
749 fontification occurs only if the buffer is less than `font-lock-maximum-size'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
750 To fontify a buffer without turning on Font Lock mode, and regardless of buffer
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
751 size, you can use \\[font-lock-fontify-buffer].
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
752
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
753 See the variable `font-lock-keywords' for customization."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
754 (interactive "P")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
755 (let ((on-p (if arg (> (prefix-numeric-value arg) 0) (not font-lock-mode)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
756 (maximum-size (if (not (consp font-lock-maximum-size))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
757 font-lock-maximum-size
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
758 (cdr (or (assq major-mode font-lock-maximum-size)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
759 (assq t font-lock-maximum-size))))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
760 ;; Font-lock mode will refuse to turn itself on if in batch mode, or if
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
761 ;; the current buffer is "invisible". The latter is because packages
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
762 ;; sometimes put their temporary buffers into some particular major mode
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
763 ;; to get syntax tables and variables and whatnot, but we don't want the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
764 ;; fact that the user has font-lock-mode on a mode hook to slow these
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
765 ;; things down.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
766 (if (or noninteractive (eq (aref (buffer-name) 0) ?\ ))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
767 (setq on-p nil))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
768 (if (equal (buffer-name) " *Compiler Input*") ; hack for bytecomp...
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
769 (setq on-p nil))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
770 (cond (on-p
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
771 (make-local-hook 'after-change-functions)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
772 (add-hook 'after-change-functions
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
773 'font-lock-after-change-function nil t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
774 (add-hook 'pre-idle-hook 'font-lock-pre-idle-hook))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
775 (t
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
776 (remove-hook 'after-change-functions
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
777 'font-lock-after-change-function t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
778 (setq font-lock-defaults-computed nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
779 font-lock-keywords nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
780 ;; We have no business doing this here, since
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
781 ;; pre-idle-hook is global. Other buffers may
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
782 ;; still be in font-lock mode. -dkindred@cs.cmu.edu
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
783 ;; (remove-hook 'pre-idle-hook 'font-lock-pre-idle-hook)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
784 ))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
785 (set (make-local-variable 'font-lock-mode) on-p)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
786 (cond (on-p
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
787 (font-lock-set-defaults-1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
788 (make-local-hook 'before-revert-hook)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
789 (make-local-hook 'after-revert-hook)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
790 ;; If buffer is reverted, must clean up the state.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
791 (add-hook 'before-revert-hook 'font-lock-revert-setup nil t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
792 (add-hook 'after-revert-hook 'font-lock-revert-cleanup nil t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
793 (run-hooks 'font-lock-mode-hook)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
794 (cond (font-lock-fontified
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
795 nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
796 ((or (null maximum-size) (<= (buffer-size) maximum-size))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
797 (font-lock-fontify-buffer))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
798 (font-lock-verbose
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
799 (lmessage 'command "Fontifying %s... buffer too big."
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
800 (buffer-name)))))
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
801 (font-lock-fontified
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
802 (setq font-lock-fontified nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
803 (remove-hook 'before-revert-hook 'font-lock-revert-setup t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
804 (remove-hook 'after-revert-hook 'font-lock-revert-cleanup t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
805 (font-lock-unfontify-region (point-min) (point-max))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
806 (font-lock-thing-lock-cleanup))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
807 (t
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
808 (remove-hook 'before-revert-hook 'font-lock-revert-setup t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
809 (remove-hook 'after-revert-hook 'font-lock-revert-cleanup t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
810 (font-lock-thing-lock-cleanup)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
811 (redraw-modeline)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
812
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
813 ;; For init-file hooks
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
814 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
815 (defun turn-on-font-lock ()
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
816 "Unconditionally turn on Font Lock mode."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
817 (font-lock-mode 1))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
818
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
819 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
820 (defun turn-off-font-lock ()
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
821 "Unconditionally turn off Font Lock mode."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
822 (font-lock-mode 0))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
823
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
824 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
825 (defun font-lock-fontify-buffer ()
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
826 "Fontify the current buffer the way `font-lock-mode' would.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
827 See `font-lock-mode' for details.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
828
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
829 This can take a while for large buffers."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
830 (interactive)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
831 (let ((was-on font-lock-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
832 (font-lock-verbose (or font-lock-verbose (interactive-p)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
833 (font-lock-message-threshold 0)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
834 (aborted nil))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
835 ;; Turn it on to run hooks and get the right font-lock-keywords.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
836 (or was-on (font-lock-mode 1))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
837 (font-lock-unfontify-region (point-min) (point-max) t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
838 ;; (buffer-syntactic-context-flush-cache)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
839
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
840 ;; If a ^G is typed during fontification, abort the fontification, but
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
841 ;; return normally (do not signal.) This is to make it easy to abort
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
842 ;; fontification if it's taking a long time, without also causing the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
843 ;; buffer not to pop up. If a real abort is desired, the user can ^G
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
844 ;; again.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
845 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
846 ;; Possibly this should happen down in font-lock-fontify-region instead
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
847 ;; of here, but since that happens from the after-change-hook (meaning
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
848 ;; much more frequently) I'm afraid of the bad consequences of stealing
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
849 ;; the interrupt character at inopportune times.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
850 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
851 (condition-case nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
852 (save-excursion
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
853 (font-lock-fontify-region (point-min) (point-max)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
854 (quit
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
855 (setq aborted t)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
856
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
857 (or was-on ; turn it off if it was off.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
858 (let ((font-lock-fontified nil)) ; kludge to prevent defontification
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
859 (font-lock-mode 0)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
860 (set (make-local-variable 'font-lock-fontified) t)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
861 (when (and aborted font-lock-verbose)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
862 (lmessage 'command "Fontifying %s... aborted." (buffer-name))))
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
863 (run-hooks 'font-lock-after-fontify-buffer-hook))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
864
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
865 ;; Fontification functions.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
866
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
867 ;; We first define some defsubsts to encapsulate the way we add
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
868 ;; faces to a region of text. I am planning on modifying the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
869 ;; text-property mechanism so that multiple independent classes
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
870 ;; of text properties can exist. That way, for example, ediff's
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
871 ;; face text properties don't interfere with font lock's face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
872 ;; text properties. Due to the XEmacs implementation of text
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
873 ;; properties in terms of extents, doing this is fairly trivial:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
874 ;; instead of using the `text-prop' property, you just use a
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
875 ;; specified property.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
876
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
877 (defsubst font-lock-set-face (start end face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
878 ;; Set the face on the characters in the range.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
879 (put-nonduplicable-text-property start end 'face face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
880 (put-nonduplicable-text-property start end 'font-lock t))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
881
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
882 (defsubst font-lock-remove-face (start end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
883 ;; Remove any syntax highlighting on the characters in the range.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
884 (put-nonduplicable-text-property start end 'face nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
885 (put-nonduplicable-text-property start end 'font-lock nil))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
886
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
887 (defsubst font-lock-any-faces-p (start end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
888 ;; Return non-nil if we've put any syntax highlighting on
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
889 ;; the characters in the range.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
890 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
891 ;; used to look for 'text-prop property, but this has problems if
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
892 ;; you put any other text properties in the vicinity. Simon
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
893 ;; Marshall suggested looking for the 'face property (this is what
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
894 ;; FSF Emacs does) but that's equally bogus. Only reliable way is
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
895 ;; for font-lock to specially mark its extents.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
896 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
897 ;; FSF's (equivalent) definition of this defsubst would be
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
898 ;; (text-property-not-all start end 'font-lock nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
899 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
900 ;; Perhaps our `map-extents' is faster than our definition
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
901 ;; of `text-property-not-all'. #### If so, `text-property-not-all'
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
902 ;; should be fixed ...
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
903 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
904 (map-extents 'extent-property (current-buffer) start (1- end) 'font-lock))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
905
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
906
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
907 ;; Fontification functions.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
908
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
909 ;; We use this wrapper. However, `font-lock-fontify-region' used to be the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
910 ;; name used for `font-lock-fontify-syntactically-region', so a change isn't
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
911 ;; back-compatible. But you shouldn't be calling these directly, should you?
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
912 (defun font-lock-fontify-region (beg end &optional loudly)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
913 (let ((modified (buffer-modified-p))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
914 (buffer-undo-list t) (inhibit-read-only t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
915 (old-syntax-table (syntax-table))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
916 buffer-file-name buffer-file-truename)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
917 (unwind-protect
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
918 (progn
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
919 ;; Use the fontification syntax table, if any.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
920 (if font-lock-syntax-table (set-syntax-table font-lock-syntax-table))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
921 ;; Now do the fontification.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
922 (if font-lock-keywords-only
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
923 (font-lock-unfontify-region beg end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
924 (font-lock-fontify-syntactically-region beg end loudly))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
925 (font-lock-fontify-keywords-region beg end loudly))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
926 ;; Clean up.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
927 (set-syntax-table old-syntax-table)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
928 (and (not modified) (buffer-modified-p) (set-buffer-modified-p nil)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
929
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
930 ;; The following must be rethought, since keywords can override fontification.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
931 ; ;; Now scan for keywords, but not if we are inside a comment now.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
932 ; (or (and (not font-lock-keywords-only)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
933 ; (let ((state (parse-partial-sexp beg end nil nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
934 ; font-lock-cache-state)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
935 ; (or (nth 4 state) (nth 7 state))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
936 ; (font-lock-fontify-keywords-region beg end))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
937
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
938 (defun font-lock-unfontify-region (beg end &optional maybe-loudly)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
939 (when (and maybe-loudly font-lock-verbose
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
940 (>= (- end beg) font-lock-message-threshold))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
941 (lmessage 'progress "Fontifying %s..." (buffer-name)))
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
942 (let ((modified (buffer-modified-p))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
943 (buffer-undo-list t) (inhibit-read-only t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
944 buffer-file-name buffer-file-truename)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
945 (font-lock-remove-face beg end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
946 (and (not modified) (buffer-modified-p) (set-buffer-modified-p nil))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
947
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
948 ;; Following is the original FSF version (similar to our original
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
949 ;; version, before all the crap I added below).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
950 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
951 ;; Probably that crap should either be fixed up so it works better,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
952 ;; or tossed away.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
953 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
954 ;; I think that lazy-lock v2 tries to do something similar.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
955 ;; Those efforts should be merged.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
956
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
957 ;; Called when any modification is made to buffer text.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
958 ;(defun font-lock-after-change-function (beg end old-len)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
959 ; (save-excursion
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
960 ; (save-match-data
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
961 ; ;; Rescan between start of line from `beg' and start of line after `end'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
962 ; (font-lock-fontify-region
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
963 ; (progn (goto-char beg) (beginning-of-line) (point))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
964 ; (progn (goto-char end) (forward-line 1) (point))))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
965
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
966 (defvar font-lock-old-extent nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
967 (defvar font-lock-old-len 0)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
968
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
969 (defun font-lock-fontify-glumped-region ()
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
970 ;; even if something goes wrong in the fontification, mark the glumped
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
971 ;; region as fontified; otherwise, the same error might get signaled
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
972 ;; after every command.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
973 (unwind-protect
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
974 ;; buffer may be deleted.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
975 (if (buffer-live-p (extent-object font-lock-old-extent))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
976 (save-excursion
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
977 (set-buffer (extent-object font-lock-old-extent))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
978 (font-lock-after-change-function-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
979 (extent-start-position font-lock-old-extent)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
980 (extent-end-position font-lock-old-extent)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
981 font-lock-old-len)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
982 (detach-extent font-lock-old-extent)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
983 (setq font-lock-old-extent nil)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
984
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
985 (defun font-lock-pre-idle-hook ()
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
986 (condition-case nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
987 (if font-lock-old-extent
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
988 (font-lock-fontify-glumped-region))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
989 (error (warn "Error caught in `font-lock-pre-idle-hook'"))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
990
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
991 (defvar font-lock-always-fontify-immediately nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
992 "Set this to non-nil to disable font-lock deferral.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
993
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
994 ;;; called when any modification is made to buffer text. This function
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
995 ;;; attempts to glump adjacent changes together so that excessive
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
996 ;;; fontification is avoided. This function could easily be adapted
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
997 ;;; to other after-change-functions.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
998
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
999 (defun font-lock-after-change-function (beg end old-len)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1000 (let ((obeg (and font-lock-old-extent
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1001 (extent-start-position font-lock-old-extent)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1002 (oend (and font-lock-old-extent
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1003 (extent-end-position font-lock-old-extent)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1004 (bc-end (+ beg old-len)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1005
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1006 ;; If this change can't be merged into the glumped one,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1007 ;; we need to fontify the glumped one right now.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1008 (if (and font-lock-old-extent
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1009 (or (not (eq (current-buffer)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1010 (extent-object font-lock-old-extent)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1011 (< bc-end obeg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1012 (> beg oend)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1013 (font-lock-fontify-glumped-region))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1014
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1015 (if font-lock-old-extent
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1016 ;; Update glumped region.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1017 (progn
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1018 ;; Any characters in the before-change region that are
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1019 ;; outside the glumped region go into the glumped
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1020 ;; before-change region.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1021 (if (> bc-end oend)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1022 (setq font-lock-old-len (+ font-lock-old-len (- bc-end oend))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1023 (if (> obeg beg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1024 (setq font-lock-old-len (+ font-lock-old-len (- obeg beg))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1025 ;; New glumped region is the union of the glumped region
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1026 ;; and the new region.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1027 (set-extent-endpoints font-lock-old-extent
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1028 (min obeg beg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1029 (max oend end)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1030
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1031 ;; No glumped region, so create one.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1032 (setq font-lock-old-extent (make-extent beg end))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1033 (set-extent-property font-lock-old-extent 'detachable nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1034 (set-extent-property font-lock-old-extent 'end-open nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1035 (setq font-lock-old-len old-len))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1036
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1037 (if font-lock-always-fontify-immediately
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1038 (font-lock-fontify-glumped-region))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1039
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1040 (defun font-lock-after-change-function-1 (beg end old-len)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1041 (if (null font-lock-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1042 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1043 (save-excursion
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1044 (save-restriction
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1045 ;; if we don't widen, then fill-paragraph (and any command that
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1046 ;; operates on a narrowed region) confuses things, because the C
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1047 ;; code will fail to realize that we're inside a comment.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1048 (widen)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1049 (save-match-data
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1050 (let ((zmacs-region-stays zmacs-region-stays)) ; protect from change!
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1051 (goto-char beg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1052 ;; Maybe flush the internal cache used by syntactically-sectionize.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1053 ;; (It'd be nice if this was more automatic.) Any deletions mean
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1054 ;; the cache is invalid, and insertions at beginning or end of line
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1055 ;; mean that the bol cache might be invalid.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1056 ;; (if (or (> old-len 0) (bobp) (= (preceding-char) ?\n))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1057 ;; (buffer-syntactic-context-flush-cache))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1058
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1059 ;; Always recompute the whole line.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1060 (goto-char end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1061 (forward-line 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1062 (setq end (point))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1063 (goto-char beg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1064 (beginning-of-line)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1065 (setq beg (point))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1066 ;; Rescan between start of line from `beg' and start of line after
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1067 ;; `end'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1068 (font-lock-fontify-region beg end)))))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1069
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1070
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1071 ;; Syntactic fontification functions.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1072
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1073 ;; Note: Here is the FSF version. Our version is much faster because
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1074 ;; of the C support we provide. This may be useful for reference,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1075 ;; however, and perhaps there is something useful here that should
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1076 ;; be merged into our version.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1077 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1078 ;(defun font-lock-fontify-syntactically-region (start end &optional loudly)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1079 ; "Put proper face on each string and comment between START and END.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1080 ;START should be at the beginning of a line."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1081 ; (let ((synstart (if comment-start-skip
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1082 ; (concat "\\s\"\\|" comment-start-skip)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1083 ; "\\s\""))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1084 ; (comstart (if comment-start-skip
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1085 ; (concat "\\s<\\|" comment-start-skip)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1086 ; "\\s<"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1087 ; state prev prevstate)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1088 ; (if loudly (message "Fontifying %s... (syntactically...)" (buffer-name)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1089 ; (save-restriction
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1090 ; (widen)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1091 ; (goto-char start)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1092 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1093 ; ;; Find the state at the `beginning-of-line' before `start'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1094 ; (if (eq start font-lock-cache-position)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1095 ; ;; Use the cache for the state of `start'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1096 ; (setq state font-lock-cache-state)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1097 ; ;; Find the state of `start'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1098 ; (if (null font-lock-beginning-of-syntax-function)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1099 ; ;; Use the state at the previous cache position, if any, or
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1100 ; ;; otherwise calculate from `point-min'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1101 ; (if (or (null font-lock-cache-position)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1102 ; (< start font-lock-cache-position))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1103 ; (setq state (parse-partial-sexp (point-min) start))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1104 ; (setq state (parse-partial-sexp font-lock-cache-position start
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1105 ; nil nil font-lock-cache-state)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1106 ; ;; Call the function to move outside any syntactic block.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1107 ; (funcall font-lock-beginning-of-syntax-function)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1108 ; (setq state (parse-partial-sexp (point) start)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1109 ; ;; Cache the state and position of `start'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1110 ; (setq font-lock-cache-state state
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1111 ; font-lock-cache-position start))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1112 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1113 ; ;; If the region starts inside a string, show the extent of it.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1114 ; (if (nth 3 state)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1115 ; (let ((beg (point)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1116 ; (while (and (re-search-forward "\\s\"" end 'move)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1117 ; (nth 3 (parse-partial-sexp beg (point)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1118 ; nil nil state))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1119 ; (put-text-property beg (point) 'face font-lock-string-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1120 ; (setq state (parse-partial-sexp beg (point) nil nil state))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1121 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1122 ; ;; Likewise for a comment.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1123 ; (if (or (nth 4 state) (nth 7 state))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1124 ; (let ((beg (point)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1125 ; (save-restriction
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1126 ; (narrow-to-region (point-min) end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1127 ; (condition-case nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1128 ; (progn
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1129 ; (re-search-backward comstart (point-min) 'move)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1130 ; (forward-comment 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1131 ; ;; forward-comment skips all whitespace,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1132 ; ;; so go back to the real end of the comment.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1133 ; (skip-chars-backward " \t"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1134 ; (error (goto-char end))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1135 ; (put-text-property beg (point) 'face font-lock-comment-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1136 ; (setq state (parse-partial-sexp beg (point) nil nil state))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1137 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1138 ; ;; Find each interesting place between here and `end'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1139 ; (while (and (< (point) end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1140 ; (setq prev (point) prevstate state)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1141 ; (re-search-forward synstart end t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1142 ; (progn
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1143 ; ;; Clear out the fonts of what we skip over.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1144 ; (remove-text-properties prev (point) '(face nil))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1145 ; ;; Verify the state at that place
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1146 ; ;; so we don't get fooled by \" or \;.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1147 ; (setq state (parse-partial-sexp prev (point)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1148 ; nil nil state))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1149 ; (let ((here (point)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1150 ; (if (or (nth 4 state) (nth 7 state))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1151 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1152 ; ;; We found a real comment start.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1153 ; (let ((beg (match-beginning 0)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1154 ; (goto-char beg)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1155 ; (save-restriction
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1156 ; (narrow-to-region (point-min) end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1157 ; (condition-case nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1158 ; (progn
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1159 ; (forward-comment 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1160 ; ;; forward-comment skips all whitespace,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1161 ; ;; so go back to the real end of the comment.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1162 ; (skip-chars-backward " \t"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1163 ; (error (goto-char end))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1164 ; (put-text-property beg (point) 'face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1165 ; font-lock-comment-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1166 ; (setq state (parse-partial-sexp here (point) nil nil state)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1167 ; (if (nth 3 state)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1168 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1169 ; ;; We found a real string start.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1170 ; (let ((beg (match-beginning 0)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1171 ; (while (and (re-search-forward "\\s\"" end 'move)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1172 ; (nth 3 (parse-partial-sexp here (point)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1173 ; nil nil state))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1174 ; (put-text-property beg (point) 'face font-lock-string-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1175 ; (setq state (parse-partial-sexp here (point)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1176 ; nil nil state))))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1177 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1178 ; ;; Make sure `prev' is non-nil after the loop
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1179 ; ;; only if it was set on the very last iteration.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1180 ; (setq prev nil)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1181 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1182 ; ;; Clean up.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1183 ; (and prev (remove-text-properties prev end '(face nil)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1184
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1185 (defun font-lock-fontify-syntactically-region (start end &optional loudly)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1186 "Put proper face on each string and comment between START and END.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1187 START should be at the beginning of a line."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1188 (if font-lock-keywords-only
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1189 nil
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
1190 (when (and font-lock-verbose
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
1191 (>= (- end start) font-lock-message-threshold))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
1192 (lmessage 'progress "Fontifying %s... (syntactically...)"
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
1193 (buffer-name)))
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1194 (font-lock-unfontify-region start end loudly)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1195 (goto-char start)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1196 (if (> end (point-max)) (setq end (point-max)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1197 (syntactically-sectionize
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1198 #'(lambda (s e context depth)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1199 (let (face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1200 (cond ((eq context 'string)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1201 ;;#### Should only do this is Lisp-like modes!
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1202 (setq face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1203 (if (= depth 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1204 ;; really we should only use this if
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1205 ;; in position 3 depth 1, but that's
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1206 ;; too expensive to compute.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1207 'font-lock-doc-string-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1208 'font-lock-string-face)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1209 ((or (eq context 'comment)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1210 (eq context 'block-comment))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1211 (setq face 'font-lock-comment-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1212 ; ;; Don't fontify whitespace at the beginning of lines;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1213 ; ;; otherwise comment blocks may not line up with code.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1214 ; ;; (This is sometimes a good idea, sometimes not; in any
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1215 ; ;; event it should be in C for speed --jwz)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1216 ; (save-excursion
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1217 ; (goto-char s)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1218 ; (while (prog1 (search-forward "\n" (1- e) 'move)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1219 ; (setq face 'font-lock-comment-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1220 ; (setq e (point)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1221 ; (skip-chars-forward " \t\n")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1222 ; (setq s (point)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1223 ))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1224 (font-lock-set-face s e face)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1225 start end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1226 ))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1227
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1228 ;;; Additional text property functions.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1229
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1230 ;; The following three text property functions are not generally available (and
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1231 ;; it's not certain that they should be) so they are inlined for speed.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1232 ;; The case for `fillin-text-property' is simple; it may or not be generally
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1233 ;; useful. (Since it is used here, it is useful in at least one place.;-)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1234 ;; However, the case for `append-text-property' and `prepend-text-property' is
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1235 ;; more complicated. Should they remove duplicate property values or not? If
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1236 ;; so, should the first or last duplicate item remain? Or the one that was
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1237 ;; added? In our implementation, the first duplicate remains.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1238
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1239 ;; XEmacs: modified all these functions to use
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1240 ;; `put-nonduplicable-text-property' instead of `put-text-property', and
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1241 ;; the first one to take both SETPROP and MARKPROP, in accordance with the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1242 ;; changed definitions of `font-lock-any-faces-p' and `font-lock-set-face'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1243
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1244 (defsubst font-lock-fillin-text-property (start end setprop markprop value &optional object)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1245 "Fill in one property of the text from START to END.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1246 Arguments PROP and VALUE specify the property and value to put where none are
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1247 already in place. Therefore existing property values are not overwritten.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1248 Optional argument OBJECT is the string or buffer containing the text."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1249 (let ((start (text-property-any start end markprop nil object)) next)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1250 (while start
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1251 (setq next (next-single-property-change start markprop object end))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1252 (put-nonduplicable-text-property start next setprop value object)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1253 (put-nonduplicable-text-property start next markprop value object)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1254 (setq start (text-property-any next end markprop nil object)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1255
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1256 ;; This function (from simon's unique.el) is rewritten and inlined for speed.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1257 ;(defun unique (list function)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1258 ; "Uniquify LIST, deleting elements using FUNCTION.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1259 ;Return the list with subsequent duplicate items removed by side effects.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1260 ;FUNCTION is called with an element of LIST and a list of elements from LIST,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1261 ;and should return the list of elements with occurrences of the element removed,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1262 ;i.e., a function such as `delete' or `delq'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1263 ;This function will work even if LIST is unsorted. See also `uniq'."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1264 ; (let ((list list))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1265 ; (while list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1266 ; (setq list (setcdr list (funcall function (car list) (cdr list))))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1267 ; list)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1268
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1269 (defsubst font-lock-unique (list)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1270 "Uniquify LIST, deleting elements using `delq'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1271 Return the list with subsequent duplicate items removed by side effects."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1272 (let ((list list))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1273 (while list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1274 (setq list (setcdr list (delq (car list) (cdr list))))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1275 list)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1276
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1277 ;; A generalisation of `facemenu-add-face' for any property, but without the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1278 ;; removal of inactive faces via `facemenu-discard-redundant-faces' and special
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1279 ;; treatment of `default'. Uses `unique' to remove duplicate property values.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1280 (defsubst font-lock-prepend-text-property (start end prop value &optional object)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1281 "Prepend to one property of the text from START to END.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1282 Arguments PROP and VALUE specify the property and value to prepend to the value
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1283 already in place. The resulting property values are always lists, and unique.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1284 Optional argument OBJECT is the string or buffer containing the text."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1285 (let ((val (if (listp value) value (list value))) next prev)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1286 (while (/= start end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1287 (setq next (next-single-property-change start prop object end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1288 prev (get-text-property start prop object))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1289 (put-text-property
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1290 start next prop
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1291 (font-lock-unique (append val (if (listp prev) prev (list prev))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1292 object)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1293 (setq start next))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1294
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1295 (defsubst font-lock-append-text-property (start end prop value &optional object)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1296 "Append to one property of the text from START to END.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1297 Arguments PROP and VALUE specify the property and value to append to the value
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1298 already in place. The resulting property values are always lists, and unique.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1299 Optional argument OBJECT is the string or buffer containing the text."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1300 (let ((val (if (listp value) value (list value))) next prev)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1301 (while (/= start end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1302 (setq next (next-single-property-change start prop object end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1303 prev (get-text-property start prop object))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1304 (put-text-property
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1305 start next prop
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1306 (font-lock-unique (append (if (listp prev) prev (list prev)) val))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1307 object)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1308 (setq start next))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1309
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1310 ;;; Regexp fontification functions.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1311
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1312 (defsubst font-lock-apply-highlight (highlight)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1313 "Apply HIGHLIGHT following a match.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1314 HIGHLIGHT should be of the form MATCH-HIGHLIGHT, see `font-lock-keywords'."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1315 (let* ((match (nth 0 highlight))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1316 (start (match-beginning match)) (end (match-end match))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1317 (override (nth 2 highlight)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1318 (let ((newface (nth 1 highlight)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1319 (or (symbolp newface)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1320 (setq newface (eval newface)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1321 (cond ((not start)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1322 ;; No match but we might not signal an error.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1323 (or (nth 3 highlight)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1324 (error "No match %d in highlight %S" match highlight)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1325 ((= start end) nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1326 ((not override)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1327 ;; Cannot override existing fontification.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1328 (or (font-lock-any-faces-p start end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1329 (font-lock-set-face start end newface)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1330 ((eq override t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1331 ;; Override existing fontification.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1332 (font-lock-set-face start end newface))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1333 ((eq override 'keep)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1334 ;; Keep existing fontification.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1335 (font-lock-fillin-text-property start end 'face 'font-lock
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1336 newface))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1337 ((eq override 'prepend)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1338 ;; Prepend to existing fontification.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1339 (font-lock-prepend-text-property start end 'face newface))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1340 ((eq override 'append)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1341 ;; Append to existing fontification.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1342 (font-lock-append-text-property start end 'face newface))))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1343
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1344 (defsubst font-lock-fontify-anchored-keywords (keywords limit)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1345 "Fontify according to KEYWORDS until LIMIT.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1346 KEYWORDS should be of the form MATCH-ANCHORED, see `font-lock-keywords',
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1347 LIMIT can be modified by the value of its PRE-MATCH-FORM."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1348 (let ((matcher (nth 0 keywords)) (lowdarks (nthcdr 3 keywords)) highlights
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1349 ;; Evaluate PRE-MATCH-FORM.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1350 (pre-match-value (eval (nth 1 keywords))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1351 ;; Set LIMIT to value of PRE-MATCH-FORM or the end of line.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1352 (if (and (numberp pre-match-value) (> pre-match-value (point)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1353 (setq limit pre-match-value)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1354 (save-excursion (end-of-line) (setq limit (point))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1355 (save-match-data
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1356 ;; Find an occurrence of `matcher' before `limit'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1357 (while (if (stringp matcher)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1358 (re-search-forward matcher limit t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1359 (funcall matcher limit))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1360 ;; Apply each highlight to this instance of `matcher'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1361 (setq highlights lowdarks)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1362 (while highlights
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1363 (font-lock-apply-highlight (car highlights))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1364 (setq highlights (cdr highlights)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1365 ;; Evaluate POST-MATCH-FORM.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1366 (eval (nth 2 keywords))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1367
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1368 (defun font-lock-fontify-keywords-region (start end &optional loudvar)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1369 "Fontify according to `font-lock-keywords' between START and END.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1370 START should be at the beginning of a line."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1371 (let ((loudly (and font-lock-verbose
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1372 (>= (- end start) font-lock-message-threshold))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1373 (let ((case-fold-search font-lock-keywords-case-fold-search)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1374 (keywords (cdr (if (eq (car-safe font-lock-keywords) t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1375 font-lock-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1376 (font-lock-compile-keywords))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1377 (bufname (buffer-name)) (count 0)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1378 keyword matcher highlights)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1379 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1380 ;; Fontify each item in `font-lock-keywords' from `start' to `end'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1381 (while keywords
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
1382 (when loudly (lmessage 'progress "Fontifying %s... (regexps..%s)"
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
1383 bufname
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
1384 (make-string (setq count (1+ count)) ?.)))
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1385 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1386 ;; Find an occurrence of `matcher' from `start' to `end'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1387 (setq keyword (car keywords) matcher (car keyword))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1388 (goto-char start)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1389 (while (and (< (point) end)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1390 (if (stringp matcher)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1391 (re-search-forward matcher end t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1392 (funcall matcher end)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1393 ;; Apply each highlight to this instance of `matcher', which may be
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1394 ;; specific highlights or more keywords anchored to `matcher'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1395 (setq highlights (cdr keyword))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1396 (while highlights
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1397 (if (numberp (car (car highlights)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1398 (let ((end (match-end (car (car highlights)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1399 (font-lock-apply-highlight (car highlights))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1400 ;; restart search just after the end of the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1401 ;; keyword so keywords can share bracketing
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1402 ;; expressions.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1403 (and end (goto-char end)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1404 (font-lock-fontify-anchored-keywords (car highlights) end))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1405 (setq highlights (cdr highlights))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1406 (setq keywords (cdr keywords))))
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 217
diff changeset
1407 (if loudly (lmessage 'progress "Fontifying %s... done." (buffer-name)))))
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1408
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1409
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1410 ;; Various functions.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1411
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1412 ;; Turn off other related packages if they're on. I prefer a hook. --sm.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1413 ;; These explicit calls are easier to understand
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1414 ;; because people know what they will do.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1415 ;; A hook is a mystery because it might do anything whatever. --rms.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1416 (defun font-lock-thing-lock-cleanup ()
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1417 (cond ((and (boundp 'fast-lock-mode) fast-lock-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1418 (fast-lock-mode -1))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1419 ((and (boundp 'lazy-lock-mode) lazy-lock-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1420 (lazy-lock-mode -1))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1421 ((and (boundp 'lazy-shot-mode) lazy-shot-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1422 (lazy-shot-mode -1))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1423
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1424 ;; Do something special for these packages after fontifying. I prefer a hook.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1425 (defun font-lock-after-fontify-buffer ()
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1426 (cond ((and (boundp 'fast-lock-mode) fast-lock-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1427 (fast-lock-after-fontify-buffer))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1428 ((and (boundp 'lazy-lock-mode) lazy-lock-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1429 (lazy-lock-after-fontify-buffer))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1430
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1431 ;; If the buffer is about to be reverted, it won't be fontified afterward.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1432 (defun font-lock-revert-setup ()
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1433 (setq font-lock-fontified nil))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1434
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1435 ;; If the buffer has just been reverted, normally that turns off
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1436 ;; Font Lock mode. So turn the mode back on if necessary.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1437 (defalias 'font-lock-revert-cleanup 'turn-on-font-lock)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1438
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1439
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1440 (defun font-lock-compile-keywords (&optional keywords)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1441 ;; Compile `font-lock-keywords' into the form (t KEYWORD ...) where KEYWORD
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1442 ;; is the (MATCHER HIGHLIGHT ...) shown in the variable's doc string.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1443 (let ((keywords (or keywords font-lock-keywords)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1444 (setq font-lock-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1445 (if (eq (car-safe keywords) t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1446 keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1447 (cons t (mapcar 'font-lock-compile-keyword keywords))))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1448
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1449 (defun font-lock-compile-keyword (keyword)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1450 (cond ((nlistp keyword) ; Just MATCHER
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1451 (list keyword '(0 font-lock-keyword-face)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1452 ((eq (car keyword) 'eval) ; Specified (eval . FORM)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1453 (font-lock-compile-keyword (eval (cdr keyword))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1454 ((numberp (cdr keyword)) ; Specified (MATCHER . MATCH)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1455 (list (car keyword) (list (cdr keyword) 'font-lock-keyword-face)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1456 ((symbolp (cdr keyword)) ; Specified (MATCHER . FACENAME)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1457 (list (car keyword) (list 0 (cdr keyword))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1458 ((nlistp (nth 1 keyword)) ; Specified (MATCHER . HIGHLIGHT)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1459 (list (car keyword) (cdr keyword)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1460 (t ; Hopefully (MATCHER HIGHLIGHT ...)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1461 keyword)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1462
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1463 (defun font-lock-choose-keywords (keywords level)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1464 ;; Return LEVELth element of KEYWORDS. A LEVEL of nil is equal to a
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1465 ;; LEVEL of 0, a LEVEL of t is equal to (1- (length KEYWORDS)).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1466 (let ((level (if (not (consp level))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1467 level
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1468 (cdr (or (assq major-mode level) (assq t level))))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1469 (cond ((symbolp keywords)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1470 keywords)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1471 ((numberp level)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1472 (or (nth level keywords) (car (reverse keywords))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1473 ((eq level t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1474 (car (reverse keywords)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1475 (t
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1476 (car keywords)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1477
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1478
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1479 ;;; Determining which set of font-lock keywords to use.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1480
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1481 (defun font-lock-find-font-lock-defaults (modesym)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1482 ;; Get the defaults based on the major mode.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1483 (let (raw-defaults)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1484 ;; I want a do-while loop!
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1485 (while (progn
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1486 (setq raw-defaults (get modesym 'font-lock-defaults))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1487 (and raw-defaults (symbolp raw-defaults)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1488 (setq modesym raw-defaults)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1489 )
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1490 raw-defaults))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1491
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1492 (defun font-lock-examine-syntax-table ()
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1493 ; Computes the value of font-lock-keywords-only for this buffer.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1494 (if (eq (syntax-table) (standard-syntax-table))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1495 ;; Assume that modes which haven't bothered to install their own
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1496 ;; syntax table don't do anything syntactically interesting.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1497 ;; Really, the standard-syntax-table shouldn't have comments and
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1498 ;; strings in it, but changing that now might break things.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1499 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1500 ;; else map over the syntax table looking for strings or comments.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1501 (let (got-one)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1502 ;; XEmacs 20.0 ...
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1503 (if (fboundp 'map-syntax-table)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1504 (setq got-one
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1505 (map-syntax-table
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1506 #'(lambda (key value)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1507 (memq (char-syntax-from-code value)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1508 '(?\" ?\< ?\> ?\$)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1509 (syntax-table)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1510 ;; older Emacsen.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1511 (let ((i (1- (length (syntax-table)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1512 (while (>= i 0)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1513 (if (memq (char-syntax i) '(?\" ?\< ?\> ?\$))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1514 (setq got-one t i 0))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1515 (setq i (1- i)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1516 (set (make-local-variable 'font-lock-keywords-only) (not got-one)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1517
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1518 ;; font-lock-set-defaults is in fontl-hooks.el.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1519
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1520 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1521 (defun font-lock-set-defaults-1 (&optional explicit-defaults)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1522 ;; does everything that font-lock-set-defaults does except
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1523 ;; enable font-lock-mode. This is called by `font-lock-mode'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1524 ;; Note that the return value is used!
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1525
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1526 (if (and font-lock-defaults-computed (not explicit-defaults))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1527 ;; nothing to do.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1528 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1529
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1530 (or font-lock-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1531 (let* ((defaults (or (and (not (eq t explicit-defaults))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1532 explicit-defaults)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1533 ;; in case modes decide to set
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1534 ;; `font-lock-defaults' themselves,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1535 ;; as in FSF Emacs.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1536 font-lock-defaults
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1537 (font-lock-find-font-lock-defaults major-mode)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1538 (keywords (font-lock-choose-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1539 (nth 0 defaults) font-lock-maximum-decoration)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1540
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1541 ;; Keywords?
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1542 (setq font-lock-keywords (if (fboundp keywords)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1543 (funcall keywords)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1544 (eval keywords)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1545 (or font-lock-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1546 ;; older way:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1547 ;; try to look for a variable `foo-mode-font-lock-keywords',
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1548 ;; or similar.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1549 (let ((major (symbol-name major-mode))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1550 (try #'(lambda (n)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1551 (if (stringp n) (setq n (intern-soft n)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1552 (if (and n
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1553 (boundp n))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1554 n
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1555 nil))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1556 (setq font-lock-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1557 (symbol-value
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1558 (or (funcall try (get major-mode 'font-lock-keywords))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1559 (funcall try (concat major "-font-lock-keywords"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1560 (funcall try (and (string-match "-mode\\'" major)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1561 (concat (substring
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1562 major 0
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1563 (match-beginning 0))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1564 "-font-lock-keywords")))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1565 'font-lock-keywords)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1566
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1567 ;; Case fold?
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1568 (if (>= (length defaults) 3)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1569 (setq font-lock-keywords-case-fold-search (nth 2 defaults))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1570 ;; older way:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1571 ;; look for a property 'font-lock-keywords-case-fold-search on
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1572 ;; the major-mode symbol.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1573 (let* ((nonexist (make-symbol ""))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1574 (value (get major-mode 'font-lock-keywords-case-fold-search
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1575 nonexist)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1576 (if (not (eq nonexist value))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1577 (setq font-lock-keywords-case-fold-search value))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1578
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1579 ;; Syntactic?
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1580 (if (>= (length defaults) 2)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1581 (setq font-lock-keywords-only (nth 1 defaults))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1582 ;; older way:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1583 ;; cleverly examine the syntax table.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1584 (font-lock-examine-syntax-table))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1585
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1586 ;; Syntax table?
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1587 (if (nth 3 defaults)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1588 (let ((slist (nth 3 defaults)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1589 (setq font-lock-syntax-table
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1590 (copy-syntax-table (syntax-table)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1591 (while slist
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1592 (modify-syntax-entry (car (car slist)) (cdr (car slist))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1593 font-lock-syntax-table)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1594 (setq slist (cdr slist)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1595
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1596 ;; Syntax function?
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1597 (cond (defaults
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1598 (setq font-lock-beginning-of-syntax-function
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1599 (nth 4 defaults)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1600 (t
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1601 ;; older way:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1602 ;; defaults not specified at all, so use `beginning-of-defun'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1603 (setq font-lock-beginning-of-syntax-function
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1604 'beginning-of-defun)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1605
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1606 (setq font-lock-defaults-computed t)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1607
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1608
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1609 ;;;;;;;;;;;;;;;;;;;;;; keywords ;;;;;;;;;;;;;;;;;;;;;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1610
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1611 ;;; Various major-mode interfaces.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1612 ;;; Probably these should go in with the source of the respective major modes.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1613
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1614 ;; The defaults and keywords listed here should perhaps be moved into
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1615 ;; mode-specific files.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1616
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1617 ;; For C and Lisp modes we use `beginning-of-defun', rather than nil,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1618 ;; for SYNTAX-BEGIN. Thus the calculation of the cache is usually
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1619 ;; faster but not infallible, so we risk mis-fontification. --sm.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1620
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1621 (put 'c-mode 'font-lock-defaults
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1622 '((c-font-lock-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1623 c-font-lock-keywords-1 c-font-lock-keywords-2 c-font-lock-keywords-3)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1624 nil nil ((?_ . "w")) beginning-of-defun))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1625 (put 'c++-c-mode 'font-lock-defaults 'c-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1626 (put 'elec-c-mode 'font-lock-defaults 'c-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1627
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1628 (put 'c++-mode 'font-lock-defaults
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1629 '((c++-font-lock-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1630 c++-font-lock-keywords-1 c++-font-lock-keywords-2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1631 c++-font-lock-keywords-3)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1632 nil nil ((?_ . "w") (?~ . "w")) beginning-of-defun))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1633
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1634 (put 'java-mode 'font-lock-defaults
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1635 '((java-font-lock-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1636 java-font-lock-keywords-1 java-font-lock-keywords-2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1637 java-font-lock-keywords-3)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1638 nil nil ((?_ . "w")) beginning-of-defun
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1639 (font-lock-mark-block-function . mark-defun)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1640
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1641 (put 'lisp-mode 'font-lock-defaults
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1642 '((lisp-font-lock-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1643 lisp-font-lock-keywords-1 lisp-font-lock-keywords-2)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1644 nil nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1645 ((?: . "w") (?- . "w") (?* . "w") (?+ . "w") (?. . "w") (?< . "w")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1646 (?> . "w") (?= . "w") (?! . "w") (?? . "w") (?$ . "w") (?% . "w")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1647 (?_ . "w") (?& . "w") (?~ . "w") (?^ . "w") (?/ . "w"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1648 beginning-of-defun))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1649 (put 'emacs-lisp-mode 'font-lock-defaults 'lisp-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1650 (put 'lisp-interaction-mode 'font-lock-defaults 'lisp-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1651
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1652 (put 'scheme-mode 'font-lock-defaults
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1653 '(scheme-font-lock-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1654 nil t
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1655 ((?: . "w") (?- . "w") (?* . "w") (?+ . "w") (?. . "w") (?< . "w")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1656 (?> . "w") (?= . "w") (?! . "w") (?? . "w") (?$ . "w") (?% . "w")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1657 (?_ . "w") (?& . "w") (?~ . "w") (?^ . "w") (?/ . "w"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1658 beginning-of-defun))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1659 (put 'inferior-scheme-mode 'font-lock-defaults 'scheme-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1660 (put 'scheme-interaction-mode 'font-lock-defaults 'scheme-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1661
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1662 (put 'tex-mode 'font-lock-defaults
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1663 ;; For TeX modes we could use `backward-paragraph' for the same reason.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1664 '(tex-font-lock-keywords nil nil ((?$ . "\""))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1665 ;; the nine billion names of TeX mode...
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1666 (put 'bibtex-mode 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1667 (put 'plain-tex-mode 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1668 (put 'slitex-tex-mode 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1669 (put 'SliTeX-mode 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1670 (put 'slitex-mode 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1671 (put 'latex-tex-mode 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1672 (put 'LaTex-tex-mode 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1673 (put 'latex-mode 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1674 (put 'LaTeX-mode 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1675 (put 'japanese-LaTeX-mode 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1676 (put 'japanese-SliTeX-mode 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1677 (put 'FoilTeX-mode 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1678 (put 'LATeX-MoDe 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1679 (put 'lATEx-mODe 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1680 ;; ok, this is getting a bit silly ...
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1681 (put 'eDOm-xETAl 'font-lock-defaults 'tex-mode)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1682
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1683 ;;; Various regexp information shared by several modes.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1684 ;;; Information specific to a single mode should go in its load library.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1685
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1686 (defconst lisp-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1687 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1688 ;; Anything not a variable or type declaration is fontified as a function.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1689 ;; It would be cleaner to allow preceding whitespace, but it would also be
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1690 ;; about five times slower.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1691 (list (concat "^(\\(def\\("
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1692 ;; Variable declarations.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1693 "\\(const\\(\\|ant\\)\\|ine-key\\(\\|-after\\)\\|var\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1694 ;; Structure declarations.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1695 "\\(class\\|struct\\|type\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1696 ;; Everything else is a function declaration.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1697 "\\([^ \t\n\(\)]+\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1698 "\\)\\)\\>"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1699 ;; Any whitespace and declared object.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1700 "[ \t'\(]*"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1701 "\\([^ \t\n\)]+\\)?")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1702 '(1 font-lock-keyword-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1703 '(8 (cond ((match-beginning 3) 'font-lock-variable-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1704 ((match-beginning 6) 'font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1705 (t 'font-lock-function-name-face))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1706 nil t))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1707 )
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1708 "Subdued level highlighting Lisp modes.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1709
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1710 (defconst lisp-font-lock-keywords-2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1711 (append lisp-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1712 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1713 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1714 ;; Control structures. ELisp and CLisp combined.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1715 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1716 ;;(regexp-opt
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1717 ;; '("cond" "if" "while" "let" "let*" "prog" "progn" "prog1"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1718 ;; "prog2" "progv" "catch" "throw" "save-restriction"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1719 ;; "save-excursion" "save-window-excursion"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1720 ;; "save-current-buffer" "with-current-buffer"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1721 ;; "with-temp-file" "with-temp-buffer" "with-output-to-string"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1722 ;; "with-string-as-buffer-contents"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1723 ;; "save-selected-window" "save-match-data" "unwind-protect"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1724 ;; "condition-case" "track-mouse" "autoload"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1725 ;; "eval-after-load" "eval-and-compile" "eval-when-compile"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1726 ;; "when" "unless" "do" "dolist" "dotimes" "flet" "labels"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1727 ;; "lambda" "return" "return-from"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1728 (cons
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1729 (concat
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1730 "(\\("
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1731 "autoload\\|c\\(atch\\|ond\\(ition-case\\)?\\)\\|do\\(list\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1732 "times\\)?\\|eval-\\(a\\(fter-load\\|nd-compile\\)\\|when-compile\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1733 "flet\\|if\\|l\\(a\\(bels\\|mbda\\)\\|et\\*?\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1734 "prog[nv12\\*]?\\|return\\(-from\\)?\\|save-\\(current-buffer\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1735 "excursion\\|match-data\\|restriction\\|selected-window\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1736 "window-excursion\\)\\|t\\(hrow\\|rack-mouse\\)\\|un\\(less\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1737 "wind-protect\\)\\|w\\(h\\(en\\|ile\\)\\|ith-\\(current-buffer\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1738 "output-to-string\\|string-as-buffer-contents\\|temp-\\(buffer\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1739 "file\\)\\)\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1740 "\\)\\>") 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1741 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1742 ;; Words inside \\[] tend to be for `substitute-command-keys'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1743 '("\\\\\\\\\\[\\(\\sw+\\)]" 1 font-lock-reference-face prepend)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1744 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1745 ;; Words inside `' tend to be symbol names.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1746 '("`\\(\\sw\\sw+\\)'" 1 font-lock-reference-face prepend)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1747 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1748 ;; CLisp `:' keywords as references.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1749 '("\\<:\\sw+\\>" 0 font-lock-reference-face prepend)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1750 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1751 ;; ELisp and CLisp `&' keywords as types.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1752 '("\\<\\&\\(optional\\|rest\\|whole\\)\\>" . font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1753 ))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1754 "Gaudy level highlighting for Lisp modes.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1755
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1756 (defvar lisp-font-lock-keywords lisp-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1757 "Default expressions to highlight in Lisp modes.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1758
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1759 ;; The previous version, before replacing it with the FSF version.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1760 ;(defconst lisp-font-lock-keywords-1 (purecopy
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1761 ; '(;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1762 ; ;; highlight defining forms. This doesn't work too nicely for
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1763 ; ;; (defun (setf foo) ...) but it does work for (defvar foo) which
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1764 ; ;; is more important.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1765 ; ("^(def[-a-z]+\\s +\\([^ \t\n\)]+\\)" 1 font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1766 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1767 ; ;; highlight CL keywords (three clauses seems faster than one)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1768 ; ("\\s :\\(\\(\\sw\\|\\s_\\)+\\)\\>" . 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1769 ; ("(:\\(\\(\\sw\\|\\s_\\)+\\)\\>" . 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1770 ; ("':\\(\\(\\sw\\|\\s_\\)+\\)\\>" . 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1771 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1772 ; ;; this is highlights things like (def* (setf foo) (bar baz)), but may
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1773 ; ;; be slower (I haven't really thought about it)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1774 ;; ("^(def[-a-z]+\\s +\\(\\s(\\S)*\\s)\\|\\S(\\S *\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1775 ;; 1 font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1776 ; ))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1777 ; "For consideration as a value of `lisp-font-lock-keywords'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1778 ;This does fairly subdued highlighting.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1779 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1780 ;(defconst lisp-font-lock-keywords-2 (purecopy
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1781 ; (append lisp-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1782 ; '(;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1783 ; ;; Highlight control structures
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1784 ; ("(\\(cond\\|if\\|when\\|unless\\|[ec]?\\(type\\)?case\\)[ \t\n]" . 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1785 ; ("(\\(while\\|do\\|let\\*?\\|flet\\|labels\\|prog[nv12*]?\\)[ \t\n]" . 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1786 ; ("(\\(do\\*\\|dotimes\\|dolist\\|loop\\)[ \t\n]" . 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1787 ; ("(\\(catch\\|\\throw\\|block\\|return\\|return-from\\)[ \t\n]" . 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1788 ; ("(\\(save-restriction\\|save-window-restriction\\)[ \t\n]" . 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1789 ; ("(\\(save-excursion\\|unwind-protect\\|condition-case\\)[ \t\n]" . 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1790 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1791 ; ;; highlight function names in emacs-lisp docstrings (in the syntax
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1792 ; ;; that substitute-command-keys understands.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1793 ; ("\\\\\\\\\\[\\([^]\\\n]+\\)]" 1 font-lock-keyword-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1794 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1795 ; ;; highlight words inside `' which tend to be function names
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1796 ; ("`\\([-a-zA-Z0-9_][-a-zA-Z0-9_][-a-zA-Z0-9_.]+\\)'"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1797 ; 1 font-lock-keyword-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1798 ; )))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1799 ; "For consideration as a value of `lisp-font-lock-keywords'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1800 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1801 ;This does a lot more highlighting.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1802
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1803 (defvar scheme-font-lock-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1804 (eval-when-compile
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1805 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1806 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1807 ;; Declarations. Hannes Haug <hannes.haug@student.uni-tuebingen.de> says
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1808 ;; this works for SOS, STklos, SCOOPS, Meroon and Tiny CLOS.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1809 (list (concat "(\\(define\\("
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1810 ;; Function names.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1811 "\\(\\|-\\(generic\\(\\|-procedure\\)\\|method\\)\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1812 ;; Macro names, as variable names. A bit dubious, this.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1813 "\\(-syntax\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1814 ;; Class names.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1815 "\\(-class\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1816 "\\)\\)\\>"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1817 ;; Any whitespace and declared object.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1818 "[ \t]*(?"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1819 "\\(\\sw+\\)?")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1820 '(1 font-lock-keyword-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1821 '(8 (cond ((match-beginning 3) 'font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1822 ((match-beginning 6) 'font-lock-variable-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1823 (t 'font-lock-type-face))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1824 nil t))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1825 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1826 ;; Control structures.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1827 ;(regexp-opt '("begin" "call-with-current-continuation" "call/cc"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1828 ; "call-with-input-file" "call-with-output-file" "case" "cond"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1829 ; "do" "else" "for-each" "if" "lambda"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1830 ; "let\\*?" "let-syntax" "letrec" "letrec-syntax"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1831 ; ;; Hannes Haug <hannes.haug@student.uni-tuebingen.de> wants:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1832 ; "and" "or" "delay"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1833 ; ;; Stefan Monnier <stefan.monnier@epfl.ch> says don't bother:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1834 ; ;;"quasiquote" "quote" "unquote" "unquote-splicing"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1835 ; "map" "syntax" "syntax-rules"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1836 (cons
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1837 (concat "(\\("
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1838 "and\\|begin\\|c\\(a\\(ll\\(-with-\\(current-continuation\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1839 "input-file\\|output-file\\)\\|/cc\\)\\|se\\)\\|ond\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1840 "d\\(elay\\|o\\)\\|else\\|for-each\\|if\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1841 "l\\(ambda\\|et\\(-syntax\\|\\*?\\|rec\\(\\|-syntax\\)\\)\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1842 "map\\|or\\|syntax\\(\\|-rules\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1843 "\\)\\>") 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1844 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1845 ;; David Fox <fox@graphics.cs.nyu.edu> for SOS/STklos class specifiers.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1846 '("\\<<\\sw+>\\>" . font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1847 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1848 ;; Scheme `:' keywords as references.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1849 '("\\<:\\sw+\\>" . font-lock-reference-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1850 ))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1851 "Default expressions to highlight in Scheme modes.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1852
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1853 ;; The previous version, before replacing it with the FSF version.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1854 ;(defconst scheme-font-lock-keywords (purecopy
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1855 ; '(("(define[ \t]+(?\\([^ \t\n\)]+\\)" 1 font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1856 ; ("(\\(cond\\|lambda\\|begin\\|if\\|else\\|case\\|do\\)[ \t\n]" . 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1857 ; ("(\\(\\|letrec\\|let\\*?\\|set!\\|and\\|or\\)[ \t\n]" . 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1858 ; ("(\\(quote\\|unquote\\|quasiquote\\|unquote-splicing\\)[ \t\n]" . 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1859 ; ("(\\(syntax\\|syntax-rules\\|define-syntax\\|let-syntax\\|letrec-syntax\\)[ \t\n]" . 1)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1860 ; "Expressions to highlight in Scheme buffers.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1861
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1862 (defconst c-font-lock-keywords-1 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1863 "Subdued level highlighting for C modes.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1864
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1865 (defconst c-font-lock-keywords-2 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1866 "Medium level highlighting for C modes.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1867
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1868 (defconst c-font-lock-keywords-3 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1869 "Gaudy level highlighting for C modes.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1870
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1871 (defconst c++-font-lock-keywords-1 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1872 "Subdued level highlighting for C++ modes.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1873
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1874 (defconst c++-font-lock-keywords-2 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1875 "Medium level highlighting for C++ modes.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1876
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1877 (defconst c++-font-lock-keywords-3 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1878 "Gaudy level highlighting for C++ modes.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1879
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1880 (defun font-lock-match-c++-style-declaration-item-and-skip-to-next (limit)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1881 ;; Match, and move over, any declaration/definition item after point.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1882 ;; The expect syntax of an item is "word" or "word::word", possibly ending
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1883 ;; with optional whitespace and a "(". Everything following the item (but
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1884 ;; belonging to it) is expected to by skip-able by `forward-sexp', and items
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1885 ;; are expected to be separated with a "," or ";".
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1886 (if (looking-at "[ \t*&]*\\(\\sw+\\)\\(::\\(\\sw+\\)\\)?[ \t]*\\((\\)?")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1887 (save-match-data
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1888 (condition-case nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1889 (save-restriction
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1890 ;; Restrict to the end of line, currently guaranteed to be LIMIT.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1891 (narrow-to-region (point-min) limit)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1892 (goto-char (match-end 1))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1893 ;; Move over any item value, etc., to the next item.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1894 (while (not (looking-at "[ \t]*\\([,;]\\|$\\)"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1895 (goto-char (or (scan-sexps (point) 1) (point-max))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1896 (goto-char (match-end 0)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1897 (error t)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1898
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1899 (let ((c-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1900 ; ("break" "continue" "do" "else" "for" "if" "return" "switch" "while")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1901 "break\\|continue\\|do\\|else\\|for\\|if\\|return\\|switch\\|while")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1902 (c-type-types
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1903 ; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1904 ; "signed" "unsigned" "short" "long" "int" "char" "float" "double"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1905 ; "void" "volatile" "const")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1906 (concat "auto\\|c\\(har\\|onst\\)\\|double\\|e\\(num\\|xtern\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1907 "float\\|int\\|long\\|register\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1908 "s\\(hort\\|igned\\|t\\(atic\\|ruct\\)\\)\\|typedef\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1909 "un\\(ion\\|signed\\)\\|vo\\(id\\|latile\\)")) ; 6 ()s deep.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1910 (c++-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1911 ; ("break" "continue" "do" "else" "for" "if" "return" "switch" "while"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1912 ; "asm" "catch" "delete" "new" "operator" "sizeof" "this" "throw" "try"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1913 ; "protected" "private" "public")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1914 (concat "asm\\|break\\|c\\(atch\\|ontinue\\)\\|d\\(elete\\|o\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1915 "else\\|for\\|if\\|new\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1916 "p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\|return\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1917 "s\\(izeof\\|witch\\)\\|t\\(h\\(is\\|row\\)\\|ry\\)\\|while"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1918 (c++-type-types
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1919 ; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1920 ; "signed" "unsigned" "short" "long" "int" "char" "float" "double"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1921 ; "void" "volatile" "const" "class" "inline" "friend" "bool"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1922 ; "virtual" "complex" "template")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1923 (concat "auto\\|bool\\|c\\(har\\|lass\\|o\\(mplex\\|nst\\)\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1924 "double\\|e\\(num\\|xtern\\)\\|f\\(loat\\|riend\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1925 "in\\(line\\|t\\)\\|long\\|register\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1926 "s\\(hort\\|igned\\|t\\(atic\\|ruct\\)\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1927 "t\\(emplate\\|ypedef\\)\\|un\\(ion\\|signed\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1928 "v\\(irtual\\|o\\(id\\|latile\\)\\)")) ; 11 ()s deep.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1929 (ctoken "\\(\\sw\\|\\s_\\|[:~*&]\\)+")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1930 )
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1931 (setq c-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1932 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1933 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1934 ;; These are all anchored at the beginning of line for speed.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1935 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1936 ;; Fontify function name definitions (GNU style; without type on line).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1937
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1938 ;; In FSF this has the simpler definition of "\\sw+" for ctoken.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1939 ;; I'm not sure if ours is more correct.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1940 ;; This is a subset of the next rule, and is slower when present. --dmoore
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1941 ;; (list (concat "^\\(" ctoken "\\)[ \t]*(") 1 'font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1942 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1943 ;; fontify the names of functions being defined.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1944 ;; FSF doesn't have this but I think it should be fast for us because
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1945 ;; our regexp routines are more intelligent than FSF's about handling
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1946 ;; anchored-at-newline. (When I added this hack in regex.c, it halved
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1947 ;; the time to do the regexp phase of font-lock for a C file!) Not
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1948 ;; including this discriminates against those who don't follow the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1949 ;; GNU coding style. --ben
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1950 ;; x?x?x?y?z should always be: (x(xx?)?)?y?z --dmoore
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1951 (list (concat
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1952 "^\\("
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1953 "\\(" ctoken "[ \t]+\\)" ; type specs; there can be no
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1954 "\\("
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1955 "\\(" ctoken "[ \t]+\\)" ; more than 3 tokens, right?
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1956 "\\(" ctoken "[ \t]+\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1957 "?\\)?\\)?"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1958 "\\([*&]+[ \t]*\\)?" ; pointer
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1959 "\\(" ctoken "\\)[ \t]*(") ; name
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1960 10 'font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1961 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1962 ;; This is faster but not by much. I don't see why not.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1963 ;(list (concat "^\\(" ctoken "\\)[ \t]*(") 1 'font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1964 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1965 ;; Added next two; they're both jolly-good fastmatch candidates so
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1966 ;; should be fast. --ben
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1967 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1968 ;; Fontify structure names (in structure definition form).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1969 (list (concat "^\\(typedef[ \t]+struct\\|struct\\|static[ \t]+struct\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1970 "[ \t]+\\(" ctoken "\\)[ \t]*\\(\{\\|$\\)")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1971 2 'font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1972 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1973 ;; Fontify case clauses. This is fast because its anchored on the left.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1974 '("case[ \t]+\\(\\(\\sw\\|\\s_\\)+\\)[ \t]+:". 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1975 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1976 '("\\<\\(default\\):". 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1977 ;; Fontify filenames in #include <...> preprocessor directives as strings.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1978 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1979 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1980 ;; Fontify function macro names.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1981 '("^#[ \t]*define[ \t]+\\(\\(\\sw+\\)(\\)" 2 font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1982 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1983 ;; Fontify symbol names in #if ... defined preprocessor directives.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1984 '("^#[ \t]*if\\>"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1985 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1986 (1 font-lock-preprocessor-face) (2 font-lock-variable-name-face nil t)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1987 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1988 ;; Fontify symbol names in #elif ... defined preprocessor directives.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1989 '("^#[ \t]*elif\\>"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1990 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1991 (1 font-lock-preprocessor-face) (2 font-lock-variable-name-face nil t)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1992 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1993 ;; Fontify otherwise as symbol names, and the preprocessor directive names.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1994 '("^\\(#[ \t]*[a-z]+\\)\\>[ \t]*\\(\\sw+\\)?"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1995 (1 font-lock-preprocessor-face) (2 font-lock-variable-name-face nil t))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1996 ))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1997
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1998 (setq c-font-lock-keywords-2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1999 (append c-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2000 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2001 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2002 ;; Simple regexps for speed.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2003 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2004 ;; Fontify all type specifiers.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2005 (cons (concat "\\<\\(" c-type-types "\\)\\>") 'font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2006 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2007 ;; Fontify all builtin keywords (except case, default and goto; see below).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2008 (cons (concat "\\<\\(" c-keywords "\\)\\>") 'font-lock-keyword-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2009 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2010 ;; Fontify case/goto keywords and targets, and case default/goto tags.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2011 '("\\<\\(case\\|goto\\)\\>[ \t]*\\([^ \t\n:;]+\\)?"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2012 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2013 '("^[ \t]*\\(\\sw+\\)[ \t]*:" 1 font-lock-reference-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2014 )))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2015
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2016 (setq c-font-lock-keywords-3
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2017 (append c-font-lock-keywords-2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2018 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2019 ;; More complicated regexps for more complete highlighting for types.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2020 ;; We still have to fontify type specifiers individually, as C is so hairy.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2021 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2022 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2023 ;; Fontify all storage classes and type specifiers, plus their items.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2024 (list (concat "\\<\\(" c-type-types "\\)\\>"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2025 "\\([ \t*&]+\\sw+\\>\\)*")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2026 ;; Fontify each declaration item.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2027 '(font-lock-match-c++-style-declaration-item-and-skip-to-next
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2028 ;; Start with point after all type specifiers.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2029 (goto-char (or (match-beginning 8) (match-end 1)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2030 ;; Finish with point after first type specifier.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2031 (goto-char (match-end 1))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2032 ;; Fontify as a variable or function name.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2033 (1 (if (match-beginning 4)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2034 font-lock-function-name-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2035 font-lock-variable-name-face))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2036 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2037 ;; Fontify structures, or typedef names, plus their items.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2038 '("\\(}\\)[ \t*]*\\sw"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2039 (font-lock-match-c++-style-declaration-item-and-skip-to-next
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2040 (goto-char (match-end 1)) nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2041 (1 (if (match-beginning 4)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2042 font-lock-function-name-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2043 font-lock-variable-name-face))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2044 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2045 ;; Fontify anything at beginning of line as a declaration or definition.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2046 '("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2047 (1 font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2048 (font-lock-match-c++-style-declaration-item-and-skip-to-next
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2049 (goto-char (or (match-beginning 2) (match-end 1))) nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2050 (1 (if (match-beginning 4)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2051 font-lock-function-name-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2052 font-lock-variable-name-face))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2053 )))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2054
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2055 (setq c++-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2056 (append
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2057 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2058 ;; The list `c-font-lock-keywords-1' less that for function names.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2059 ;; the simple function form regexp has been removed. --dmoore
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2060 ;;(cdr c-font-lock-keywords-1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2061 c-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2062 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2063 ;; Fontify function name definitions, possibly incorporating class name.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2064 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2065 '("^\\(\\sw+\\)\\(::\\(\\sw+\\)\\)?[ \t]*("
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2066 (1 (if (match-beginning 2)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2067 font-lock-type-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2068 font-lock-function-name-face))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2069 (3 (if (match-beginning 2) font-lock-function-name-face) nil t))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2070 )))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2071
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2072 (setq c++-font-lock-keywords-2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2073 (append c++-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2074 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2075 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2076 ;; The list `c-font-lock-keywords-2' for C++ plus operator overloading.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2077 (cons (concat "\\<\\(" c++-type-types "\\)\\>") 'font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2078 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2079 ;; Fontify operator function name overloading.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2080 '("\\<\\(operator\\)\\>[ \t]*\\([][)(><!=+-][][)(><!=+-]?\\)?"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2081 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2082 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2083 ;; Fontify case/goto keywords and targets, and case default/goto tags.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2084 '("\\<\\(case\\|goto\\)\\>[ \t]*\\([^ \t\n:;]+\\)?"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2085 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2086 '("^[ \t]*\\(\\sw+\\)[ \t]*:[^:]" 1 font-lock-reference-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2087 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2088 ;; Fontify other builtin keywords.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2089 (cons (concat "\\<\\(" c++-keywords "\\)\\>") 'font-lock-keyword-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2090 )))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2091
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2092 (setq c++-font-lock-keywords-3
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2093 (append c++-font-lock-keywords-2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2094 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2095 ;; More complicated regexps for more complete highlighting for types.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2096 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2097 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2098 ;; Fontify all storage classes and type specifiers, plus their items.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2099 (list (concat "\\<\\(" c++-type-types "\\)\\>"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2100 "\\([ \t*&]+\\sw+\\>\\)*")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2101 ;; Fontify each declaration item.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2102 '(font-lock-match-c++-style-declaration-item-and-skip-to-next
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2103 ;; Start with point after all type specifiers.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2104 (goto-char (or (match-beginning 13) (match-end 1)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2105 ;; Finish with point after first type specifier.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2106 (goto-char (match-end 1))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2107 ;; Fontify as a variable or function name.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2108 (1 (cond ((match-beginning 2) 'font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2109 ((match-beginning 4) 'font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2110 (t 'font-lock-variable-name-face)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2111 (3 (if (match-beginning 4)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2112 'font-lock-function-name-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2113 'font-lock-variable-name-face) nil t)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2114 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2115 ;; Fontify structures, or typedef names, plus their items.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2116 '("\\(}\\)[ \t*]*\\sw"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2117 (font-lock-match-c++-style-declaration-item-and-skip-to-next
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2118 (goto-char (match-end 1)) nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2119 (1 (if (match-beginning 4)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2120 font-lock-function-name-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2121 font-lock-variable-name-face))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2122 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2123 ;; Fontify anything at beginning of line as a declaration or definition.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2124 '("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2125 (1 font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2126 (font-lock-match-c++-style-declaration-item-and-skip-to-next
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2127 (goto-char (or (match-beginning 2) (match-end 1))) nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2128 (1 (cond ((match-beginning 2) 'font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2129 ((match-beginning 4) 'font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2130 (t 'font-lock-variable-name-face)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2131 (3 (if (match-beginning 4)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2132 'font-lock-function-name-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2133 'font-lock-variable-name-face) nil t)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2134 )))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2135 )
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2136
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2137 (defvar c-font-lock-keywords c-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2138 "Default expressions to highlight in C mode.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2139
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2140 (defvar c++-font-lock-keywords c++-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2141 "Default expressions to highlight in C++ mode.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2142
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2143 ;; The previous version, before replacing it with the FSF version.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2144 ;(defconst c-font-lock-keywords-1 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2145 ; "For consideration as a value of `c-font-lock-keywords'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2146 ;This does fairly subdued highlighting.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2147 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2148 ;(defconst c-font-lock-keywords-2 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2149 ; "For consideration as a value of `c-font-lock-keywords'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2150 ;This does a lot more highlighting.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2151 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2152 ;(let ((storage "auto\\|extern\\|register\\|static\\|volatile")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2153 ; (prefixes "unsigned\\|short\\|long\\|const")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2154 ; (types (concat "int\\|long\\|char\\|float\\|double\\|void\\|struct\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2155 ; "union\\|enum\\|typedef"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2156 ; (ctoken "\\(\\sw\\|\\s_\\|[:~*&]\\)+")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2157 ; )
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2158 ; (setq c-font-lock-keywords-1 (purecopy
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2159 ; (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2160 ; ;; fontify preprocessor directives.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2161 ; '("^#[ \t]*[a-z]+" . font-lock-preprocessor-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2162 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2163 ; ;; fontify names being defined.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2164 ; '("^#[ \t]*\\(define\\|undef\\)[ \t]+\\(\\(\\sw\\|\\s_\\)+\\)" 2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2165 ; font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2166 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2167 ; ;; fontify other preprocessor lines.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2168 ; '("^#[ \t]*\\(if\\|ifn?def\\|elif\\)[ \t]+\\([^\n]+\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2169 ; 2 font-lock-function-name-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2170 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2171 ; ;; fontify the filename in #include <...>
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2172 ; ;; don't need to do this for #include "..." because those were
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2173 ; ;; already fontified as strings by the syntactic pass.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2174 ; ;; (Changed to not include the <> in the face, since "" aren't.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2175 ; '("^#[ \t]*include[ \t]+<\\([^>\"\n]+\\)>" 1 font-lock-string-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2176 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2177 ; ;; fontify the names of functions being defined.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2178 ; ;; I think this should be fast because it's anchored at bol, but it's not.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2179 ; (list (concat
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2180 ; "^\\(" ctoken "[ \t]+\\)?" ; type specs; there can be no
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2181 ; "\\(" ctoken "[ \t]+\\)?" ; more than 3 tokens, right?
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2182 ; "\\(" ctoken "[ \t]+\\)?"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2183 ; "\\([*&]+[ \t]*\\)?" ; pointer
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2184 ; "\\(" ctoken "\\)[ \t]*(") ; name
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2185 ; 8 'font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2186 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2187 ; ;; This is faster but not by much. I don't see why not.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2188 ;; (list (concat "^\\(" ctoken "\\)[ \t]*(") 1 'font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2189 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2190 ; ;; Fontify structure names (in structure definition form).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2191 ; (list (concat "^\\(typedef[ \t]+struct\\|struct\\|static[ \t]+struct\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2192 ; "[ \t]+\\(" ctoken "\\)[ \t]*\\(\{\\|$\\)")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2193 ; 2 'font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2194 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2195 ; ;; Fontify case clauses. This is fast because its anchored on the left.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2196 ; '("case[ \t]+\\(\\(\\sw\\|\\s_\\)+\\):". 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2197 ; '("\\<\\(default\\):". 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2198 ; )))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2199 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2200 ; (setq c-font-lock-keywords-2 (purecopy
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2201 ; (append c-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2202 ; (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2203 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2204 ; ;; fontify all storage classes and type specifiers
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2205 ; ;; types should be surrounded by non alphanumerics (Raymond Toy)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2206 ; (cons (concat "\\<\\(" storage "\\)\\>") 'font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2207 ; (list (concat "\\([^a-zA-Z0-9_]\\|^\\)\\("
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2208 ; types
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2209 ; "\\)\\([^a-zA-Z0-9_]\\|$\\)")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2210 ; 2 'font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2211 ; ;; fontify the prefixes now. The types should have been fontified
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2212 ; ;; previously.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2213 ; (list (concat "\\<\\(" prefixes "\\)[ \t]+\\(" types "\\)\\>")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2214 ; 1 'font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2215 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2216 ; ;; fontify all builtin tokens
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2217 ; (cons (concat
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2218 ; "[ \t]\\("
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2219 ; (mapconcat 'identity
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2220 ; '("for" "while" "do" "return" "goto" "case" "break" "switch"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2221 ; "if" "then" "else if" "else" "return" "continue" "default"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2222 ; )
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2223 ; "\\|")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2224 ; "\\)[ \t\n(){};,]")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2225 ; 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2226 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2227 ; ;; fontify case targets and goto-tags. This is slow because the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2228 ; ;; expression is anchored on the right.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2229 ; "\\(\\(\\sw\\|\\s_\\)+\\):"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2230 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2231 ; ;; Fontify variables declared with structures, or typedef names.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2232 ; '("}[ \t*]*\\(\\(\\sw\\|\\s_\\)+\\)[ \t]*[,;]"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2233 ; 1 font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2234 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2235 ; ;; Fontify global variables without a type.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2236 ;; '("^\\([_a-zA-Z0-9:~*]+\\)[ \t]*[[;={]" 1 font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2237 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2238 ; ))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2239 ; )
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2240 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2241 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2242 ;;; default to the gaudier variety?
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2243 ;;(defconst c-font-lock-keywords c-font-lock-keywords-2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2244 ;; "Additional expressions to highlight in C mode.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2245 ;(defconst c-font-lock-keywords c-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2246 ; "Additional expressions to highlight in C mode.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2247 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2248 ;(defconst c++-font-lock-keywords-1 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2249 ; "For consideration as a value of `c++-font-lock-keywords'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2250 ;This does fairly subdued highlighting.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2251 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2252 ;(defconst c++-font-lock-keywords-2 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2253 ; "For consideration as a value of `c++-font-lock-keywords'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2254 ;This does a lot more highlighting.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2255 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2256 ;(let ((ctoken "\\(\\sw\\|\\s_\\|[:~*&]\\)+")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2257 ; (c++-types (concat "complex\\|public\\|private\\|protected\\|virtual\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2258 ; "friend\\|inline"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2259 ; c++-font-lock-keywords-internal-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2260 ; c++-font-lock-keywords-internal-2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2261 ; )
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2262 ; (setq c++-font-lock-keywords-internal-1 (purecopy
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2263 ; (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2264 ; ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2265 ; ;; fontify friend operator functions
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2266 ; '("^\\(operator[^(]*\\)(" 1 font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2267 ; '("^\\(operator[ \\t]*([ \\t]*)[^(]*\\)(" 1 font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2268 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2269 ; ;; fontify the class names only in the definition
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2270 ; (list (concat "^class[ \t]+" ctoken "[ \t\n{: ;]") 1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2271 ; 'font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2272 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2273 ; (list (concat
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2274 ; "^\\(" ctoken "[ \t]+\\)?" ; type specs; there can be no
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2275 ; "\\(" ctoken "[ \t]+\\)?" ; more than 3 tokens, right?
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2276 ; "\\(" ctoken "[ \t]+\\)?"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2277 ; "\\(\\*+[ \t]*\\)?" ; pointer
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2278 ; "\\(" ctoken "\\(::\\)?~?\\(\\(operator[ \t]*[^ \ta-zA-Z]+\\)\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2279 ; ctoken "\\)\\)[ \t]*(") ; name
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2280 ; 8 'font-lock-function-name-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2281 ; )))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2282 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2283 ; (setq c++-font-lock-keywords-internal-2 (purecopy
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2284 ; (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2285 ; ;; fontify extra c++ storage classes and type specifiers
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2286 ; (cons (concat "\\<\\(" c++-types "\\)\\>") 'font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2287 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2288 ; ;;special check for class
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2289 ; '("^\\(\\<\\|template[ \t]+<[ \t]*\\)\\(class\\)[ \t\n]+" 2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2290 ; font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2291 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2292 ; ;; special handling of template
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2293 ; "^\\(template\\)\\>"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2294 ; ;; fontify extra c++ builtin tokens
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2295 ; (cons (concat
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2296 ; "[ \t]\\("
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2297 ; (mapconcat 'identity
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2298 ; '("asm" "catch" "throw" "try" "delete" "new" "operator"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2299 ; "sizeof" "this"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2300 ; )
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2301 ; "\\|")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2302 ; "\\)[ \t\n(){};,]")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2303 ; 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2304 ; )))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2305 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2306 ; (setq c++-font-lock-keywords-1 (purecopy
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2307 ; (append c-font-lock-keywords-1 c++-font-lock-keywords-internal-1)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2308 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2309 ; (setq c++-font-lock-keywords-2 (purecopy
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2310 ; (append c-font-lock-keywords-2 c++-font-lock-keywords-internal-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2311 ; c++-font-lock-keywords-internal-2)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2312 ; )
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2313 ;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2314 ;(defconst c++-font-lock-keywords c++-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2315 ; "Additional expressions to highlight in C++ mode.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2316
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2317 ;; Java support from Anders Lindgren and Bob Weiner
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2318
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2319 (defconst java-font-lock-keywords-1 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2320 "For consideration as a value of `java-font-lock-keywords'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2321 This does fairly subdued highlighting.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2322
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2323 (defconst java-font-lock-keywords-2 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2324 "For consideration as a value of `java-font-lock-keywords'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2325 This adds highlighting of types and identifier names.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2326
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2327 (defconst java-font-lock-keywords-3 nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2328 "For consideration as a value of `java-font-lock-keywords'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2329 This adds highlighting of Java documentation tags, such as @see.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2330
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2331 (defvar java-font-lock-type-regexp
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2332 (concat "\\<\\(boolean\\|byte\\|char\\|double\\|float\\|int"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2333 "\\|long\\|short\\|void\\)\\>")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2334 "Regexp which should match a primitive type.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2335
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2336 (let ((capital-letter "A-Z\300-\326\330-\337")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2337 (letter "a-zA-Z_$\300-\326\330-\366\370-\377")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2338 (digit "0-9"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2339 (defvar java-font-lock-identifier-regexp
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2340 (concat "\\<\\([" letter "][" letter digit "]*\\)\\>")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2341 "Regexp which should match all Java identifiers.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2342
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2343 (defvar java-font-lock-class-name-regexp
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2344 (concat "\\<\\([" capital-letter "][" letter digit "]*\\)\\>")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2345 "Regexp which should match a class or an interface name.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2346 The name is assumed to begin with a capital letter.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2347 )
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2348
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2349
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2350 (let ((java-modifier-regexp
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2351 (concat "\\<\\(abstract\\|const\\|final\\|native\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2352 "private\\|protected\\|public\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2353 "static\\|synchronized\\|transient\\|volatile\\)\\>")))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2354
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2355 ;; Basic font-lock support:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2356 (setq java-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2357 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2358 ;; Keywords:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2359 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2360 (concat
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2361 "\\<\\("
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2362 "break\\|byvalue\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2363 "case\\|cast\\|catch\\|class\\|continue\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2364 "do\\|else\\|extends\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2365 "finally\\|for\\|future\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2366 "generic\\|goto\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2367 "if\\|implements\\|import\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2368 "instanceof\\|interface\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2369 "new\\|package\\|return\\|switch\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2370 "throws?\\|try\\|while\\)\\>")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2371 1 'font-lock-keyword-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2372
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2373 ;; Modifiers:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2374 (list java-modifier-regexp 1 font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2375
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2376 ;; Special constants:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2377 '("\\<\\(this\\|super\\)\\>" (1 font-lock-reference-face))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2378 '("\\<\\(false\\|null\\|true\\)\\>" (1 font-lock-keyword-face))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2379
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2380 ;; Class names:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2381 (list (concat "\\<class\\>\\s *" java-font-lock-identifier-regexp)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2382 1 'font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2383
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2384 ;; Package declarations:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2385 (list (concat "\\<\\(package\\|import\\)\\>\\s *"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2386 java-font-lock-identifier-regexp)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2387 '(2 font-lock-reference-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2388 (list (concat
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2389 "\\=\\.\\(" java-font-lock-identifier-regexp "\\)")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2390 nil nil '(1 (let ((c (char-after (match-end 0))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2391 (if (and (characterp c)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2392 (= c ?.))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2393 'font-lock-reference-face
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2394 'font-lock-type-face)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2395
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2396 ;; Constructors:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2397 (list (concat
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2398 "^\\s *\\(" java-modifier-regexp "\\s +\\)*"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2399 java-font-lock-class-name-regexp "\\s *\(")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2400 (list 3
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2401 '(condition-case nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2402 (save-excursion
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2403 (goto-char (scan-sexps (- (match-end 0) 1) 1))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2404 (parse-partial-sexp (point) (point-max) nil t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2405 (and (looking-at "\\($\\|\\<throws\\>\\|{\\)")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2406 'font-lock-function-name-face))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2407 (error 'font-lock-function-name-face))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2408
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2409 ;; Methods:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2410 (list (concat "\\(" java-font-lock-type-regexp "\\|"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2411 java-font-lock-class-name-regexp "\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2412 "\\s *\\(\\[\\s *\\]\\s *\\)*"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2413 java-font-lock-identifier-regexp "\\s *\(")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2414 5
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2415 'font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2416
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2417 ;; Labels:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2418 (list ":"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2419 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2420 (concat "^\\s *" java-font-lock-identifier-regexp "\\s *:")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2421 '(beginning-of-line) '(end-of-line)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2422 '(1 font-lock-reference-face)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2423
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2424 ;; `break' and continue' destination labels:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2425 (list (concat "\\<\\(break\\|continue\\)\\>\\s *"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2426 java-font-lock-identifier-regexp)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2427 2 'font-lock-reference-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2428
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2429 ;; Case statements:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2430 ;; In Java, any constant expression is allowed.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2431 '("\\<case\\>\\s *\\(.*\\):" 1 font-lock-reference-face)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2432
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2433 ;; Types and declared variable names:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2434 (setq java-font-lock-keywords-2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2435 (append
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2436
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2437 java-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2438 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2439 ;; Keywords followed by a type:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2440 (list (concat "\\<\\(extends\\|instanceof\\|new\\)\\>\\s *"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2441 java-font-lock-identifier-regexp)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2442 '(2 (if (= (char-after (match-end 0)) ?.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2443 'font-lock-reference-face 'font-lock-type-face))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2444 (list (concat "\\=\\." java-font-lock-identifier-regexp)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2445 '(goto-char (match-end 0)) nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2446 '(1 (if (= (char-after (match-end 0)) ?.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2447 'font-lock-reference-face 'font-lock-type-face))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2448
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2449 ;; Keywords followed by a type list:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2450 (list (concat "\\<\\(implements\\|throws\\)\\>\\ s*"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2451 java-font-lock-identifier-regexp)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2452 '(2 (if (= (char-after (match-end 0)) ?.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2453 font-lock-reference-face font-lock-type-face))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2454 (list (concat "\\=\\(\\.\\|\\s *\\(,\\)\\s *\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2455 java-font-lock-identifier-regexp)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2456 '(goto-char (match-end 0)) nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2457 '(3 (if (= (char-after (match-end 0)) ?.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2458 font-lock-reference-face font-lock-type-face))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2459
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2460 ;; primitive types, can't be confused with anything else.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2461 (list java-font-lock-type-regexp
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2462 '(1 font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2463 '(font-lock-match-java-declarations
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2464 (goto-char (match-end 0))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2465 (goto-char (match-end 0))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2466 (0 font-lock-variable-name-face)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2467
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2468 ;; Declarations, class types and capitalized variables:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2469 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2470 ;; Declarations are easy to recognize. Capitalized words
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2471 ;; followed by a closing parenthesis are treated as casts if they
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2472 ;; also are followed by an expression. Expressions beginning with
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2473 ;; a unary numerical operator, e.g. +, can't be cast to an object
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2474 ;; type.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2475 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2476 ;; The path of a fully qualified type, e.g. java.lang.Foo, is
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2477 ;; fontified in the reference face.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2478 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2479 ;; An access to a static field, e.g. System.out.println, is
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2480 ;; not fontified since it can't be distinguished from the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2481 ;; usage of a capitalized variable, e.g. Foo.out.println.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2482
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2483 (list (concat java-font-lock-class-name-regexp
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2484 "\\s *\\(\\[\\s *\\]\\s *\\)*"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2485 "\\(\\<\\|$\\|)\\s *\\([\(\"]\\|\\<\\)\\)")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2486 '(1 (save-match-data
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2487 (save-excursion
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2488 (goto-char
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2489 (match-beginning 3))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2490 (if (not (looking-at "\\<instanceof\\>"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2491 'font-lock-type-face))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2492 (list (concat "\\=" java-font-lock-identifier-regexp "\\.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2493 '(progn
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2494 (goto-char (match-beginning 0))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2495 (while (or (= (preceding-char) ?.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2496 (= (char-syntax (preceding-char)) ?w))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2497 (backward-char)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2498 '(goto-char (match-end 0))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2499 '(1 font-lock-reference-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2500 '(0 nil)) ; Workaround for bug in XEmacs.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2501 '(font-lock-match-java-declarations
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2502 (goto-char (match-end 1))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2503 (goto-char (match-end 0))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2504 (1 font-lock-variable-name-face))))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2505
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2506 ;; Modifier keywords and Java doc tags
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2507 (setq java-font-lock-keywords-3
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2508 (append
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2509
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2510 '(
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2511 ;; Feature scoping:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2512 ;; These must come first or the Modifiers from keywords-1 will
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2513 ;; catch them. We don't want to use override fontification here
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2514 ;; because then these terms will be fontified within comments.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2515 ("\\<private\\>" 0 font-lock-string-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2516 ("\\<protected\\>" 0 font-lock-preprocessor-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2517 ("\\<public\\>" 0 font-lock-reference-face))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2518 java-font-lock-keywords-2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2519
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2520 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2521
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2522 ;; Java doc tags
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2523 '("@\\(author\\|exception\\|param\\|return\\|see\\|version\\)\\s "
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2524 0 font-lock-keyword-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2525
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2526 ;; Doc tag - Parameter identifiers
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2527 (list (concat "@param\\s +" java-font-lock-identifier-regexp)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2528 1 'font-lock-variable-name-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2529
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2530 ;; Doc tag - Exception types
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2531 (list (concat "@exception\\ s*"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2532 java-font-lock-identifier-regexp)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2533 '(1 (if (= (char-after (match-end 0)) ?.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2534 font-lock-reference-face font-lock-type-face) t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2535 (list (concat "\\=\\." java-font-lock-identifier-regexp)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2536 '(goto-char (match-end 0)) nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2537 '(1 (if (= (char-after (match-end 0)) ?.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2538 'font-lock-reference-face 'font-lock-type-face) t)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2539
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2540 ;; Doc tag - Cross-references, usually to methods
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2541 '("@see\\s +\\(\\S *[^][ \t\n\r\f(){},.;:]\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2542 1 font-lock-function-name-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2543
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2544 )))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2545 )
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2546
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2547 (defvar java-font-lock-keywords java-font-lock-keywords-1
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2548 "Additional expressions to highlight in Java mode.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2549
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2550 ;; Match and move over any declaration/definition item after
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2551 ;; point. Does not match items which look like a type declaration
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2552 ;; (primitive types and class names, i.e. capitalized words.)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2553 ;; Should the variable name be followed by a comma, we reposition
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2554 ;; the cursor to fontify more identifiers.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2555 (defun font-lock-match-java-declarations (limit)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2556 "Match and skip over variable definitions."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2557 (if (looking-at "\\s *\\(\\[\\s *\\]\\s *\\)*")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2558 (goto-char (match-end 0)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2559 (and
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2560 (looking-at java-font-lock-identifier-regexp)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2561 (save-match-data
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2562 (not (string-match java-font-lock-type-regexp
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2563 (buffer-substring (match-beginning 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2564 (match-end 1)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2565 (save-match-data
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2566 (save-excursion
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2567 (goto-char (match-beginning 1))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2568 (not (looking-at
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2569 (concat java-font-lock-class-name-regexp
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2570 "\\s *\\(\\[\\s *\\]\\s *\\)*\\<")))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2571 (save-match-data
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2572 (condition-case nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2573 (save-restriction
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2574 (narrow-to-region (point-min) limit)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2575 (goto-char (match-end 0))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2576 ;; Note: Both `scan-sexps' and the second goto-char can
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2577 ;; generate an error which is caught by the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2578 ;; `condition-case' expression.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2579 (while (not (looking-at "\\s *\\(\\(,\\)\\|;\\|$\\)"))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2580 (goto-char (or (scan-sexps (point) 1) (point-max))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2581 (goto-char (match-end 2))) ; non-nil
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2582 (error t)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2583
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2584
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2585 (defvar tex-font-lock-keywords
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2586 ; ;; Regexps updated with help from Ulrik Dickow <dickow@nbi.dk>.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2587 ; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2588 ; 2 font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2589 ; ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2590 ; 2 font-lock-reference-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2591 ; ;; It seems a bit dubious to use `bold' and `italic' faces since we might
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2592 ; ;; not be able to display those fonts.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2593 ; ("{\\\\bf\\([^}]+\\)}" 1 'bold keep)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2594 ; ("{\\\\\\(em\\|it\\|sl\\)\\([^}]+\\)}" 2 'italic keep)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2595 ; ("\\\\\\([a-zA-Z@]+\\|.\\)" . font-lock-keyword-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2596 ; ("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" 1 font-lock-function-name-face keep))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2597 ;; Rewritten and extended for LaTeX2e by Ulrik Dickow <dickow@nbi.dk>.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2598 '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2599 2 font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2600 ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2601 2 font-lock-reference-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2602 ("^[ \t]*\\\\def\\\\\\(\\(\\w\\|@\\)+\\)" 1 font-lock-function-name-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2603 "\\\\\\([a-zA-Z@]+\\|.\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2604 ;; It seems a bit dubious to use `bold' and `italic' faces since we might
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2605 ;; not be able to display those fonts.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2606 ;; LaTeX2e: \emph{This is emphasized}.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2607 ("\\\\emph{\\([^}]+\\)}" 1 'italic keep)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2608 ;; LaTeX2e: \textbf{This is bold}, \textit{...}, \textsl{...}
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2609 ("\\\\text\\(\\(bf\\)\\|it\\|sl\\){\\([^}]+\\)}"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2610 3 (if (match-beginning 2) 'bold 'italic) keep)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2611 ;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for good tables.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2612 ("\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2613 3 (if (match-beginning 2) 'bold 'italic) keep))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2614 "Default expressions to highlight in TeX modes.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2615
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2616 ;; The previous version, before replacing it with the FSF version.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2617 ;(defconst tex-font-lock-keywords (purecopy
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2618 ; (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2619 ; ;; Lionel Mallet: Thu Oct 14 09:41:38 1993
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2620 ; ;; I've added an exit condition to the regexp below, and the other
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2621 ; ;; regexps for the second part.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2622 ; ;; What would be useful here is something like:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2623 ; ;; ("\\(\\\\\\w+\\)\\({\\(\\w+\\)}\\)+" 1 font-lock-keyword-face t 3
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2624 ; ;; font-lock-function-name-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2625 ; '("\\(\\\\\\w+\\)\\W" 1 font-lock-keyword-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2626 ; '("\\(\\\\\\w+\\){\\([^}\n]+\\)}" 2 font-lock-function-name-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2627 ; '("\\(\\\\\\w+\\){\\(\\w+\\)}{\\(\\w+\\)}" 3
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2628 ; font-lock-function-name-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2629 ; '("\\(\\\\\\w+\\){\\(\\w+\\)}{\\(\\w+\\)}{\\(\\w+\\)}" 4
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2630 ; font-lock-function-name-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2631 ; '("{\\\\\\(em\\|tt\\)\\([^}]+\\)}" 2 font-lock-comment-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2632 ; '("{\\\\bf\\([^}]+\\)}" 1 font-lock-keyword-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2633 ; '("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)\\W" 1 font-lock-function-name-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2634 ; ;; Lionel Mallet: Thu Oct 14 09:40:10 1993
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2635 ; ;; the regexp below is useless as it is now covered by the first 2 regexps
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2636 ; ;; '("\\\\\\(begin\\|end\\){\\([a-zA-Z0-9\\*]+\\)}"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2637 ; ;; 2 font-lock-function-name-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2638 ; '("[^\\\\]\\$\\([^$]*\\)\\$" 1 font-lock-string-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2639 ;; '("\\$\\([^$]*\\)\\$" 1 font-lock-string-face t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2640 ; ))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2641 ; "Additional expressions to highlight in TeX mode.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2642
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2643 (defconst ksh-font-lock-keywords (purecopy
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2644 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2645 '("\\(^\\|[^\$\\\]\\)#.*" . font-lock-comment-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2646 '("\\<\\(if\\|then\\|else\\|elif\\|fi\\|case\\|esac\\|for\\|do\\|done\\|foreach\\|in\\|end\\|select\\|while\\|repeat\\|time\\|function\\|until\\|exec\\|command\\|coproc\\|noglob\\|nohup\\|nocorrect\\|source\\|autoload\\|alias\\|unalias\\|export\\|set\\|echo\\|eval\\|cd\\|log\\|compctl\\)\\>" . font-lock-keyword-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2647 '("\\<\\[\\[.*\\]\\]\\>" . font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2648 '("\$\(.*\)" . font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2649 ))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2650 "Additional expressions to highlight in ksh-mode.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2651
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2652 (defconst sh-font-lock-keywords (purecopy
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2653 (list
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2654 '("\\(^\\|[^\$\\\]\\)#.*" . font-lock-comment-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2655 '("\\<\\(if\\|then\\|else\\|elif\\|fi\\|case\\|esac\\|for\\|do\\|done\\|in\\|while\\|exec\\|export\\|set\\|echo\\|eval\\|cd\\)\\>" . font-lock-keyword-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2656 '("\\[.*\\]" . font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2657 '("`.*`" . font-lock-type-face)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2658 ))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2659 "Additional expressions to highlight in sh-mode.")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2660
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2661
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2662 ;; Install ourselves:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2663
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2664 (add-hook 'find-file-hooks 'font-lock-set-defaults t)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2665
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2666 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2667 (add-minor-mode 'font-lock-mode " Font")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2668
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2669 ;; Provide ourselves:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2670
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2671 (provide 'font-lock)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2672
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2673 ;;; font-lock.el ends here