annotate lisp/font-lock.el @ 5470:0af042a0c116

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