Mercurial > emacs
annotate lisp/font-lock.el @ 7300:cc7cd83ccf3f
Update copyright.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 03 May 1994 23:47:06 +0000 |
parents | 4fd40bd394fe |
children | 621c162a80db |
rev | line source |
---|---|
4053 | 1 ;; Electric Font Lock Mode |
7298 | 2 ;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. |
4053 | 3 |
4 ;; Author: jwz, then rms | |
5 ;; Maintainer: FSF | |
6 ;; Keywords: languages, faces | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; Font-lock-mode is a minor mode that causes your comments to be | |
28 ;; displayed in one face, strings in another, reserved words in another, | |
29 ;; documentation strings in another, and so on. | |
30 ;; | |
31 ;; Comments will be displayed in `font-lock-comment-face'. | |
32 ;; Strings will be displayed in `font-lock-string-face'. | |
33 ;; Doc strings will be displayed in `font-lock-doc-string-face'. | |
34 ;; Function and variable names (in their defining forms) will be | |
35 ;; displayed in `font-lock-function-name-face'. | |
36 ;; Reserved words will be displayed in `font-lock-keyword-face'. | |
37 ;; | |
38 ;; To make the text you type be fontified, use M-x font-lock-mode. | |
39 ;; When this minor mode is on, the fonts of the current line are | |
40 ;; updated with every insertion or deletion. | |
41 ;; | |
42 ;; To define new reserved words or other patterns to highlight, use | |
43 ;; the `font-lock-keywords' variable. This should be mode-local. | |
44 ;; | |
45 ;; To turn this on automatically, add this to your .emacs file: | |
46 ;; | |
47 ;; (setq emacs-lisp-mode-hook '(lambda () (font-lock-mode 1))) | |
48 ;; | |
49 ;; On a Sparc2, the initial fontification takes about 12 seconds for a 120k | |
50 ;; file of C code, using the default configuration. You can speed this up | |
51 ;; substantially by removing some of the patterns that are highlighted by | |
52 ;; default. Fontifying Lisp code is significantly faster, because Lisp has a | |
53 ;; more regular syntax than C, so the expressions don't have to be as hairy. | |
54 | |
55 ;;; Code: | |
56 | |
6578
de72ddd5a3c0
Check for existence of windowing system.
Karl Heuer <kwzh@gnu.org>
parents:
6219
diff
changeset
|
57 (or window-system |
de72ddd5a3c0
Check for existence of windowing system.
Karl Heuer <kwzh@gnu.org>
parents:
6219
diff
changeset
|
58 (error "Can't fontify on an ASCII terminal")) |
de72ddd5a3c0
Check for existence of windowing system.
Karl Heuer <kwzh@gnu.org>
parents:
6219
diff
changeset
|
59 |
4053 | 60 (or (internal-find-face 'underline) |
61 (copy-face 'default 'underline)) | |
62 (set-face-underline-p 'underline t) | |
63 | |
64 (defvar font-lock-comment-face | |
65 'italic | |
66 "Face to use for comments.") | |
67 | |
68 (defvar font-lock-doc-string-face | |
69 'italic | |
70 "Face to use for documentation strings.") | |
71 | |
72 (defvar font-lock-string-face | |
73 'underline | |
74 "Face to use for string constants.") | |
75 | |
4219
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
76 (defvar font-lock-function-name-face |
4053 | 77 'bold-italic |
78 "Face to use for function names.") | |
79 | |
80 (defvar font-lock-keyword-face | |
81 'bold | |
82 "Face to use for keywords.") | |
83 | |
84 (defvar font-lock-type-face | |
85 'italic | |
86 "Face to use for data types.") | |
87 | |
88 (make-variable-buffer-local 'font-lock-keywords) | |
89 (defvar font-lock-keywords nil | |
90 "*The keywords to highlight. | |
91 If this is a list, then elements may be of the forms: | |
92 | |
4727
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
93 \"string\" ; A regexp to highlight in the |
4053 | 94 ; `font-lock-keyword-face'. |
4727
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
95 (\"string\" . N) ; Highlight subexpression N of the regexp. |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
96 (\"string\" . face-name) ; Use the named face |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
97 (\"string\" N face-name) ; Both of the above |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
98 (\"string\" N face-name t) ; This allows highlighting to override |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
99 ; already-highlighted regions. |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
100 (\"string\" N face-name keep) ; This allows highlighting to occur |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
101 ; even if some parts of what STRING matches |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
102 ; are already highlighted--but does not alter |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
103 ; the existing highlighting of those parts. |
4053 | 104 |
105 These regular expressions should not match text which spans lines. | |
106 While \\[font-lock-fontify-buffer] handles multi-line patterns correctly, | |
107 updating when you edit the buffer does not, | |
108 since it considers text one line at a time. | |
109 | |
110 Be careful composing regexps for this list; the wrong pattern can dramatically | |
111 slow things down!") | |
112 | |
113 (defvar font-lock-keywords-case-fold-search nil | |
114 "*Non-nil means the patterns in `font-lock-keywords' are case-insensitive.") | |
115 | |
116 (defvar font-lock-verbose t | |
117 "*Non-nil means `font-lock-fontify-buffer' should print status messages.") | |
118 | |
4054 | 119 ;;;###autoload |
4053 | 120 (defvar font-lock-mode-hook nil |
121 "Function or functions to run on entry to Font Lock mode.") | |
122 | |
123 ;;; These variables record, for each buffer, | |
124 ;;; the parse state at a particular position, always the start of a line. | |
125 ;;; This is used to make font-lock-fontify-region faster. | |
126 (defvar font-lock-cache-position nil) | |
127 (defvar font-lock-cache-state nil) | |
128 (make-variable-buffer-local 'font-lock-cache-position) | |
129 (make-variable-buffer-local 'font-lock-cache-state) | |
130 | |
131 (defun font-lock-fontify-region (start end) | |
132 "Put proper face on each string and comment between START and END." | |
133 (save-excursion | |
134 (goto-char start) | |
135 (beginning-of-line) | |
136 (setq end (min end (point-max))) | |
4219
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
137 (let ((buffer-read-only nil) |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
138 state startline prev prevstate |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
139 (modified (buffer-modified-p))) |
4053 | 140 ;; Find the state at the line-beginning before START. |
141 (setq startline (point)) | |
142 (if (eq (point) font-lock-cache-position) | |
143 (setq state font-lock-cache-state) | |
144 ;; Find outermost containing sexp. | |
145 (beginning-of-defun) | |
146 ;; Find the state at STARTLINE. | |
147 (while (< (point) startline) | |
148 (setq state (parse-partial-sexp (point) startline 0))) | |
149 (setq font-lock-cache-state state | |
150 font-lock-cache-position (point))) | |
151 ;; Now find the state precisely at START. | |
152 (setq state (parse-partial-sexp (point) start nil nil state)) | |
153 ;; If the region starts inside a string, show the extent of it. | |
154 (if (nth 3 state) | |
155 (let ((beg (point))) | |
156 (while (and (re-search-forward "\\s\"" end 'move) | |
157 (nth 3 (parse-partial-sexp beg (point) | |
158 nil nil state)))) | |
159 (put-text-property beg (point) 'face font-lock-string-face) | |
160 (setq state (parse-partial-sexp beg (point) nil nil state)))) | |
161 ;; Likewise for a comment. | |
162 (if (or (nth 4 state) (nth 7 state)) | |
163 (let ((beg (point))) | |
164 (while (and (re-search-forward (if comment-end | |
165 (concat "\\s>\\|" | |
166 (regexp-quote comment-end)) | |
167 "\\s>") | |
168 end 'move) | |
169 (nth 3 (parse-partial-sexp beg (point) | |
170 nil nil state)))) | |
171 (put-text-property beg (point) 'face font-lock-comment-face) | |
172 (setq state (parse-partial-sexp beg (point) nil nil state)))) | |
173 ;; Find each interesting place between here and END. | |
174 (while (and (< (point) end) | |
175 (setq prev (point) prevstate state) | |
4459
2d8f7239f2ca
(font-lock-fontify-region): Handle comment-start-skip = nil.
Richard M. Stallman <rms@gnu.org>
parents:
4239
diff
changeset
|
176 (re-search-forward (if comment-start-skip |
2d8f7239f2ca
(font-lock-fontify-region): Handle comment-start-skip = nil.
Richard M. Stallman <rms@gnu.org>
parents:
4239
diff
changeset
|
177 (concat "\\s\"\\|" comment-start-skip) |
2d8f7239f2ca
(font-lock-fontify-region): Handle comment-start-skip = nil.
Richard M. Stallman <rms@gnu.org>
parents:
4239
diff
changeset
|
178 "\\s\"") |
2d8f7239f2ca
(font-lock-fontify-region): Handle comment-start-skip = nil.
Richard M. Stallman <rms@gnu.org>
parents:
4239
diff
changeset
|
179 end t) |
4053 | 180 ;; Clear out the fonts of what we skip over. |
181 (progn (remove-text-properties prev (point) '(face nil)) t) | |
182 ;; Verify the state at that place | |
183 ;; so we don't get fooled by \" or \;. | |
184 (setq state (parse-partial-sexp prev (point) | |
185 nil nil state))) | |
186 (let ((here (point))) | |
187 (if (or (nth 4 state) (nth 7 state)) | |
188 ;; We found a real comment start. | |
189 (let ((beg (match-beginning 0))) | |
190 (goto-char beg) | |
191 (save-restriction | |
192 (narrow-to-region (point-min) end) | |
193 (condition-case nil | |
194 (progn | |
195 (forward-comment 1) | |
196 ;; forward-comment skips all whitespace, | |
197 ;; so go back to the real end of the comment. | |
198 (skip-chars-backward " \t")) | |
199 (error (goto-char end)))) | |
200 (put-text-property beg (point) 'face font-lock-comment-face) | |
201 (setq state (parse-partial-sexp here (point) nil nil state))) | |
202 (if (nth 3 state) | |
203 (let ((beg (match-beginning 0))) | |
204 (while (and (re-search-forward "\\s\"" end 'move) | |
205 (nth 3 (parse-partial-sexp here (point) | |
206 nil nil state)))) | |
207 (put-text-property beg (point) 'face font-lock-string-face) | |
208 (setq state (parse-partial-sexp here (point) nil nil state)))) | |
209 )) | |
210 ;; Make sure PREV is non-nil after the loop | |
211 ;; only if it was set on the very last iteration. | |
212 (setq prev nil)) | |
213 (and prev | |
4219
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
214 (remove-text-properties prev end '(face nil))) |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
215 (set-buffer-modified-p modified)))) |
4053 | 216 |
217 ;; This code used to be used to show a string on reaching the end of it. | |
218 ;; It is probably not needed due to later changes to handle strings | |
219 ;; starting before the region in question. | |
220 ;; (if (and (null (nth 3 state)) | |
221 ;; (eq (char-syntax (preceding-char)) ?\") | |
222 ;; (save-excursion | |
223 ;; (nth 3 (parse-partial-sexp prev (1- (point)) | |
224 ;; nil nil prevstate)))) | |
225 ;; ;; We found the end of a string. | |
226 ;; (save-excursion | |
227 ;; (setq foo2 (point)) | |
228 ;; (let ((ept (point))) | |
229 ;; (forward-sexp -1) | |
230 ;; ;; Highlight the string when we see the end. | |
231 ;; ;; Doing it at the start leads to trouble: | |
232 ;; ;; either it fails to handle multiline strings | |
233 ;; ;; or it can run away when an unmatched " is inserted. | |
234 ;; (put-text-property (point) ept 'face | |
235 ;; (if (= (car state) 1) | |
236 ;; font-lock-doc-string-face | |
237 ;; font-lock-string-face))))) | |
238 | |
239 (defun font-lock-unfontify-region (beg end) | |
4219
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
240 (let ((modified (buffer-modified-p)) |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
241 (buffer-read-only nil)) |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
242 (remove-text-properties beg end '(face nil)) |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
243 (set-buffer-modified-p modified))) |
4053 | 244 |
245 ;; Called when any modification is made to buffer text. | |
246 (defun font-lock-after-change-function (beg end old-len) | |
247 (save-excursion | |
248 (save-match-data | |
249 (goto-char beg) | |
250 ;; Discard the cache info if text before it has changed. | |
251 (and font-lock-cache-position | |
252 (> font-lock-cache-position beg) | |
253 (setq font-lock-cache-position nil)) | |
254 ;; Rescan till end of line. yes! | |
255 (goto-char end) | |
256 (end-of-line) | |
257 (setq end (point)) | |
258 (goto-char beg) | |
259 (beginning-of-line) | |
260 (setq beg (point)) | |
4239
e8cf7a7d0102
(font-lock-after-change-function):
Richard M. Stallman <rms@gnu.org>
parents:
4219
diff
changeset
|
261 ;; First scan for strings and comments. |
e8cf7a7d0102
(font-lock-after-change-function):
Richard M. Stallman <rms@gnu.org>
parents:
4219
diff
changeset
|
262 ;; Must scan from line start in case of |
e8cf7a7d0102
(font-lock-after-change-function):
Richard M. Stallman <rms@gnu.org>
parents:
4219
diff
changeset
|
263 ;; inserting space into `intfoo () {}'. |
e8cf7a7d0102
(font-lock-after-change-function):
Richard M. Stallman <rms@gnu.org>
parents:
4219
diff
changeset
|
264 (font-lock-fontify-region beg (1+ end)) |
4053 | 265 ;; Now scan for keywords. |
266 (font-lock-hack-keywords beg end)))) | |
267 | |
268 ;;; Fontifying arbitrary patterns | |
269 | |
270 (defsubst font-lock-any-properties-p (start end) | |
4727
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
271 (or (get-text-property start 'face) |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
272 (let ((next (next-single-property-change start 'face))) |
4053 | 273 (and next (< next end))))) |
274 | |
275 (defun font-lock-hack-keywords (start end &optional loudly) | |
276 (goto-char start) | |
277 (let ((case-fold-search font-lock-keywords-case-fold-search) | |
278 (rest font-lock-keywords) | |
279 (count 0) | |
4219
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
280 (buffer-read-only nil) |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
281 (modified (buffer-modified-p)) |
4053 | 282 first str match face s e allow-overlap-p) |
283 (while rest | |
284 (setq first (car rest) rest (cdr rest)) | |
285 (goto-char start) | |
286 (cond ((consp first) | |
287 (setq str (car first)) | |
288 (cond ((consp (cdr first)) | |
289 (setq match (nth 1 first) | |
4219
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
290 face (eval (nth 2 first)) |
4053 | 291 allow-overlap-p (nth 3 first))) |
292 ((symbolp (cdr first)) | |
293 (setq match 0 allow-overlap-p nil | |
4219
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
294 face (eval (cdr first)))) |
4053 | 295 (t |
296 (setq match (cdr first) | |
297 allow-overlap-p nil | |
298 face font-lock-keyword-face)))) | |
299 (t | |
300 (setq str first match 0 allow-overlap-p nil | |
301 face font-lock-keyword-face))) | |
302 ;(message "regexp: %s" str) | |
303 (while (re-search-forward str end t) | |
304 (setq s (match-beginning match) | |
305 e (match-end match)) | |
306 (or s (error "expression did not match subexpression %d" match)) | |
307 ;; don't fontify this keyword if we're already in some other context. | |
308 (or (if allow-overlap-p nil (font-lock-any-properties-p s e)) | |
4727
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
309 (if (not (memq allow-overlap-p '(t nil))) |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
310 (save-excursion |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
311 (goto-char s) |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
312 (save-restriction |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
313 (narrow-to-region s e) |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
314 (while (not (eobp)) |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
315 (let ((next (next-single-property-change (point) 'face))) |
5056
64211dda414c
(font-lock-hack-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
4897
diff
changeset
|
316 (if (or (null next) (> next (point-max))) |
4727
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
317 (setq next (point-max))) |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
318 (if (not (get-text-property (point) 'face)) |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
319 (put-text-property (point) next 'face face)) |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
320 (goto-char next))))) |
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
321 (put-text-property s e 'face face)))) |
4053 | 322 (if loudly (message "Fontifying %s... (regexps...%s)" |
323 (buffer-name) | |
4219
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
324 (make-string (setq count (1+ count)) ?.)))) |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
325 (set-buffer-modified-p modified))) |
4053 | 326 |
327 ;; The user level functions | |
328 | |
329 (defvar font-lock-mode nil) ; for modeline | |
330 (or (assq 'font-lock-mode minor-mode-alist) | |
331 (setq minor-mode-alist | |
332 (append minor-mode-alist | |
333 '((font-lock-mode " Font"))))) | |
334 | |
335 (defvar font-lock-fontified nil) ; whether we have hacked this buffer | |
336 (put 'font-lock-fontified 'permanent-local t) | |
337 | |
338 ;;;###autoload | |
339 (defun font-lock-mode (&optional arg) | |
340 "Toggle Font Lock mode. | |
341 With arg, turn Font Lock mode on if and only if arg is positive. | |
342 | |
343 When Font Lock mode is enabled, text is fontified as you type it: | |
344 | |
345 - comments are displayed in `font-lock-comment-face'; | |
346 (That is a variable whose value should be a face name.) | |
347 - strings are displayed in `font-lock-string-face'; | |
348 - documentation strings are displayed in `font-lock-doc-string-face'; | |
349 - function and variable names in their defining forms are displayed | |
350 in `font-lock-function-name-face'; | |
351 - and certain other expressions are displayed in other faces | |
352 according to the value of the variable `font-lock-keywords'. | |
353 | |
354 When you turn Font Lock mode on/off, the buffer is fontified/defontified. | |
355 To fontify a buffer without having newly typed text become fontified, you | |
356 can use \\[font-lock-fontify-buffer]." | |
357 (interactive "P") | |
358 (let ((on-p (if (null arg) | |
359 (not font-lock-mode) | |
360 (> (prefix-numeric-value arg) 0)))) | |
361 (if (equal (buffer-name) " *Compiler Input*") ; hack for bytecomp... | |
362 (setq on-p nil)) | |
363 (or (memq after-change-function | |
364 '(nil font-lock-after-change-function)) | |
365 (error "after-change-function is %s" after-change-function)) | |
366 (set (make-local-variable 'after-change-function) | |
367 (if on-p 'font-lock-after-change-function nil)) | |
368 (set (make-local-variable 'font-lock-mode) on-p) | |
369 (cond (on-p | |
370 (font-lock-set-defaults) | |
5717
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
371 (make-local-variable 'before-revert-hook) |
5625
24f92f49a07f
(font-lock-mode): Set after-revert-hook
Richard M. Stallman <rms@gnu.org>
parents:
5360
diff
changeset
|
372 (make-local-variable 'after-revert-hook) |
5717
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
373 ;; If buffer is reverted, must clean up the state. |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
374 (add-hook 'before-revert-hook 'font-lock-revert-setup) |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
375 (add-hook 'after-revert-hook 'font-lock-revert-cleanup) |
4053 | 376 (run-hooks 'font-lock-mode-hook) |
377 (or font-lock-fontified (font-lock-fontify-buffer))) | |
378 (font-lock-fontified | |
379 (setq font-lock-fontified nil) | |
5717
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
380 (remove-hook 'before-revert-hook 'font-lock-revert-setup) |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
381 (remove-hook 'after-revert-hook 'font-lock-revert-cleanup) |
4053 | 382 (font-lock-unfontify-region (point-min) (point-max)))) |
383 (force-mode-line-update))) | |
384 | |
5717
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
385 ;; If the buffer is about to be reverted, it won't be fontified. |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
386 (defun font-lock-revert-setup () |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
387 (setq font-lock-fontified nil)) |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
388 |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
389 ;; If the buffer has just been reverted, we might not even be in font-lock |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
390 ;; mode anymore, and if we are, the buffer may or may not have already been |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
391 ;; refontified. Refontify here if it looks like we need to. |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
392 (defun font-lock-revert-cleanup () |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
393 (and font-lock-mode |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
394 (not font-lock-fontified) |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
395 (font-lock-mode 1))) |
24e1180b507d
(font-lock-mode): Use the new hooks to get proper behavior on a revert.
Karl Heuer <kwzh@gnu.org>
parents:
5625
diff
changeset
|
396 |
4053 | 397 (defun font-lock-fontify-buffer () |
398 "Fontify the current buffer the way `font-lock-mode' would: | |
399 | |
400 - comments are displayed in `font-lock-comment-face'; | |
401 - strings are displayed in `font-lock-string-face'; | |
402 - documentation strings are displayed in `font-lock-doc-string-face'; | |
403 - function and variable names in their defining forms are displayed | |
404 in `font-lock-function-name-face'; | |
405 - and certain other expressions are displayed in other faces | |
406 according to the value of the variable `font-lock-keywords'. | |
407 | |
408 This can take a while for large buffers." | |
409 (interactive) | |
410 (let ((was-on font-lock-mode) | |
411 (font-lock-verbose (or font-lock-verbose (interactive-p)))) | |
412 (if font-lock-verbose (message "Fontifying %s..." (buffer-name))) | |
413 ;; Turn it on to run hooks and get the right font-lock-keywords. | |
4897
c3db6fd69f1f
(font-lock-fontify-buffer): Don't turn
Richard M. Stallman <rms@gnu.org>
parents:
4727
diff
changeset
|
414 (or was-on (font-lock-set-defaults)) |
4053 | 415 (font-lock-unfontify-region (point-min) (point-max)) |
416 (if font-lock-verbose (message "Fontifying %s... (syntactically...)" | |
417 (buffer-name))) | |
418 ;; (buffer-syntactic-context-flush-cache) | |
419 (save-excursion | |
420 (font-lock-fontify-region (point-min) (point-max)) | |
421 (if font-lock-verbose (message "Fontifying %s... (regexps...)" | |
422 (buffer-name))) | |
423 (font-lock-hack-keywords (point-min) (point-max) font-lock-verbose)) | |
424 (set (make-local-variable 'font-lock-fontified) t) | |
425 (if font-lock-verbose (message "Fontifying %s... done." (buffer-name))) | |
426 )) | |
427 | |
428 | |
429 ;;; Various mode-specific information. | |
430 | |
431 (defun font-lock-set-defaults () | |
4727
ca337641008d
(font-lock-fontify-region): Don't add `font-lock' props.
Richard M. Stallman <rms@gnu.org>
parents:
4700
diff
changeset
|
432 "Set `font-lock-keywords' to something appropriate for this mode." |
5294
f5fdaf66b013
(font-lock-set-defaults): Do nothing if font-lock-keywords is already set.
Richard M. Stallman <rms@gnu.org>
parents:
5056
diff
changeset
|
433 (if (not font-lock-keywords) ; if not already set. |
f5fdaf66b013
(font-lock-set-defaults): Do nothing if font-lock-keywords is already set.
Richard M. Stallman <rms@gnu.org>
parents:
5056
diff
changeset
|
434 (setq font-lock-keywords |
f5fdaf66b013
(font-lock-set-defaults): Do nothing if font-lock-keywords is already set.
Richard M. Stallman <rms@gnu.org>
parents:
5056
diff
changeset
|
435 (cond ((eq major-mode 'lisp-mode) lisp-font-lock-keywords) |
f5fdaf66b013
(font-lock-set-defaults): Do nothing if font-lock-keywords is already set.
Richard M. Stallman <rms@gnu.org>
parents:
5056
diff
changeset
|
436 ((eq major-mode 'emacs-lisp-mode) lisp-font-lock-keywords) |
f5fdaf66b013
(font-lock-set-defaults): Do nothing if font-lock-keywords is already set.
Richard M. Stallman <rms@gnu.org>
parents:
5056
diff
changeset
|
437 ((eq major-mode 'c-mode) c-font-lock-keywords) |
f5fdaf66b013
(font-lock-set-defaults): Do nothing if font-lock-keywords is already set.
Richard M. Stallman <rms@gnu.org>
parents:
5056
diff
changeset
|
438 ((eq major-mode 'c++-c-mode) c-font-lock-keywords) |
f5fdaf66b013
(font-lock-set-defaults): Do nothing if font-lock-keywords is already set.
Richard M. Stallman <rms@gnu.org>
parents:
5056
diff
changeset
|
439 ((eq major-mode 'c++-mode) c++-font-lock-keywords) |
f5fdaf66b013
(font-lock-set-defaults): Do nothing if font-lock-keywords is already set.
Richard M. Stallman <rms@gnu.org>
parents:
5056
diff
changeset
|
440 ((eq major-mode 'perl-mode) perl-font-lock-keywords) |
f5fdaf66b013
(font-lock-set-defaults): Do nothing if font-lock-keywords is already set.
Richard M. Stallman <rms@gnu.org>
parents:
5056
diff
changeset
|
441 ((eq major-mode 'tex-mode) tex-font-lock-keywords) |
f5fdaf66b013
(font-lock-set-defaults): Do nothing if font-lock-keywords is already set.
Richard M. Stallman <rms@gnu.org>
parents:
5056
diff
changeset
|
442 ((eq major-mode 'texinfo-mode) texi-font-lock-keywords) |
5726
781af712e68c
(font-lock-set-defaults): Handle shell mode.
Richard M. Stallman <rms@gnu.org>
parents:
5717
diff
changeset
|
443 ((eq major-mode 'shell-mode) shell-font-lock-keywords) |
5752
412ac1a01f46
(dired-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5744
diff
changeset
|
444 ((eq major-mode 'dired-mode) dired-font-lock-keywords) |
7018
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
445 ((eq major-mode 'rmail-mode) rmail-font-lock-keywords) |
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
446 ((eq major-mode 'compilation-mode) |
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
447 compilation-mode-font-lock-keywords) |
5360
7e5fce72b793
(font-lock-set-defaults): Add missing paren.
Richard M. Stallman <rms@gnu.org>
parents:
5294
diff
changeset
|
448 (t nil))))) |
4053 | 449 |
450 (defconst lisp-font-lock-keywords-1 | |
451 '(;; | |
452 ;; highlight defining forms. This doesn't work too nicely for | |
453 ;; (defun (setf foo) ...) but it does work for (defvar foo) which | |
454 ;; is more important. | |
455 ("^(def[-a-z]+\\s +\\([^ \t\n\)]+\\)" 1 font-lock-function-name-face) | |
456 ;; | |
457 ;; highlight CL keywords | |
458 ("\\s :\\(\\(\\sw\\|\\s_\\)+\\)\\>" . 1) | |
459 ;; | |
460 ;; this is highlights things like (def* (setf foo) (bar baz)), but may | |
461 ;; be slower (I haven't really thought about it) | |
462 ; ("^(def[-a-z]+\\s +\\(\\s(\\S)*\\s)\\|\\S(\\S *\\)" | |
463 ; 1 font-lock-function-name-face) | |
464 ) | |
465 "For consideration as a value of `lisp-font-lock-keywords'. | |
466 This does fairly subdued highlighting.") | |
467 | |
468 (defconst lisp-font-lock-keywords-2 | |
469 (append | |
470 lisp-font-lock-keywords-1 | |
471 '(;; | |
472 ;; Highlight control structures | |
473 ("(\\(cond\\|if\\|when\\|unless\\|[ec]?\\(type\\)?case\\)[ \t\n]" . 1) | |
5878
044cb853edbd
(lisp-font-lock-keywords-2): Quote the * in let*.
Richard M. Stallman <rms@gnu.org>
parents:
5752
diff
changeset
|
474 ("(\\(while\\|do\\|let\\*?\\|flet\\|labels\\|prog[nv12*]?\\)[ \t\n]" . 1) |
4053 | 475 ("(\\(catch\\|\\throw\\|block\\|return\\|return-from\\)[ \t\n]" . 1) |
476 ("(\\(save-restriction\\|save-window-restriction\\)[ \t\n]" . 1) | |
477 ("(\\(save-excursion\\|unwind-protect\\|condition-case\\)[ \t\n]" . 1) | |
478 ;; | |
479 ;; highlight function names in emacs-lisp docstrings (in the syntax | |
480 ;; that substitute-command-keys understands.) | |
481 ("\\\\\\\\\\[\\([^]\\\n]+\\)]" 1 font-lock-keyword-face t) | |
482 ;; | |
483 ;; highlight words inside `' which tend to be function names | |
484 ("`\\([-a-zA-Z0-9_][-a-zA-Z0-9_][-a-zA-Z0-9_.]+\\)'" | |
485 1 font-lock-keyword-face t) | |
486 )) | |
487 "For consideration as a value of `lisp-font-lock-keywords'. | |
488 This does a lot more highlighting.") | |
489 | |
490 ;; default to the gaudier variety? | |
491 ;(defvar lisp-font-lock-keywords lisp-font-lock-keywords-2 | |
492 ; "Additional expressions to highlight in Lisp modes.") | |
493 (defvar lisp-font-lock-keywords lisp-font-lock-keywords-1 | |
494 "Additional expressions to highlight in Lisp modes.") | |
495 | |
496 | |
497 (defconst c-font-lock-keywords-1 nil | |
498 "For consideration as a value of `c-font-lock-keywords'. | |
499 This does fairly subdued highlighting.") | |
500 | |
501 (defconst c-font-lock-keywords-2 nil | |
502 "For consideration as a value of `c-font-lock-keywords'. | |
503 This does a lot more highlighting.") | |
504 | |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
505 (defconst c++-font-lock-keywords-1 nil |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
506 "For consideration as a value of `c++-font-lock-keywords'. |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
507 This does fairly subdued highlighting.") |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
508 |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
509 (defconst c++-font-lock-keywords-2 nil |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
510 "For consideration as a value of `c++-font-lock-keywords'. |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
511 This does a lot more highlighting.") |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
512 |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
513 (let* ((storage "auto\\|extern\\|register\\|static\\|typedef") |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
514 (struct "struct\\|union\\|enum") |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
515 (prefixes "signed\\|unsigned\\|short\\|long") |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
516 (types (concat prefixes "\\|int\\|char\\|float\\|double\\|void")) |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
517 (ctoken "[a-zA-Z0-9_:~*]+") |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
518 (c++-things (concat |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
519 "const\\|class\\|protected:\\|private:\\|public:\\|inline\\|" |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
520 "new\\|delete"))) |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
521 (setq c-font-lock-keywords-1 |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
522 (list |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
523 ;; fontify preprocessor directives as comments. |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
524 '("^#[ \t]*[a-z]+" . font-lock-comment-face) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
525 ;; |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
526 ;; fontify names being defined. |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
527 '("^#[ \t]*\\(define\\|undef\\)[ \t]+\\(\\(\\sw\\|\\s_\\)+\\)" 2 |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
528 font-lock-function-name-face) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
529 ;; |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
530 ;; fontify other preprocessor lines. |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
531 '("^#[ \t]*\\(if\\|elif\\|else\\|endif\\)[ \t]+\\([^\n]+\\)" |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
532 2 font-lock-function-name-face keep) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
533 '("^#[ \t]*\\(ifn?def\\)[ \t]+\\([^ \t\n]+\\)" |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
534 2 font-lock-function-name-face t) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
535 ;; |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
536 ;; fontify the filename in #include <...> |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
537 ;; don't need to do this for #include "..." because those were |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
538 ;; already fontified as strings by the syntactic pass. |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
539 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
540 ;; |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
541 ;; fontify the names of functions being defined. |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
542 (list (concat |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
543 "^\\(" ctoken "[ \t]+\\)?" ; type specs; there can be no |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
544 "\\(" ctoken "[ \t]+\\)?" ; more than 3 tokens, right? |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
545 "\\(" ctoken "[ \t]+\\)?" |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
546 "\\([*&]+[ \t]*\\)?" ; pointer |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
547 "\\(" ctoken "\\)[ \t]*(") ; name |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
548 5 'font-lock-function-name-face) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
549 ;; |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
550 ;; |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
551 ;; Fontify structure names (in structure definition form). |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
552 (list (concat "^\\(" storage "\\)?[ \t]*\\<\\(" struct "\\)" |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
553 "[ \t]+\\(" ctoken "\\)[ \t]*\\(\{\\|$\\)") |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
554 3 'font-lock-function-name-face) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
555 ;; |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
556 ;; Fontify declarations of simple identifiers (including typedefs). |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
557 ;; (Should this be in c-font-lock-keywords-2 instead?) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
558 (list (concat "^[ \t]*\\(\\(" storage "\\)[ \t]+\\)?\\(\\(\\(" prefixes |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
559 "\\)\\>[ \t]*\\)*\\(" types "\\)\\)[ \t]+\\(" ctoken |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
560 "\\)[ \t]*[=;]") |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
561 7 'font-lock-function-name-face 'keep) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
562 ;; |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
563 ;; And likewise for structs |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
564 (list (concat "^[ \t]*\\(\\(" storage "\\)[ \t]+\\)?\\(" struct |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
565 "\\)[ \t]+" ctoken "[ \t]+\\(" ctoken "\\);") |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
566 4 'font-lock-function-name-face 'keep) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
567 ;; |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
568 ;; Fontify case clauses. This is fast because its anchored on the left. |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
569 '("case[ \t]+\\(\\(\\sw\\|\\s_\\)+\\):". 1) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
570 '("\\<\\(default\\):". 1) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
571 )) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
572 |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
573 (setq c-font-lock-keywords-2 |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
574 (append c-font-lock-keywords-1 |
4053 | 575 (list |
576 ;; | |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
577 ;; fontify all storage classes and type specifiers |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
578 (cons (concat "\\<\\(" storage "\\)\\>") 'font-lock-type-face) |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
579 (cons (concat "\\<\\(" types "\\)\\>") 'font-lock-type-face) |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
580 (cons (concat "\\<\\(\\(\\(" prefixes "\\)\\>[ \t]*\\)*\\(" types |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
581 "\\)\\)\\>") |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
582 'font-lock-type-face) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
583 (list (concat "\\<\\(" struct "\\)[ \t]+" ctoken) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
584 0 'font-lock-type-face 'keep) |
4053 | 585 ;; |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
586 ;; fontify all builtin tokens |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
587 (cons (concat |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
588 "[ \t]\\(" |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
589 (mapconcat 'identity |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
590 '("for" "while" "do" "return" "goto" "case" "break" "switch" |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
591 "if" "else" "default" "continue" "default") |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
592 "\\|") |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
593 "\\)[ \t\n(){};,]") |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
594 1) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
595 ;; |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
596 ;; fontify case targets and goto-tags. This is slow because the |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
597 ;; expression is anchored on the right. |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
598 "\\(\\(\\sw\\|\\s_\\)+\\):" |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
599 ;; |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
600 ;; Fontify variables declared with structures, or typedef names. |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
601 '("}[ \t*]*\\(\\(\\sw\\|\\s_\\)+\\)[ \t]*[,;]" |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
602 1 font-lock-function-name-face) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
603 ;; |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
604 ;; Fontify global variables without a type. |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
605 ; '("^\\([_a-zA-Z0-9:~*]+\\)[ \t]*[[;={]" 1 font-lock-function-name-face) |
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
606 ))) |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
607 |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
608 (setq c++-font-lock-keywords-1 |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
609 (cons |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
610 (concat "\\(" c++-things "\\)[ \t\n]") |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
611 c-font-lock-keywords-1)) |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
612 (setq c++-font-lock-keywords-2 |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
613 (cons |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
614 (cons (concat "\\<\\(" c++-things "\\)\\>") 'font-lock-type-face) |
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
615 c-font-lock-keywords-2)) |
6093
00cee8387866
Clean up c-font-lock-keywords; now slightly more consistent about highlighting
Karl Heuer <kwzh@gnu.org>
parents:
5878
diff
changeset
|
616 ) |
4053 | 617 |
618 ; default to the gaudier variety? | |
619 (defvar c-font-lock-keywords c-font-lock-keywords-1 | |
620 "Additional expressions to highlight in C mode.") | |
621 | |
6219
d960f0463014
(c++-font-lock-keywords-1, c++-font-lock-keywords-2): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
6093
diff
changeset
|
622 (defvar c++-font-lock-keywords c++-font-lock-keywords-1 |
4053 | 623 "Additional expressions to highlight in C++ mode.") |
624 | |
625 | |
626 (defvar perl-font-lock-keywords | |
627 (list | |
4219
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
628 (cons (concat "[ \n\t{]*\\(" |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
629 (mapconcat 'identity |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
630 '("if" "until" "while" "elsif" "else" "unless" "for" |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
631 "foreach" "continue" "exit" "die" "last" "goto" "next" |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
632 "redo" "return" "local" "exec") |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
633 "\\|") |
24f3ca095be9
(perl-font-lock-keywords): Add a `(... . 1)' to the
Richard M. Stallman <rms@gnu.org>
parents:
4054
diff
changeset
|
634 "\\)[ \n\t;(]") 1) |
4053 | 635 (mapconcat 'identity |
636 '("#endif" "#else" "#ifdef" "#ifndef" "#if" "#include" | |
637 "#define" "#undef") | |
638 "\\|") | |
4239
e8cf7a7d0102
(font-lock-after-change-function):
Richard M. Stallman <rms@gnu.org>
parents:
4219
diff
changeset
|
639 '("^[ \n\t]*sub[ \t]+\\([^ \t{]+\\)[ \t]*[{]" 1 font-lock-function-name-face) |
e8cf7a7d0102
(font-lock-after-change-function):
Richard M. Stallman <rms@gnu.org>
parents:
4219
diff
changeset
|
640 '("[ \n\t{]*\\(eval\\)[ \n\t(;]" 1 font-lock-function-name-face) |
4053 | 641 '("\\(--- .* ---\\|=== .* ===\\)" . font-lock-doc-string-face) |
642 ) | |
643 "Additional expressions to highlight in Perl mode.") | |
644 | |
645 (defvar tex-font-lock-keywords | |
646 (list | |
647 '("\\(\\\\\\w+\\)" 1 font-lock-keyword-face t) | |
648 '("{\\\\em\\([^}]+\\)}" 1 font-lock-comment-face t) | |
649 '("{\\\\bf\\([^}]+\\)}" 1 font-lock-keyword-face t) | |
650 '("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" 1 font-lock-function-name-face t) | |
651 '("\\\\\\(begin\\|end\\){\\([a-zA-Z0-9\\*]+\\)}" | |
652 2 font-lock-function-name-face t) | |
653 '("[^\\\\]\\$\\([^$]*\\)\\$" 1 font-lock-string-face t) | |
654 ; '("\\$\\([^$]*\\)\\$" 1 font-lock-string-face t) | |
655 ) | |
656 "Additional expressions to highlight in TeX mode.") | |
657 | |
658 (defvar texi-font-lock-keywords | |
659 (list | |
660 "@\\(@\\|[^}\t \n{]+\\)" ;commands | |
661 '("^\\(@c\\|@comment\\)[ \t].*$" . font-lock-comment-face) ;comments | |
662 '("^\\(*.*\\)[\t ]*$" 1 font-lock-function-name-face t) ;menu items | |
663 '("@\\(emph\\|strong\\|b\\|i\\){\\([^}]+\\)" 2 font-lock-comment-face t) | |
664 '("@\\(file\\|kbd\\|key\\){\\([^}]+\\)" 2 font-lock-string-face t) | |
665 '("@\\(samp\\|code\\|var\\){\\([^}]+\\)" 2 font-lock-function-name-face t) | |
666 '("@\\(xref\\|pxref\\){\\([^}]+\\)" 2 font-lock-keyword-face t) | |
667 '("@end *\\([a-zA-Z0-9]+\\)[ \t]*$" 1 font-lock-function-name-face t) | |
668 '("@item \\(.*\\)$" 1 font-lock-function-name-face t) | |
669 '("\\$\\([^$]*\\)\\$" 1 font-lock-string-face t) | |
670 ) | |
671 "Additional expressions to highlight in TeXinfo mode.") | |
672 | |
5726
781af712e68c
(font-lock-set-defaults): Handle shell mode.
Richard M. Stallman <rms@gnu.org>
parents:
5717
diff
changeset
|
673 (defvar shell-font-lock-keywords |
781af712e68c
(font-lock-set-defaults): Handle shell mode.
Richard M. Stallman <rms@gnu.org>
parents:
5717
diff
changeset
|
674 (list (cons shell-prompt-pattern 'font-lock-keyword-face) |
781af712e68c
(font-lock-set-defaults): Handle shell mode.
Richard M. Stallman <rms@gnu.org>
parents:
5717
diff
changeset
|
675 (list (concat shell-prompt-pattern "\\([^ \t]+\\)") |
781af712e68c
(font-lock-set-defaults): Handle shell mode.
Richard M. Stallman <rms@gnu.org>
parents:
5717
diff
changeset
|
676 1 'font-lock-function-name-face) |
781af712e68c
(font-lock-set-defaults): Handle shell mode.
Richard M. Stallman <rms@gnu.org>
parents:
5717
diff
changeset
|
677 '("[ \t]\\([+-][^ \t\n]+\\)" 1 font-lock-comment-face) |
781af712e68c
(font-lock-set-defaults): Handle shell mode.
Richard M. Stallman <rms@gnu.org>
parents:
5717
diff
changeset
|
678 '("^[^ \t]+:.*$" . font-lock-string-face) |
781af712e68c
(font-lock-set-defaults): Handle shell mode.
Richard M. Stallman <rms@gnu.org>
parents:
5717
diff
changeset
|
679 '("^\\[[1-9][0-9]*\\]" . font-lock-string-face)) |
5744
c870cde64544
(shell-font-lock-keywords): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
5726
diff
changeset
|
680 "Additional expressions to highlight in Shell mode.") |
5726
781af712e68c
(font-lock-set-defaults): Handle shell mode.
Richard M. Stallman <rms@gnu.org>
parents:
5717
diff
changeset
|
681 |
5752
412ac1a01f46
(dired-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5744
diff
changeset
|
682 (defvar dired-font-lock-keywords |
412ac1a01f46
(dired-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5744
diff
changeset
|
683 '(;; Put directory headers in italics. |
412ac1a01f46
(dired-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5744
diff
changeset
|
684 ("^ \\(/.+\\)$" 1 font-lock-type-face) |
412ac1a01f46
(dired-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5744
diff
changeset
|
685 ;; Put symlinks in bold italics. |
412ac1a01f46
(dired-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5744
diff
changeset
|
686 ("\\([^ ]+\\) -> [^ ]+$" . font-lock-function-name-face) |
412ac1a01f46
(dired-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5744
diff
changeset
|
687 ;; Put marks in bold. |
412ac1a01f46
(dired-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5744
diff
changeset
|
688 ("^\\([^ ]\\).*$" 1 font-lock-keyword-face t) |
412ac1a01f46
(dired-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5744
diff
changeset
|
689 ;; Put files that are subdirectories in bold. |
412ac1a01f46
(dired-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5744
diff
changeset
|
690 ("^..d.* \\([^ ]+\\)$" 1 font-lock-keyword-face)) |
412ac1a01f46
(dired-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5744
diff
changeset
|
691 "Additional expressions to highlight in Dired mode.") |
412ac1a01f46
(dired-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
5744
diff
changeset
|
692 |
7018
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
693 (defvar rmail-font-lock-keywords |
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
694 '(;; Put From field in bold. |
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
695 ("^From: \\(.*\\)$" 1 font-lock-keyword-face) |
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
696 ;; Put subject in bold italics |
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
697 ("^Subject: \\(.*\\)$" 1 font-lock-function-name-face)) |
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
698 "Additional expressions to highlight in Rmail mode.") |
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
699 |
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
700 (defvar compilation-mode-font-lock-keywords |
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
701 '(("^\\([^\n:]*:\\([0-9]+:\\)+\\)\\(.*\\)$" 1 font-lock-function-name-face)) |
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
702 ;;; ("^\\([^\n:]*:\\([0-9]+:\\)+\\)\\(.*\\)$" 0 font-lock-keyword-face keep) |
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
703 "Additional expressions to highlight in Compilation mode.") |
aa83a7152b11
(rmail-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6578
diff
changeset
|
704 |
4053 | 705 (provide 'font-lock) |
706 | |
707 ;;; font-lock.el ends here |