]> code.delx.au - gnu-emacs/blob - lisp/font-lock.el
(vc-rcs-status): Removing any trailing "-".
[gnu-emacs] / lisp / font-lock.el
1 ;; Electric Font Lock Mode
2 ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc.
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
57 (or (internal-find-face 'underline)
58 (copy-face 'default 'underline))
59 (set-face-underline-p 'underline t)
60
61 (defvar font-lock-comment-face
62 'italic
63 "Face to use for comments.")
64
65 (defvar font-lock-doc-string-face
66 'italic
67 "Face to use for documentation strings.")
68
69 (defvar font-lock-string-face
70 'underline
71 "Face to use for string constants.")
72
73 (defvar font-lock-function-name-face
74 'bold-italic
75 "Face to use for function names.")
76
77 (defvar font-lock-keyword-face
78 'bold
79 "Face to use for keywords.")
80
81 (defvar font-lock-type-face
82 'italic
83 "Face to use for data types.")
84
85 (make-variable-buffer-local 'font-lock-keywords)
86 (defvar font-lock-keywords nil
87 "*The keywords to highlight.
88 If this is a list, then elements may be of the forms:
89
90 \"string\" ; a regexp to highlight in the
91 ; `font-lock-keyword-face'.
92 (\"string\" . integer) ; match N of the regexp will be highlighted
93 (\"string\" . face-name) ; use the named face
94 (\"string\" integer face-name) ; both of the above
95 (\"string\" integer face-name t) ; this allows highlighting to overlap
96 ; with already-highlighted regions.
97
98 These regular expressions should not match text which spans lines.
99 While \\[font-lock-fontify-buffer] handles multi-line patterns correctly,
100 updating when you edit the buffer does not,
101 since it considers text one line at a time.
102
103 Be careful composing regexps for this list; the wrong pattern can dramatically
104 slow things down!")
105
106 (defvar font-lock-keywords-case-fold-search nil
107 "*Non-nil means the patterns in `font-lock-keywords' are case-insensitive.")
108
109 (defvar font-lock-verbose t
110 "*Non-nil means `font-lock-fontify-buffer' should print status messages.")
111
112 ;;;###autoload
113 (defvar font-lock-mode-hook nil
114 "Function or functions to run on entry to Font Lock mode.")
115
116 ;;; These variables record, for each buffer,
117 ;;; the parse state at a particular position, always the start of a line.
118 ;;; This is used to make font-lock-fontify-region faster.
119 (defvar font-lock-cache-position nil)
120 (defvar font-lock-cache-state nil)
121 (make-variable-buffer-local 'font-lock-cache-position)
122 (make-variable-buffer-local 'font-lock-cache-state)
123
124 (defun font-lock-fontify-region (start end)
125 "Put proper face on each string and comment between START and END."
126 (save-excursion
127 (goto-char start)
128 (beginning-of-line)
129 (setq end (min end (point-max)))
130 (let ((buffer-read-only nil)
131 state startline prev prevstate
132 (modified (buffer-modified-p)))
133 ;; Find the state at the line-beginning before START.
134 (setq startline (point))
135 (if (eq (point) font-lock-cache-position)
136 (setq state font-lock-cache-state)
137 ;; Find outermost containing sexp.
138 (beginning-of-defun)
139 ;; Find the state at STARTLINE.
140 (while (< (point) startline)
141 (setq state (parse-partial-sexp (point) startline 0)))
142 (setq font-lock-cache-state state
143 font-lock-cache-position (point)))
144 ;; Now find the state precisely at START.
145 (setq state (parse-partial-sexp (point) start nil nil state))
146 ;; If the region starts inside a string, show the extent of it.
147 (if (nth 3 state)
148 (let ((beg (point)))
149 (while (and (re-search-forward "\\s\"" end 'move)
150 (nth 3 (parse-partial-sexp beg (point)
151 nil nil state))))
152 (put-text-property beg (point) 'face font-lock-string-face)
153 (setq state (parse-partial-sexp beg (point) nil nil state))))
154 ;; Likewise for a comment.
155 (if (or (nth 4 state) (nth 7 state))
156 (let ((beg (point)))
157 (while (and (re-search-forward (if comment-end
158 (concat "\\s>\\|"
159 (regexp-quote comment-end))
160 "\\s>")
161 end 'move)
162 (nth 3 (parse-partial-sexp beg (point)
163 nil nil state))))
164 (put-text-property beg (point) 'face font-lock-comment-face)
165 (setq state (parse-partial-sexp beg (point) nil nil state))))
166 ;; Find each interesting place between here and END.
167 (while (and (< (point) end)
168 (setq prev (point) prevstate state)
169 (re-search-forward (concat "\\s\"\\|" comment-start-skip) end t)
170 ;; Clear out the fonts of what we skip over.
171 (progn (remove-text-properties prev (point) '(face nil)) t)
172 ;; Verify the state at that place
173 ;; so we don't get fooled by \" or \;.
174 (setq state (parse-partial-sexp prev (point)
175 nil nil state)))
176 (let ((here (point)))
177 (if (or (nth 4 state) (nth 7 state))
178 ;; We found a real comment start.
179 (let ((beg (match-beginning 0)))
180 (goto-char beg)
181 (save-restriction
182 (narrow-to-region (point-min) end)
183 (condition-case nil
184 (progn
185 (forward-comment 1)
186 ;; forward-comment skips all whitespace,
187 ;; so go back to the real end of the comment.
188 (skip-chars-backward " \t"))
189 (error (goto-char end))))
190 (put-text-property beg (point) 'face font-lock-comment-face)
191 (setq state (parse-partial-sexp here (point) nil nil state)))
192 (if (nth 3 state)
193 (let ((beg (match-beginning 0)))
194 (while (and (re-search-forward "\\s\"" end 'move)
195 (nth 3 (parse-partial-sexp here (point)
196 nil nil state))))
197 (put-text-property beg (point) 'face font-lock-string-face)
198 (setq state (parse-partial-sexp here (point) nil nil state))))
199 ))
200 ;; Make sure PREV is non-nil after the loop
201 ;; only if it was set on the very last iteration.
202 (setq prev nil))
203 (and prev
204 (remove-text-properties prev end '(face nil)))
205 (set-buffer-modified-p modified))))
206
207 ;; This code used to be used to show a string on reaching the end of it.
208 ;; It is probably not needed due to later changes to handle strings
209 ;; starting before the region in question.
210 ;; (if (and (null (nth 3 state))
211 ;; (eq (char-syntax (preceding-char)) ?\")
212 ;; (save-excursion
213 ;; (nth 3 (parse-partial-sexp prev (1- (point))
214 ;; nil nil prevstate))))
215 ;; ;; We found the end of a string.
216 ;; (save-excursion
217 ;; (setq foo2 (point))
218 ;; (let ((ept (point)))
219 ;; (forward-sexp -1)
220 ;; ;; Highlight the string when we see the end.
221 ;; ;; Doing it at the start leads to trouble:
222 ;; ;; either it fails to handle multiline strings
223 ;; ;; or it can run away when an unmatched " is inserted.
224 ;; (put-text-property (point) ept 'face
225 ;; (if (= (car state) 1)
226 ;; font-lock-doc-string-face
227 ;; font-lock-string-face)))))
228
229 (defun font-lock-unfontify-region (beg end)
230 (let ((modified (buffer-modified-p))
231 (buffer-read-only nil))
232 (remove-text-properties beg end '(face nil))
233 (set-buffer-modified-p modified)))
234
235 ;; Called when any modification is made to buffer text.
236 (defun font-lock-after-change-function (beg end old-len)
237 (save-excursion
238 (save-match-data
239 (goto-char beg)
240 ;; Discard the cache info if text before it has changed.
241 (and font-lock-cache-position
242 (> font-lock-cache-position beg)
243 (setq font-lock-cache-position nil))
244 ;; Rescan till end of line. yes!
245 (goto-char end)
246 (end-of-line)
247 (setq end (point))
248 (goto-char beg)
249 (beginning-of-line)
250 (setq beg (point))
251 ;; First scan for strings and comments.
252 ;; Must scan from line start in case of
253 ;; inserting space into `intfoo () {}'.
254 (font-lock-fontify-region beg (1+ end))
255 ;; Now scan for keywords.
256 (font-lock-hack-keywords beg end))))
257 \f
258 ;;; Fontifying arbitrary patterns
259
260 (defsubst font-lock-any-properties-p (start end)
261 (or (get-text-property start 'font-lock)
262 (let ((next (next-single-property-change start 'font-lock)))
263 (and next (< next end)))))
264
265 (defun font-lock-hack-keywords (start end &optional loudly)
266 (goto-char start)
267 (let ((case-fold-search font-lock-keywords-case-fold-search)
268 (rest font-lock-keywords)
269 (count 0)
270 (buffer-read-only nil)
271 (modified (buffer-modified-p))
272 first str match face s e allow-overlap-p)
273 (while rest
274 (setq first (car rest) rest (cdr rest))
275 (goto-char start)
276 (cond ((consp first)
277 (setq str (car first))
278 (cond ((consp (cdr first))
279 (setq match (nth 1 first)
280 face (eval (nth 2 first))
281 allow-overlap-p (nth 3 first)))
282 ((symbolp (cdr first))
283 (setq match 0 allow-overlap-p nil
284 face (eval (cdr first))))
285 (t
286 (setq match (cdr first)
287 allow-overlap-p nil
288 face font-lock-keyword-face))))
289 (t
290 (setq str first match 0 allow-overlap-p nil
291 face font-lock-keyword-face)))
292 ;(message "regexp: %s" str)
293 (while (re-search-forward str end t)
294 (setq s (match-beginning match)
295 e (match-end match))
296 (or s (error "expression did not match subexpression %d" match))
297 ;; don't fontify this keyword if we're already in some other context.
298 (or (if allow-overlap-p nil (font-lock-any-properties-p s e))
299 (progn
300 (put-text-property s e 'face face))))
301 (if loudly (message "Fontifying %s... (regexps...%s)"
302 (buffer-name)
303 (make-string (setq count (1+ count)) ?.))))
304 (set-buffer-modified-p modified)))
305 \f
306 ;; The user level functions
307
308 (defvar font-lock-mode nil) ; for modeline
309 (or (assq 'font-lock-mode minor-mode-alist)
310 (setq minor-mode-alist
311 (append minor-mode-alist
312 '((font-lock-mode " Font")))))
313
314 (defvar font-lock-fontified nil) ; whether we have hacked this buffer
315 (put 'font-lock-fontified 'permanent-local t)
316
317 ;;;###autoload
318 (defun font-lock-mode (&optional arg)
319 "Toggle Font Lock mode.
320 With arg, turn Font Lock mode on if and only if arg is positive.
321
322 When Font Lock mode is enabled, text is fontified as you type it:
323
324 - comments are displayed in `font-lock-comment-face';
325 (That is a variable whose value should be a face name.)
326 - strings are displayed in `font-lock-string-face';
327 - documentation strings are displayed in `font-lock-doc-string-face';
328 - function and variable names in their defining forms are displayed
329 in `font-lock-function-name-face';
330 - and certain other expressions are displayed in other faces
331 according to the value of the variable `font-lock-keywords'.
332
333 When you turn Font Lock mode on/off, the buffer is fontified/defontified.
334 To fontify a buffer without having newly typed text become fontified, you
335 can use \\[font-lock-fontify-buffer]."
336 (interactive "P")
337 (let ((on-p (if (null arg)
338 (not font-lock-mode)
339 (> (prefix-numeric-value arg) 0))))
340 (if (equal (buffer-name) " *Compiler Input*") ; hack for bytecomp...
341 (setq on-p nil))
342 (or (memq after-change-function
343 '(nil font-lock-after-change-function))
344 (error "after-change-function is %s" after-change-function))
345 (set (make-local-variable 'after-change-function)
346 (if on-p 'font-lock-after-change-function nil))
347 (set (make-local-variable 'font-lock-mode) on-p)
348 (cond (on-p
349 (font-lock-set-defaults)
350 (run-hooks 'font-lock-mode-hook)
351 (or font-lock-fontified (font-lock-fontify-buffer)))
352 (font-lock-fontified
353 (setq font-lock-fontified nil)
354 (font-lock-unfontify-region (point-min) (point-max))))
355 (force-mode-line-update)))
356
357
358 (defun font-lock-fontify-buffer ()
359 "Fontify the current buffer the way `font-lock-mode' would:
360
361 - comments are displayed in `font-lock-comment-face';
362 - strings are displayed in `font-lock-string-face';
363 - documentation strings are displayed in `font-lock-doc-string-face';
364 - function and variable names in their defining forms are displayed
365 in `font-lock-function-name-face';
366 - and certain other expressions are displayed in other faces
367 according to the value of the variable `font-lock-keywords'.
368
369 This can take a while for large buffers."
370 (interactive)
371 (let ((was-on font-lock-mode)
372 (font-lock-verbose (or font-lock-verbose (interactive-p))))
373 (if font-lock-verbose (message "Fontifying %s..." (buffer-name)))
374 ;; Turn it on to run hooks and get the right font-lock-keywords.
375 (or was-on (font-lock-mode 1))
376 (font-lock-unfontify-region (point-min) (point-max))
377 (if font-lock-verbose (message "Fontifying %s... (syntactically...)"
378 (buffer-name)))
379 ;; (buffer-syntactic-context-flush-cache)
380 (save-excursion
381 (font-lock-fontify-region (point-min) (point-max))
382 (if font-lock-verbose (message "Fontifying %s... (regexps...)"
383 (buffer-name)))
384 (font-lock-hack-keywords (point-min) (point-max) font-lock-verbose))
385 (or was-on (font-lock-mode 0)) ; turn it off if it was off.
386 (set (make-local-variable 'font-lock-fontified) t)
387 (if font-lock-verbose (message "Fontifying %s... done." (buffer-name)))
388 ))
389
390 \f
391 ;;; Various mode-specific information.
392
393 (defun font-lock-set-defaults ()
394 "sets font-lock-keywords to something appropriate for this mode."
395 (setq font-lock-keywords
396 (cond ((eq major-mode 'lisp-mode) lisp-font-lock-keywords)
397 ((eq major-mode 'emacs-lisp-mode) lisp-font-lock-keywords)
398 ((eq major-mode 'c-mode) c-font-lock-keywords)
399 ((eq major-mode 'c++-c-mode) c-font-lock-keywords)
400 ((eq major-mode 'c++-mode) c++-font-lock-keywords)
401 ((eq major-mode 'perl-mode) perl-font-lock-keywords)
402 ((eq major-mode 'tex-mode) tex-font-lock-keywords)
403 ((eq major-mode 'texinfo-mode) texi-font-lock-keywords)
404 (t nil))))
405
406 (defconst lisp-font-lock-keywords-1
407 '(;;
408 ;; highlight defining forms. This doesn't work too nicely for
409 ;; (defun (setf foo) ...) but it does work for (defvar foo) which
410 ;; is more important.
411 ("^(def[-a-z]+\\s +\\([^ \t\n\)]+\\)" 1 font-lock-function-name-face)
412 ;;
413 ;; highlight CL keywords
414 ("\\s :\\(\\(\\sw\\|\\s_\\)+\\)\\>" . 1)
415 ;;
416 ;; this is highlights things like (def* (setf foo) (bar baz)), but may
417 ;; be slower (I haven't really thought about it)
418 ; ("^(def[-a-z]+\\s +\\(\\s(\\S)*\\s)\\|\\S(\\S *\\)"
419 ; 1 font-lock-function-name-face)
420 )
421 "For consideration as a value of `lisp-font-lock-keywords'.
422 This does fairly subdued highlighting.")
423
424 (defconst lisp-font-lock-keywords-2
425 (append
426 lisp-font-lock-keywords-1
427 '(;;
428 ;; Highlight control structures
429 ("(\\(cond\\|if\\|when\\|unless\\|[ec]?\\(type\\)?case\\)[ \t\n]" . 1)
430 ("(\\(while\\|do\\|let*?\\|flet\\|labels\\|prog[nv12*]?\\)[ \t\n]" . 1)
431 ("(\\(catch\\|\\throw\\|block\\|return\\|return-from\\)[ \t\n]" . 1)
432 ("(\\(save-restriction\\|save-window-restriction\\)[ \t\n]" . 1)
433 ("(\\(save-excursion\\|unwind-protect\\|condition-case\\)[ \t\n]" . 1)
434 ;;
435 ;; highlight function names in emacs-lisp docstrings (in the syntax
436 ;; that substitute-command-keys understands.)
437 ("\\\\\\\\\\[\\([^]\\\n]+\\)]" 1 font-lock-keyword-face t)
438 ;;
439 ;; highlight words inside `' which tend to be function names
440 ("`\\([-a-zA-Z0-9_][-a-zA-Z0-9_][-a-zA-Z0-9_.]+\\)'"
441 1 font-lock-keyword-face t)
442 ))
443 "For consideration as a value of `lisp-font-lock-keywords'.
444 This does a lot more highlighting.")
445
446 ;; default to the gaudier variety?
447 ;(defvar lisp-font-lock-keywords lisp-font-lock-keywords-2
448 ; "Additional expressions to highlight in Lisp modes.")
449 (defvar lisp-font-lock-keywords lisp-font-lock-keywords-1
450 "Additional expressions to highlight in Lisp modes.")
451
452
453 (defconst c-font-lock-keywords-1 nil
454 "For consideration as a value of `c-font-lock-keywords'.
455 This does fairly subdued highlighting.")
456
457 (defconst c-font-lock-keywords-2 nil
458 "For consideration as a value of `c-font-lock-keywords'.
459 This does a lot more highlighting.")
460
461 (let ((storage "auto\\|extern\\|register\\|static\\|volatile")
462 (prefixes "unsigned\\|short\\|long")
463 (types (concat "int\\|char\\|float\\|double\\|void\\|struct\\|"
464 "union\\|enum\\|typedef"))
465 (ctoken "[a-zA-Z0-9_:~*]+")
466 )
467 (setq c-font-lock-keywords-1
468 (list
469 ;; fontify preprocessor directives as comments.
470 '("^#[ \t]*[a-z]+" . font-lock-comment-face)
471 ;;
472 ;; fontify names being defined.
473 '("^#[ \t]*\\(define\\|undef\\)[ \t]+\\(\\(\\sw\\|\\s_\\)+\\)" 2
474 font-lock-function-name-face)
475 ;;
476 ;; fontify other preprocessor lines.
477 '("^#[ \t]*\\(if\\|ifn?def\\)[ \t]+\\([^\n]+\\)"
478 2 font-lock-function-name-face t)
479 ;;
480 ;; fontify the filename in #include <...>
481 ;; don't need to do this for #include "..." because those were
482 ;; already fontified as strings by the syntactic pass.
483 '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
484 ;;
485 ;; fontify the names of functions being defined.
486 (list (concat
487 "^\\(" ctoken "[ \t]+\\)?" ; type specs; there can be no
488 "\\(" ctoken "[ \t]+\\)?" ; more than 3 tokens, right?
489 "\\(" ctoken "[ \t]+\\)?"
490 "\\([*&]+[ \t]*\\)?" ; pointer
491 "\\(" ctoken "\\)[ \t]*(") ; name
492 5 'font-lock-function-name-face)
493 ;;
494 ;;
495 ;; Fontify structure names (in structure definition form).
496 (list (concat "^\\(typedef[ \t]+struct\\|struct\\|static[ \t]+struct\\)"
497 "[ \t]+\\(" ctoken "\\)[ \t]*\\(\{\\|$\\)")
498 2 'font-lock-function-name-face)
499 ;;
500 ;; Fontify case clauses. This is fast because its anchored on the left.
501 '("case[ \t]+\\(\\(\\sw\\|\\s_\\)+\\):". 1)
502 '("\\<\\(default\\):". 1)
503 ))
504
505 (setq c-font-lock-keywords-2
506 (append c-font-lock-keywords-1
507 (list
508 ;;
509 ;; fontify all storage classes and type specifiers
510 (cons (concat "\\<\\(" storage "\\)\\>") 'font-lock-type-face)
511 (cons (concat "\\<\\(" types "\\)\\>") 'font-lock-type-face)
512 (cons (concat "\\<\\(" prefixes "[ \t]+" types "\\)\\>")
513 'font-lock-type-face)
514 ;;
515 ;; fontify all builtin tokens
516 (cons (concat
517 "[ \t]\\("
518 (mapconcat 'identity
519 '("for" "while" "do" "return" "goto" "case" "break" "switch"
520 "if" "then" "else if" "else" "return" "default" "continue"
521 "default"
522 )
523 "\\|")
524 "\\)[ \t\n(){};,]")
525 1)
526 ;;
527 ;; fontify case targets and goto-tags. This is slow because the
528 ;; expression is anchored on the right.
529 "\\(\\(\\sw\\|\\s_\\)+\\):"
530 ;;
531 ;; Fontify variables declared with structures, or typedef names.
532 '("}[ \t*]*\\(\\(\\sw\\|\\s_\\)+\\)[ \t]*[,;]"
533 1 font-lock-function-name-face)
534 ;;
535 ;; Fontify global variables without a type.
536 ; '("^\\([_a-zA-Z0-9:~*]+\\)[ \t]*[[;={]" 1 font-lock-function-name-face)
537
538 )))
539 )
540
541 ; default to the gaudier variety?
542 ;(defvar c-font-lock-keywords c-font-lock-keywords-2
543 ; "Additional expressions to highlight in C mode.")
544 (defvar c-font-lock-keywords c-font-lock-keywords-1
545 "Additional expressions to highlight in C mode.")
546
547 (defvar c++-font-lock-keywords c-font-lock-keywords
548 "Additional expressions to highlight in C++ mode.")
549
550
551 (defvar perl-font-lock-keywords
552 (list
553 (cons (concat "[ \n\t{]*\\("
554 (mapconcat 'identity
555 '("if" "until" "while" "elsif" "else" "unless" "for"
556 "foreach" "continue" "exit" "die" "last" "goto" "next"
557 "redo" "return" "local" "exec")
558 "\\|")
559 "\\)[ \n\t;(]") 1)
560 (mapconcat 'identity
561 '("#endif" "#else" "#ifdef" "#ifndef" "#if" "#include"
562 "#define" "#undef")
563 "\\|")
564 '("^[ \n\t]*sub[ \t]+\\([^ \t{]+\\)[ \t]*[{]" 1 font-lock-function-name-face)
565 '("[ \n\t{]*\\(eval\\)[ \n\t(;]" 1 font-lock-function-name-face)
566 '("\\(--- .* ---\\|=== .* ===\\)" . font-lock-doc-string-face)
567 )
568 "Additional expressions to highlight in Perl mode.")
569
570 (defvar tex-font-lock-keywords
571 (list
572 '("\\(\\\\\\w+\\)" 1 font-lock-keyword-face t)
573 '("{\\\\em\\([^}]+\\)}" 1 font-lock-comment-face t)
574 '("{\\\\bf\\([^}]+\\)}" 1 font-lock-keyword-face t)
575 '("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" 1 font-lock-function-name-face t)
576 '("\\\\\\(begin\\|end\\){\\([a-zA-Z0-9\\*]+\\)}"
577 2 font-lock-function-name-face t)
578 '("[^\\\\]\\$\\([^$]*\\)\\$" 1 font-lock-string-face t)
579 ; '("\\$\\([^$]*\\)\\$" 1 font-lock-string-face t)
580 )
581 "Additional expressions to highlight in TeX mode.")
582
583 (defvar texi-font-lock-keywords
584 (list
585 "@\\(@\\|[^}\t \n{]+\\)" ;commands
586 '("^\\(@c\\|@comment\\)[ \t].*$" . font-lock-comment-face) ;comments
587 '("^\\(*.*\\)[\t ]*$" 1 font-lock-function-name-face t) ;menu items
588 '("@\\(emph\\|strong\\|b\\|i\\){\\([^}]+\\)" 2 font-lock-comment-face t)
589 '("@\\(file\\|kbd\\|key\\){\\([^}]+\\)" 2 font-lock-string-face t)
590 '("@\\(samp\\|code\\|var\\){\\([^}]+\\)" 2 font-lock-function-name-face t)
591 '("@\\(xref\\|pxref\\){\\([^}]+\\)" 2 font-lock-keyword-face t)
592 '("@end *\\([a-zA-Z0-9]+\\)[ \t]*$" 1 font-lock-function-name-face t)
593 '("@item \\(.*\\)$" 1 font-lock-function-name-face t)
594 '("\\$\\([^$]*\\)\\$" 1 font-lock-string-face t)
595 )
596 "Additional expressions to highlight in TeXinfo mode.")
597
598 (provide 'font-lock)
599
600 ;;; font-lock.el ends here