1993-07-09 20:27:43 +00:00
|
|
|
|
;; Electric Font Lock Mode
|
1995-03-02 10:57:07 +00:00
|
|
|
|
;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
1995-03-02 10:57:07 +00:00
|
|
|
|
;; Author: jwz, then rms and sm <simon@gnu.ai.mit.edu>
|
1993-07-09 20:27:43 +00:00
|
|
|
|
;; Maintainer: FSF
|
|
|
|
|
;; Keywords: languages, faces
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
;; any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
|
|
|
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
1994-10-12 09:23:37 +00:00
|
|
|
|
;; Font Lock mode is a minor mode that causes your comments to be displayed in
|
|
|
|
|
;; one face, strings in another, reserved words in another, and so on.
|
1993-07-09 20:27:43 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Comments will be displayed in `font-lock-comment-face'.
|
|
|
|
|
;; Strings will be displayed in `font-lock-string-face'.
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; Regexps are used to display selected patterns in other faces.
|
1993-07-09 20:27:43 +00:00
|
|
|
|
;;
|
|
|
|
|
;; To make the text you type be fontified, use M-x font-lock-mode.
|
1994-10-12 09:23:37 +00:00
|
|
|
|
;; When this minor mode is on, the faces of the current line are
|
1993-07-09 20:27:43 +00:00
|
|
|
|
;; updated with every insertion or deletion.
|
|
|
|
|
;;
|
1994-10-12 09:23:37 +00:00
|
|
|
|
;; To turn Font Lock mode on automatically, add this to your .emacs file:
|
1993-07-09 20:27:43 +00:00
|
|
|
|
;;
|
1994-10-12 09:23:37 +00:00
|
|
|
|
;; (add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock)
|
1993-07-09 20:27:43 +00:00
|
|
|
|
;;
|
1994-10-12 09:23:37 +00:00
|
|
|
|
;; On a Sparc2, `font-lock-fontify-buffer' takes about 10 seconds for a 120k
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; file of C code using the default configuration, and about 25 seconds using
|
|
|
|
|
;; the more extensive configuration, though times also depend on file contents.
|
|
|
|
|
;; You can speed this up substantially by removing some of the patterns that
|
|
|
|
|
;; are highlighted by default. Fontifying Lisp code is significantly faster,
|
|
|
|
|
;; because Lisp has a more regular syntax than C, so the expressions don't have
|
|
|
|
|
;; to be as hairy.
|
|
|
|
|
;;
|
1994-10-12 09:23:37 +00:00
|
|
|
|
;; If you add patterns for a new mode, say foo.el's `foo-mode', say in which
|
|
|
|
|
;; you don't want syntactic fontification to occur, you can make Font Lock mode
|
|
|
|
|
;; use your regexps when turning on Font Lock by adding to `foo-mode-hook':
|
|
|
|
|
;;
|
|
|
|
|
;; (add-hook 'foo-mode-hook
|
|
|
|
|
;; '(lambda () (make-local-variable 'font-lock-defaults)
|
|
|
|
|
;; (setq font-lock-defaults '(foo-font-lock-keywords t))))
|
|
|
|
|
;;
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; Nasty regexps of the form "bar\\(\\|lo\\)\\|f\\(oo\\|u\\(\\|bar\\)\\)\\|lo"
|
|
|
|
|
;; are made thusly: (make-regexp '("foo" "fu" "fubar" "bar" "barlo" "lo")) for
|
|
|
|
|
;; efficiency. See /pub/gnu/emacs/elisp-archive/functions/make-regexp.el.Z on
|
|
|
|
|
;; archive.cis.ohio-state.edu for this and other functions.
|
|
|
|
|
|
1993-07-09 20:27:43 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(defvar font-lock-comment-face 'font-lock-comment-face
|
|
|
|
|
"Face to use for comments.")
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(defvar font-lock-string-face 'font-lock-string-face
|
|
|
|
|
"Face to use for strings.")
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(defvar font-lock-function-name-face 'font-lock-function-name-face
|
1993-07-09 20:27:43 +00:00
|
|
|
|
"Face to use for function names.")
|
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(defvar font-lock-variable-name-face 'font-lock-variable-name-face
|
|
|
|
|
"Face to use for variable names.")
|
|
|
|
|
|
|
|
|
|
(defvar font-lock-keyword-face 'font-lock-keyword-face
|
1993-07-09 20:27:43 +00:00
|
|
|
|
"Face to use for keywords.")
|
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(defvar font-lock-type-face 'font-lock-type-face
|
1993-07-09 20:27:43 +00:00
|
|
|
|
"Face to use for data types.")
|
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(defvar font-lock-reference-face 'font-lock-reference-face
|
|
|
|
|
"Face to use for references.")
|
|
|
|
|
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(make-variable-buffer-local 'font-lock-keywords)
|
|
|
|
|
(defvar font-lock-keywords nil
|
1995-08-10 13:57:18 +00:00
|
|
|
|
"*A list of the keywords to highlight.
|
|
|
|
|
Each element should be of the form:
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
|
1995-04-24 10:49:03 +00:00
|
|
|
|
MATCHER
|
|
|
|
|
(MATCHER . MATCH)
|
|
|
|
|
(MATCHER . FACENAME)
|
|
|
|
|
(MATCHER . HIGHLIGHT)
|
|
|
|
|
(MATCHER HIGHLIGHT ...)
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
|
|
|
|
|
where HIGHLIGHT should be of the form (MATCH FACENAME OVERRIDE LAXMATCH).
|
1995-04-24 10:49:03 +00:00
|
|
|
|
MATCHER can be either the regexp to search for, or the function name to call to
|
|
|
|
|
make the search (called with one argument, the limit of the search). MATCH is
|
|
|
|
|
the subexpression of MATCHER to be highlighted. FACENAME is an expression
|
|
|
|
|
whose value is the face name to use. FACENAME's default attributes may be
|
|
|
|
|
defined in `font-lock-face-attributes'.
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
|
|
|
|
|
OVERRIDE and LAXMATCH are flags. If OVERRIDE is t, existing fontification may
|
|
|
|
|
be overriden. If `keep', only parts not already fontified are highlighted.
|
1995-04-24 10:49:03 +00:00
|
|
|
|
If LAXMATCH is non-nil, no error is signalled if there is no MATCH in MATCHER.
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
|
|
|
|
|
These regular expressions should not match text which spans lines. While
|
|
|
|
|
\\[font-lock-fontify-buffer] handles multi-line patterns correctly, updating
|
|
|
|
|
when you edit the buffer does not, since it considers text one line at a time.
|
|
|
|
|
|
|
|
|
|
Be careful composing regexps for this list;
|
|
|
|
|
the wrong pattern can dramatically slow things down!")
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(defvar font-lock-defaults nil
|
|
|
|
|
"If set by a major mode, should be the defaults for Font Lock mode.
|
|
|
|
|
The value should look like the `cdr' of an item in `font-lock-defaults-alist'.")
|
|
|
|
|
|
|
|
|
|
(defvar font-lock-defaults-alist
|
1995-08-10 13:57:18 +00:00
|
|
|
|
(let (
|
|
|
|
|
;; For C and Lisp modes we use `beginning-of-defun', rather than nil,
|
|
|
|
|
;; for SYNTAX-BEGIN. Thus the calculation of the cache is faster but
|
|
|
|
|
;; not infallible, so we risk mis-fontification. --sm
|
1995-06-26 11:55:25 +00:00
|
|
|
|
(c-mode-defaults
|
|
|
|
|
'((c-font-lock-keywords c-font-lock-keywords-1 c-font-lock-keywords-2)
|
1995-08-10 13:57:18 +00:00
|
|
|
|
nil nil ((?\_ . "w")) beginning-of-defun))
|
1995-06-26 11:55:25 +00:00
|
|
|
|
(c++-mode-defaults
|
|
|
|
|
'((c++-font-lock-keywords c++-font-lock-keywords-1
|
|
|
|
|
c++-font-lock-keywords-2)
|
1995-08-10 13:57:18 +00:00
|
|
|
|
nil nil ((?\_ . "w")) beginning-of-defun))
|
1995-06-26 11:55:25 +00:00
|
|
|
|
(lisp-mode-defaults
|
|
|
|
|
'((lisp-font-lock-keywords lisp-font-lock-keywords-1
|
|
|
|
|
lisp-font-lock-keywords-2)
|
1995-08-10 13:57:18 +00:00
|
|
|
|
nil nil ((?\: . "w") (?\- . "w") (?\* . "w"))
|
|
|
|
|
beginning-of-defun))
|
|
|
|
|
(scheme-mode-defaults
|
|
|
|
|
'(scheme-font-lock-keywords
|
|
|
|
|
nil nil ((?\: . "w") (?\- . "w") (?\* . "w") (?\/ . "w"))
|
|
|
|
|
beginning-of-defun))
|
|
|
|
|
;; For TeX modes we could use `backward-paragraph' for the same reason.
|
|
|
|
|
(tex-mode-defaults '(tex-font-lock-keywords nil nil ((?\$ . "\""))))
|
|
|
|
|
)
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(list
|
1995-08-10 13:57:18 +00:00
|
|
|
|
(cons 'bibtex-mode tex-mode-defaults)
|
|
|
|
|
(cons 'c++-c-mode c-mode-defaults)
|
|
|
|
|
(cons 'c++-mode c++-mode-defaults)
|
|
|
|
|
(cons 'c-mode c-mode-defaults)
|
|
|
|
|
(cons 'emacs-lisp-mode lisp-mode-defaults)
|
|
|
|
|
(cons 'inferior-scheme-mode scheme-mode-defaults)
|
|
|
|
|
(cons 'latex-mode tex-mode-defaults)
|
|
|
|
|
(cons 'lisp-mode lisp-mode-defaults)
|
|
|
|
|
(cons 'lisp-interaction-mode lisp-mode-defaults)
|
|
|
|
|
(cons 'plain-tex-mode tex-mode-defaults)
|
|
|
|
|
(cons 'scheme-mode scheme-mode-defaults)
|
|
|
|
|
(cons 'scheme-interaction-mode scheme-mode-defaults)
|
|
|
|
|
(cons 'slitex-mode tex-mode-defaults)
|
|
|
|
|
(cons 'tex-mode tex-mode-defaults)))
|
1994-10-12 09:23:37 +00:00
|
|
|
|
"*Alist of default major mode and Font Lock defaults.
|
|
|
|
|
Each item should be a list of the form:
|
1995-08-10 13:57:18 +00:00
|
|
|
|
|
|
|
|
|
(MAJOR-MODE . (KEYWORDS KEYWORDS-ONLY CASE-FOLD SYNTAX-ALIST SYNTAX-BEGIN))
|
|
|
|
|
|
|
|
|
|
where MAJOR-MODE is a symbol, and KEYWORDS may be a symbol or a list of
|
|
|
|
|
symbols. If KEYWORDS-ONLY is non-nil, syntactic fontification (strings and
|
1995-06-26 11:55:25 +00:00
|
|
|
|
comments) is not performed. If CASE-FOLD is non-nil, the case of the keywords
|
1995-08-10 13:57:18 +00:00
|
|
|
|
is ignored when fontifying. If SYNTAX-ALIST is non-nil, it should be a list of
|
|
|
|
|
cons pairs of the form (CHAR . STRING) used to set the local Font Lock syntax
|
|
|
|
|
table for keyword and syntactic fontification. (See `modify-syntax-entry'.)
|
|
|
|
|
|
|
|
|
|
SYNTAX-BEGIN should be a function, it is called with no args to move outside of
|
|
|
|
|
a syntactic block for syntactic fontification. Typical values are nil
|
|
|
|
|
\(equivalent to `beginning-of-buffer'), `beginning-of-line' (i.e., the start of
|
|
|
|
|
the line is known to be outside a syntactic block), or `beginning-of-defun' for
|
|
|
|
|
programming modes or `backward-paragraph' for textual modes (i.e., the
|
|
|
|
|
mode-dependent function is known to move outside a syntactic block).
|
|
|
|
|
|
|
|
|
|
These item elements are used by Font Lock mode to set the variables
|
|
|
|
|
`font-lock-keywords', `font-lock-no-comments',
|
|
|
|
|
`font-lock-keywords-case-fold-search', `font-lock-syntax-table' and
|
|
|
|
|
`font-lock-beginning-of-syntax-function', respectively.")
|
|
|
|
|
|
|
|
|
|
(defvar font-lock-no-comments nil
|
|
|
|
|
"*Non-nil means Font Lock should not fontify comments or strings.
|
|
|
|
|
This is normally set via `font-lock-defaults'.")
|
1994-10-12 09:23:37 +00:00
|
|
|
|
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(defvar font-lock-keywords-case-fold-search nil
|
1995-08-10 13:57:18 +00:00
|
|
|
|
"*Non-nil means the patterns in `font-lock-keywords' are case-insensitive.
|
|
|
|
|
This is normally set via `font-lock-defaults'.")
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
1994-08-05 05:11:30 +00:00
|
|
|
|
(defvar font-lock-syntax-table nil
|
1995-03-02 10:57:07 +00:00
|
|
|
|
"Non-nil means use this syntax table for fontifying.
|
1995-08-10 13:57:18 +00:00
|
|
|
|
If this is nil, the major mode's syntax table is used.
|
|
|
|
|
This is normally set via `font-lock-defaults'.")
|
|
|
|
|
|
|
|
|
|
(defvar font-lock-beginning-of-syntax-function nil
|
|
|
|
|
"*Non-nil means use this function to move outside of a syntactic block.
|
|
|
|
|
If this is nil, `beginning-of-buffer' is used.
|
|
|
|
|
This is normally set via `font-lock-defaults'.")
|
1994-08-05 05:11:30 +00:00
|
|
|
|
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(defvar font-lock-verbose t
|
|
|
|
|
"*Non-nil means `font-lock-fontify-buffer' should print status messages.")
|
|
|
|
|
|
1995-03-02 10:57:07 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defvar font-lock-maximum-decoration nil
|
1995-08-10 13:57:18 +00:00
|
|
|
|
"*If non-nil, the maximum decoration for fontifying.
|
1995-06-26 11:55:25 +00:00
|
|
|
|
If nil, use the default decoration (typically the minimum available).
|
|
|
|
|
If t, use the maximum decoration available.
|
|
|
|
|
If a number, use that level of decoration (or if not available the maximum).")
|
1995-04-24 10:49:03 +00:00
|
|
|
|
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;;;###autoload
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(defvar font-lock-maximum-size
|
|
|
|
|
(if font-lock-maximum-decoration (* 150 1024) (* 300 1024))
|
1995-08-10 13:57:18 +00:00
|
|
|
|
"*If non-nil, the maximum size for buffers for fontifying.
|
1995-04-24 10:49:03 +00:00
|
|
|
|
Only buffers less than this can be fontified when Font Lock mode is turned on.
|
|
|
|
|
If nil, means size is irrelevant.")
|
1995-03-02 10:57:07 +00:00
|
|
|
|
|
1993-07-09 20:28:05 +00:00
|
|
|
|
;;;###autoload
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(defvar font-lock-mode-hook nil
|
|
|
|
|
"Function or functions to run on entry to Font Lock mode.")
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
|
|
|
|
|
;; Colour etc. support.
|
|
|
|
|
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(defvar font-lock-display-type nil
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
"A symbol indicating the display Emacs is running under.
|
|
|
|
|
The symbol should be one of `color', `grayscale' or `mono'.
|
|
|
|
|
If Emacs guesses this display attribute wrongly, either set this variable in
|
1994-10-12 09:23:37 +00:00
|
|
|
|
your `~/.emacs' or set the resource `Emacs.displayType' in your `~/.Xdefaults'.
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
See also `font-lock-background-mode' and `font-lock-face-attributes'.")
|
|
|
|
|
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(defvar font-lock-background-mode nil
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
"A symbol indicating the Emacs background brightness.
|
|
|
|
|
The symbol should be one of `light' or `dark'.
|
|
|
|
|
If Emacs guesses this frame attribute wrongly, either set this variable in
|
1994-10-12 09:23:37 +00:00
|
|
|
|
your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
|
|
|
|
|
`~/.Xdefaults'.
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
See also `font-lock-display-type' and `font-lock-face-attributes'.")
|
|
|
|
|
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(defvar font-lock-face-attributes nil
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
"A list of default attributes to use for face attributes.
|
|
|
|
|
Each element of the list should be of the form
|
|
|
|
|
|
|
|
|
|
(FACE FOREGROUND BACKGROUND BOLD-P ITALIC-P UNDERLINE-P)
|
|
|
|
|
|
|
|
|
|
where FACE should be one of the face symbols `font-lock-comment-face',
|
|
|
|
|
`font-lock-string-face', `font-lock-keyword-face', `font-lock-type-face',
|
|
|
|
|
`font-lock-function-name-face', `font-lock-variable-name-face', and
|
|
|
|
|
`font-lock-reference-face'. A form for each of these face symbols should be
|
|
|
|
|
provided in the list, but other face symbols and attributes may be given and
|
|
|
|
|
used in highlighting. See `font-lock-keywords'.
|
|
|
|
|
|
|
|
|
|
Subsequent element items should be the attributes for the corresponding
|
|
|
|
|
Font Lock mode faces. Attributes FOREGROUND and BACKGROUND should be strings
|
|
|
|
|
\(default if nil), while BOLD-P, ITALIC-P, and UNDERLINE-P should specify the
|
|
|
|
|
corresponding face attributes (yes if non-nil).
|
|
|
|
|
|
|
|
|
|
Emacs uses default attributes based on display type and background brightness.
|
|
|
|
|
See variables `font-lock-display-type' and `font-lock-background-mode'.
|
|
|
|
|
|
|
|
|
|
Resources can be used to over-ride these face attributes. For example, the
|
|
|
|
|
resource `Emacs.font-lock-comment-face.attributeUnderline' can be used to
|
|
|
|
|
specify the UNDERLINE-P attribute for face `font-lock-comment-face'.")
|
|
|
|
|
|
1995-06-16 07:47:09 +00:00
|
|
|
|
(defun font-lock-make-faces (&optional override)
|
1994-10-12 09:23:37 +00:00
|
|
|
|
"Make faces from `font-lock-face-attributes'.
|
|
|
|
|
A default list is used if this is nil.
|
1995-06-16 07:47:09 +00:00
|
|
|
|
If optional OVERRIDE is non-nil, faces that already exist are reset.
|
1994-10-12 09:23:37 +00:00
|
|
|
|
See `font-lock-make-face' and `list-faces-display'."
|
|
|
|
|
;; We don't need to `setq' any of these variables, but the user can see what
|
|
|
|
|
;; is being used if we do.
|
|
|
|
|
(if (null font-lock-display-type)
|
|
|
|
|
(setq font-lock-display-type
|
|
|
|
|
(let ((display-resource (x-get-resource ".displayType"
|
|
|
|
|
"DisplayType")))
|
|
|
|
|
(cond (display-resource (intern (downcase display-resource)))
|
|
|
|
|
((x-display-color-p) 'color)
|
|
|
|
|
((x-display-grayscale-p) 'grayscale)
|
|
|
|
|
(t 'mono)))))
|
|
|
|
|
(if (null font-lock-background-mode)
|
|
|
|
|
(setq font-lock-background-mode
|
|
|
|
|
(let ((bg-resource (x-get-resource ".backgroundMode"
|
|
|
|
|
"BackgroundMode"))
|
|
|
|
|
(params (frame-parameters)))
|
|
|
|
|
(cond (bg-resource (intern (downcase bg-resource)))
|
1995-04-16 05:41:53 +00:00
|
|
|
|
((< (apply '+ (x-color-values
|
|
|
|
|
(cdr (assq 'background-color params))))
|
|
|
|
|
(/ (apply '+ (x-color-values "white")) 3))
|
1994-10-12 09:23:37 +00:00
|
|
|
|
'dark)
|
|
|
|
|
(t 'light)))))
|
|
|
|
|
(if (null font-lock-face-attributes)
|
|
|
|
|
(setq font-lock-face-attributes
|
|
|
|
|
(let ((light-bg (eq font-lock-background-mode 'light)))
|
|
|
|
|
(cond ((memq font-lock-display-type '(mono monochrome))
|
|
|
|
|
;; Emacs 19.25's font-lock defaults:
|
|
|
|
|
;;'((font-lock-comment-face nil nil nil t nil)
|
|
|
|
|
;; (font-lock-string-face nil nil nil nil t)
|
|
|
|
|
;; (font-lock-keyword-face nil nil t nil nil)
|
|
|
|
|
;; (font-lock-function-name-face nil nil t t nil)
|
|
|
|
|
;; (font-lock-type-face nil nil nil t nil))
|
|
|
|
|
(list '(font-lock-comment-face nil nil t t nil)
|
|
|
|
|
'(font-lock-string-face nil nil nil t nil)
|
|
|
|
|
'(font-lock-keyword-face nil nil t nil nil)
|
|
|
|
|
(list
|
|
|
|
|
'font-lock-function-name-face
|
|
|
|
|
(cdr (assq 'background-color (frame-parameters)))
|
|
|
|
|
(cdr (assq 'foreground-color (frame-parameters)))
|
|
|
|
|
t nil nil)
|
|
|
|
|
'(font-lock-variable-name-face nil nil t t nil)
|
|
|
|
|
'(font-lock-type-face nil nil t nil t)
|
|
|
|
|
'(font-lock-reference-face nil nil t nil t)))
|
|
|
|
|
((memq font-lock-display-type '(grayscale greyscale
|
|
|
|
|
grayshade greyshade))
|
|
|
|
|
(list
|
|
|
|
|
(list 'font-lock-comment-face
|
1995-07-07 13:27:15 +00:00
|
|
|
|
nil (if light-bg "Gray80" "DimGray") t t nil)
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(list 'font-lock-string-face
|
1995-07-07 13:27:15 +00:00
|
|
|
|
nil (if light-bg "Gray50" "LightGray") nil t nil)
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(list 'font-lock-keyword-face
|
1995-07-07 13:27:15 +00:00
|
|
|
|
nil (if light-bg "Gray90" "DimGray") t nil nil)
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(list 'font-lock-function-name-face
|
|
|
|
|
(cdr (assq 'background-color (frame-parameters)))
|
|
|
|
|
(cdr (assq 'foreground-color (frame-parameters)))
|
|
|
|
|
t nil nil)
|
|
|
|
|
(list 'font-lock-variable-name-face
|
1995-07-07 13:27:15 +00:00
|
|
|
|
nil (if light-bg "Gray90" "DimGray") t t nil)
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(list 'font-lock-type-face
|
1995-07-07 13:27:15 +00:00
|
|
|
|
nil (if light-bg "Gray80" "DimGray") t nil t)
|
1994-12-01 14:00:16 +00:00
|
|
|
|
(list 'font-lock-reference-face
|
1995-07-07 13:27:15 +00:00
|
|
|
|
nil (if light-bg "LightGray" "Gray50") t nil t)))
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(light-bg ; light colour background
|
|
|
|
|
'((font-lock-comment-face "Firebrick")
|
|
|
|
|
(font-lock-string-face "RosyBrown")
|
|
|
|
|
(font-lock-keyword-face "Purple")
|
|
|
|
|
(font-lock-function-name-face "Blue")
|
|
|
|
|
(font-lock-variable-name-face "DarkGoldenrod")
|
|
|
|
|
(font-lock-type-face "DarkOliveGreen")
|
|
|
|
|
(font-lock-reference-face "CadetBlue")))
|
|
|
|
|
(t ; dark colour background
|
|
|
|
|
'((font-lock-comment-face "OrangeRed")
|
|
|
|
|
(font-lock-string-face "LightSalmon")
|
|
|
|
|
(font-lock-keyword-face "LightSteelBlue")
|
|
|
|
|
(font-lock-function-name-face "LightSkyBlue")
|
|
|
|
|
(font-lock-variable-name-face "LightGoldenrod")
|
|
|
|
|
(font-lock-type-face "PaleGreen")
|
|
|
|
|
(font-lock-reference-face "Aquamarine")))))))
|
1995-06-16 07:47:09 +00:00
|
|
|
|
;; Now make the faces if we have to.
|
1995-08-10 13:57:18 +00:00
|
|
|
|
(mapcar (function
|
|
|
|
|
(lambda (face-attributes)
|
1995-06-16 07:47:09 +00:00
|
|
|
|
(let ((face (nth 0 face-attributes)))
|
1995-08-10 13:57:18 +00:00
|
|
|
|
(cond (override
|
|
|
|
|
;; We can stomp all over it anyway. Get outta my face!
|
|
|
|
|
(font-lock-make-face face-attributes))
|
|
|
|
|
((and (boundp face) (facep (symbol-value face)))
|
|
|
|
|
;; The variable exists and is already bound to a face.
|
|
|
|
|
nil)
|
|
|
|
|
((facep face)
|
|
|
|
|
;; We already have a face so we bind the variable to it.
|
|
|
|
|
(set face face))
|
|
|
|
|
(t
|
|
|
|
|
;; No variable or no face.
|
|
|
|
|
(font-lock-make-face face-attributes))))))
|
1995-06-16 07:47:09 +00:00
|
|
|
|
font-lock-face-attributes))
|
1994-10-12 09:23:37 +00:00
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(defun font-lock-make-face (face-attributes)
|
|
|
|
|
"Make a face from FACE-ATTRIBUTES.
|
|
|
|
|
FACE-ATTRIBUTES should be like an element `font-lock-face-attributes', so that
|
|
|
|
|
the face name is the first item in the list. A variable with the same name as
|
|
|
|
|
the face is also set; its value is the face name."
|
|
|
|
|
(let* ((face (nth 0 face-attributes))
|
|
|
|
|
(face-name (symbol-name face))
|
|
|
|
|
(set-p (function (lambda (face-name resource)
|
|
|
|
|
(x-get-resource (concat face-name ".attribute" resource)
|
|
|
|
|
(concat "Face.Attribute" resource)))))
|
|
|
|
|
(on-p (function (lambda (face-name resource)
|
|
|
|
|
(let ((set (funcall set-p face-name resource)))
|
|
|
|
|
(and set (member (downcase set) '("on" "true"))))))))
|
|
|
|
|
(make-face face)
|
|
|
|
|
;; Set attributes not set from X resources (and therefore `make-face').
|
|
|
|
|
(or (funcall set-p face-name "Foreground")
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(set-face-foreground face (nth 1 face-attributes))
|
|
|
|
|
(error nil)))
|
|
|
|
|
(or (funcall set-p face-name "Background")
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(set-face-background face (nth 2 face-attributes))
|
|
|
|
|
(error nil)))
|
|
|
|
|
(if (funcall set-p face-name "Bold")
|
|
|
|
|
(and (funcall on-p face-name "Bold") (make-face-bold face nil t))
|
|
|
|
|
(and (nth 3 face-attributes) (make-face-bold face nil t)))
|
|
|
|
|
(if (funcall set-p face-name "Italic")
|
|
|
|
|
(and (funcall on-p face-name "Italic") (make-face-italic face nil t))
|
|
|
|
|
(and (nth 4 face-attributes) (make-face-italic face nil t)))
|
|
|
|
|
(or (funcall set-p face-name "Underline")
|
|
|
|
|
(set-face-underline-p face (nth 5 face-attributes)))
|
|
|
|
|
(set face face)))
|
|
|
|
|
|
|
|
|
|
;; Fontification.
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; These variables record, for each buffer, the parse state at a particular
|
|
|
|
|
;; position, always the start of a line. Used to make font-lock-fontify-region
|
|
|
|
|
;; faster.
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(defvar font-lock-cache-position nil)
|
|
|
|
|
(defvar font-lock-cache-state nil)
|
|
|
|
|
(make-variable-buffer-local 'font-lock-cache-position)
|
|
|
|
|
(make-variable-buffer-local 'font-lock-cache-state)
|
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(defun font-lock-fontify-region (start end &optional loudly)
|
1993-07-09 20:27:43 +00:00
|
|
|
|
"Put proper face on each string and comment between START and END."
|
|
|
|
|
(save-excursion
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
|
|
|
|
(goto-char start)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(if loudly (message "Fontifying %s... (syntactically...)" (buffer-name)))
|
1995-08-10 13:57:18 +00:00
|
|
|
|
(let ((inhibit-read-only t) (buffer-undo-list t)
|
|
|
|
|
buffer-file-name buffer-file-truename
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(modified (buffer-modified-p))
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(old-syntax (syntax-table))
|
1995-03-02 10:57:07 +00:00
|
|
|
|
(synstart (if comment-start-skip
|
|
|
|
|
(concat "\\s\"\\|" comment-start-skip)
|
|
|
|
|
"\\s\""))
|
|
|
|
|
(comstart (if comment-start-skip
|
|
|
|
|
(concat "\\s<\\|" comment-start-skip)
|
|
|
|
|
"\\s<"))
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(startline (point))
|
|
|
|
|
state prev prevstate)
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Use the fontification syntax table, if any.
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(if font-lock-syntax-table
|
|
|
|
|
(set-syntax-table font-lock-syntax-table))
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Find the state at the `beginning-of-line' before `start'.
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(if (eq startline font-lock-cache-position)
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;; Use the cache for the state of `startline'.
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(setq state font-lock-cache-state)
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;; Find the state of `startline'.
|
|
|
|
|
(if (null font-lock-beginning-of-syntax-function)
|
|
|
|
|
;; Use the state at the previous cache position, if any, or
|
|
|
|
|
;; otherwise calculate from `point-min'.
|
|
|
|
|
(if (or (null font-lock-cache-position)
|
|
|
|
|
(< startline font-lock-cache-position))
|
|
|
|
|
(setq state (parse-partial-sexp
|
|
|
|
|
(point-min) startline))
|
|
|
|
|
(setq state (parse-partial-sexp
|
|
|
|
|
font-lock-cache-position startline
|
|
|
|
|
nil nil font-lock-cache-state)))
|
|
|
|
|
;; Call the function to move outside any syntactic block.
|
|
|
|
|
(funcall font-lock-beginning-of-syntax-function)
|
|
|
|
|
(setq state (parse-partial-sexp (point) startline)))
|
|
|
|
|
;; Cache the state and position of `startline'.
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(setq font-lock-cache-state state
|
1995-08-10 13:57:18 +00:00
|
|
|
|
font-lock-cache-position startline))
|
|
|
|
|
;;
|
|
|
|
|
;; Now find the state at `start' based on that of `startline'.
|
|
|
|
|
(setq state (parse-partial-sexp startline start nil nil state))
|
|
|
|
|
;;
|
1995-04-24 10:49:03 +00:00
|
|
|
|
;; If the region starts inside a string, show the extent of it.
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(if (nth 3 state)
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(let ((beg (point)))
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(while (and (re-search-forward "\\s\"" end 'move)
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(nth 3 (parse-partial-sexp beg (point) nil nil
|
1994-10-12 09:23:37 +00:00
|
|
|
|
state))))
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(put-text-property beg (point) 'face font-lock-string-face)
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(setq state (parse-partial-sexp beg (point)
|
|
|
|
|
nil nil state))))
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;;
|
1995-04-24 10:49:03 +00:00
|
|
|
|
;; Likewise for a comment.
|
|
|
|
|
(if (or (nth 4 state) (nth 7 state))
|
|
|
|
|
(let ((beg (point)))
|
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region (point-min) end)
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(progn
|
|
|
|
|
(re-search-backward comstart (point-min) 'move)
|
|
|
|
|
(forward-comment 1)
|
|
|
|
|
;; forward-comment skips all whitespace,
|
|
|
|
|
;; so go back to the real end of the comment.
|
|
|
|
|
(skip-chars-backward " \t"))
|
|
|
|
|
(error (goto-char end))))
|
|
|
|
|
(put-text-property beg (point) 'face
|
|
|
|
|
font-lock-comment-face)
|
|
|
|
|
(setq state (parse-partial-sexp beg (point)
|
|
|
|
|
nil nil state))))
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Find each interesting place between here and `end'.
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(while (and (< (point) end)
|
|
|
|
|
(setq prev (point) prevstate state)
|
|
|
|
|
(re-search-forward synstart end t)
|
|
|
|
|
(progn
|
|
|
|
|
;; Clear out the fonts of what we skip over.
|
|
|
|
|
(remove-text-properties prev (point) '(face nil))
|
|
|
|
|
;; Verify the state at that place
|
|
|
|
|
;; so we don't get fooled by \" or \;.
|
|
|
|
|
(setq state (parse-partial-sexp prev (point)
|
|
|
|
|
nil nil state))))
|
|
|
|
|
(let ((here (point)))
|
|
|
|
|
(if (or (nth 4 state) (nth 7 state))
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;;
|
1995-04-24 10:49:03 +00:00
|
|
|
|
;; We found a real comment start.
|
|
|
|
|
(let ((beg (match-beginning 0)))
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region (point-min) end)
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(progn
|
|
|
|
|
(forward-comment 1)
|
|
|
|
|
;; forward-comment skips all whitespace,
|
|
|
|
|
;; so go back to the real end of the comment.
|
|
|
|
|
(skip-chars-backward " \t"))
|
|
|
|
|
(error (goto-char end))))
|
|
|
|
|
(put-text-property beg (point) 'face
|
|
|
|
|
font-lock-comment-face)
|
|
|
|
|
(setq state (parse-partial-sexp here (point)
|
|
|
|
|
nil nil state)))
|
|
|
|
|
(if (nth 3 state)
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;;
|
|
|
|
|
;; We found a real string start.
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(let ((beg (match-beginning 0)))
|
|
|
|
|
(while (and (re-search-forward "\\s\"" end 'move)
|
|
|
|
|
(nth 3 (parse-partial-sexp
|
|
|
|
|
here (point) nil nil state))))
|
|
|
|
|
(put-text-property beg (point) 'face
|
|
|
|
|
font-lock-string-face)
|
|
|
|
|
(setq state (parse-partial-sexp here (point)
|
|
|
|
|
nil nil state))))))
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Make sure `prev' is non-nil after the loop
|
1995-04-24 10:49:03 +00:00
|
|
|
|
;; only if it was set on the very last iteration.
|
|
|
|
|
(setq prev nil)))
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Clean up.
|
1995-07-09 13:26:41 +00:00
|
|
|
|
(set-syntax-table old-syntax)
|
|
|
|
|
(and prev
|
|
|
|
|
(remove-text-properties prev end '(face nil)))
|
|
|
|
|
(and (buffer-modified-p)
|
|
|
|
|
(not modified)
|
|
|
|
|
(set-buffer-modified-p nil)))))))
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
|
|
|
|
(defun font-lock-unfontify-region (beg end)
|
1993-07-22 06:12:37 +00:00
|
|
|
|
(let ((modified (buffer-modified-p))
|
1995-08-10 13:57:18 +00:00
|
|
|
|
(buffer-undo-list t) (inhibit-read-only t)
|
|
|
|
|
buffer-file-name buffer-file-truename)
|
1993-07-22 06:12:37 +00:00
|
|
|
|
(remove-text-properties beg end '(face nil))
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(and (buffer-modified-p)
|
|
|
|
|
(not modified)
|
|
|
|
|
(set-buffer-modified-p nil))))
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
|
|
|
|
;; Called when any modification is made to buffer text.
|
|
|
|
|
(defun font-lock-after-change-function (beg end old-len)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(save-match-data
|
|
|
|
|
;; Discard the cache info if text before it has changed.
|
|
|
|
|
(and font-lock-cache-position
|
|
|
|
|
(> font-lock-cache-position beg)
|
|
|
|
|
(setq font-lock-cache-position nil))
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; Rescan between start of line from `beg' and start of line after `end'.
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(goto-char beg)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(setq beg (point))
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(goto-char end)
|
|
|
|
|
(forward-line 1)
|
|
|
|
|
(setq end (point))
|
1993-07-23 05:10:00 +00:00
|
|
|
|
;; First scan for strings and comments.
|
|
|
|
|
;; Must scan from line start in case of
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; inserting space into `intfoo () {}', and after widened.
|
1994-05-13 21:24:47 +00:00
|
|
|
|
(if font-lock-no-comments
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(font-lock-unfontify-region beg end)
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(font-lock-fontify-region beg end))
|
1995-03-02 10:57:07 +00:00
|
|
|
|
;; Now scan for keywords.
|
1994-12-05 13:38:11 +00:00
|
|
|
|
(font-lock-hack-keywords beg end))))
|
|
|
|
|
|
1995-04-24 10:49:03 +00:00
|
|
|
|
;; The following must be rethought, since keywords can override fontification.
|
1994-12-05 13:38:11 +00:00
|
|
|
|
; ;; Now scan for keywords, but not if we are inside a comment now.
|
|
|
|
|
; (or (and (not font-lock-no-comments)
|
|
|
|
|
; (let ((state (parse-partial-sexp beg end nil nil
|
|
|
|
|
; font-lock-cache-state)))
|
|
|
|
|
; (or (nth 4 state) (nth 7 state))))
|
|
|
|
|
; (font-lock-hack-keywords beg end))
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
|
|
|
|
;;; Fontifying arbitrary patterns
|
|
|
|
|
|
1995-06-01 09:08:29 +00:00
|
|
|
|
(defun font-lock-compile-keywords (&optional keywords)
|
1995-04-24 10:49:03 +00:00
|
|
|
|
;; Compile `font-lock-keywords' into the form (t KEYWORD ...) where KEYWORD
|
|
|
|
|
;; is the (MATCHER HIGHLIGHT ...) shown in the variable's doc string.
|
1995-06-01 09:08:29 +00:00
|
|
|
|
(let ((keywords (or keywords font-lock-keywords)))
|
|
|
|
|
(setq font-lock-keywords
|
|
|
|
|
(if (eq (car-safe keywords) t)
|
|
|
|
|
keywords
|
|
|
|
|
(cons t
|
|
|
|
|
(mapcar
|
|
|
|
|
(function (lambda (item)
|
|
|
|
|
(cond ((nlistp item)
|
|
|
|
|
(list item '(0 font-lock-keyword-face)))
|
|
|
|
|
((numberp (cdr item))
|
|
|
|
|
(list (car item) (list (cdr item) 'font-lock-keyword-face)))
|
|
|
|
|
((symbolp (cdr item))
|
|
|
|
|
(list (car item) (list 0 (cdr item))))
|
|
|
|
|
((nlistp (nth 1 item))
|
|
|
|
|
(list (car item) (cdr item)))
|
|
|
|
|
(t
|
|
|
|
|
item))))
|
|
|
|
|
keywords))))))
|
1995-04-24 10:49:03 +00:00
|
|
|
|
|
|
|
|
|
(defsubst font-lock-apply-highlight (highlight)
|
|
|
|
|
"Apply HIGHLIGHT following a match. See `font-lock-keywords'."
|
|
|
|
|
(let* ((match (nth 0 highlight))
|
|
|
|
|
(beg (match-beginning match)) (end (match-end match))
|
|
|
|
|
(override (nth 2 highlight)))
|
|
|
|
|
(cond ((not beg)
|
|
|
|
|
;; No match but we might not signal an error
|
|
|
|
|
(or (nth 3 highlight) (error "Highlight %S failed" highlight)))
|
|
|
|
|
((and (not override) (text-property-not-all beg end 'face nil))
|
|
|
|
|
;; Can't override and already fontified
|
|
|
|
|
nil)
|
|
|
|
|
((not (eq override 'keep))
|
|
|
|
|
;; Can override but need not keep existing fontification
|
|
|
|
|
(put-text-property beg end 'face (eval (nth 1 highlight))))
|
|
|
|
|
(t
|
|
|
|
|
;; Can override but must keep existing fontification
|
|
|
|
|
(let ((pos (text-property-any beg end 'face nil)) next
|
|
|
|
|
(face (eval (nth 1 highlight))))
|
|
|
|
|
(while pos
|
|
|
|
|
(setq next (next-single-property-change pos 'face nil end))
|
|
|
|
|
(put-text-property pos next 'face face)
|
|
|
|
|
(setq pos (text-property-any next end 'face nil))))))))
|
|
|
|
|
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(defun font-lock-hack-keywords (start end &optional loudly)
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
"Fontify according to `font-lock-keywords' between START and END."
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(let ((case-fold-search font-lock-keywords-case-fold-search)
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(keywords (cdr (if (eq (car-safe font-lock-keywords) t)
|
|
|
|
|
font-lock-keywords
|
|
|
|
|
(font-lock-compile-keywords))))
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(count 0)
|
1995-08-10 13:57:18 +00:00
|
|
|
|
(inhibit-read-only t) (buffer-undo-list t)
|
|
|
|
|
buffer-file-name buffer-file-truename
|
1993-07-22 06:12:37 +00:00
|
|
|
|
(modified (buffer-modified-p))
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(old-syntax (syntax-table))
|
|
|
|
|
(bufname (buffer-name)))
|
1994-08-05 05:11:30 +00:00
|
|
|
|
(unwind-protect
|
1995-08-10 13:57:18 +00:00
|
|
|
|
(let (keyword matcher highlights lowdarks)
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(if loudly (message "Fontifying %s... (regexps...)" bufname))
|
|
|
|
|
(if font-lock-syntax-table (set-syntax-table font-lock-syntax-table))
|
|
|
|
|
(while keywords
|
|
|
|
|
(setq keyword (car keywords) keywords (cdr keywords)
|
1995-04-24 10:49:03 +00:00
|
|
|
|
matcher (car keyword) highlights (cdr keyword))
|
1994-08-05 05:11:30 +00:00
|
|
|
|
(goto-char start)
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(while (if (stringp matcher)
|
|
|
|
|
(re-search-forward matcher end t)
|
|
|
|
|
(funcall matcher end))
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;; An explicit `while' loop is slightly faster than a `mapcar'.
|
|
|
|
|
;(mapcar 'font-lock-apply-highlight highlights)
|
|
|
|
|
(setq lowdarks highlights)
|
|
|
|
|
(while lowdarks
|
|
|
|
|
(font-lock-apply-highlight (car lowdarks))
|
|
|
|
|
(setq lowdarks (cdr lowdarks))))
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(if loudly (message "Fontifying %s... (regexps...%s)" bufname
|
1994-08-05 05:11:30 +00:00
|
|
|
|
(make-string (setq count (1+ count)) ?.)))))
|
1995-07-09 13:26:41 +00:00
|
|
|
|
(set-syntax-table old-syntax)
|
|
|
|
|
(and (buffer-modified-p)
|
|
|
|
|
(not modified)
|
|
|
|
|
(set-buffer-modified-p nil)))))
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
|
|
|
|
;; The user level functions
|
|
|
|
|
|
|
|
|
|
(defvar font-lock-mode nil) ; for modeline
|
|
|
|
|
|
|
|
|
|
(defvar font-lock-fontified nil) ; whether we have hacked this buffer
|
|
|
|
|
(put 'font-lock-fontified 'permanent-local t)
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun font-lock-mode (&optional arg)
|
|
|
|
|
"Toggle Font Lock mode.
|
|
|
|
|
With arg, turn Font Lock mode on if and only if arg is positive.
|
|
|
|
|
|
|
|
|
|
When Font Lock mode is enabled, text is fontified as you type it:
|
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
- Comments are displayed in `font-lock-comment-face';
|
|
|
|
|
- Strings are displayed in `font-lock-string-face';
|
|
|
|
|
- Certain other expressions are displayed in other faces according to the
|
|
|
|
|
value of the variable `font-lock-keywords'.
|
|
|
|
|
|
|
|
|
|
You can enable Font Lock mode in any major mode automatically by turning on in
|
|
|
|
|
the major mode's hook. For example, put in your ~/.emacs:
|
|
|
|
|
|
|
|
|
|
(add-hook 'c-mode-hook 'turn-on-font-lock)
|
|
|
|
|
|
|
|
|
|
Or for any visited file with the following in your ~/.emacs:
|
|
|
|
|
|
|
|
|
|
(add-hook 'find-file-hooks 'turn-on-font-lock)
|
|
|
|
|
|
|
|
|
|
The default Font Lock mode faces and their attributes are defined in the
|
|
|
|
|
variable `font-lock-face-attributes', and Font Lock mode default settings in
|
|
|
|
|
the variable `font-lock-defaults-alist'.
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
1995-04-24 10:49:03 +00:00
|
|
|
|
Where modes support different levels of fontification, you can use the variable
|
1995-06-26 11:55:25 +00:00
|
|
|
|
`font-lock-maximum-decoration' to specify which level you generally prefer.
|
1994-10-12 09:23:37 +00:00
|
|
|
|
When you turn Font Lock mode on/off the buffer is fontified/defontified, though
|
|
|
|
|
fontification occurs only if the buffer is less than `font-lock-maximum-size'.
|
|
|
|
|
To fontify a buffer without turning on Font Lock mode, and regardless of buffer
|
|
|
|
|
size, you can use \\[font-lock-fontify-buffer]."
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(interactive "P")
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(let ((on-p (if arg (> (prefix-numeric-value arg) 0) (not font-lock-mode))))
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(if (equal (buffer-name) " *Compiler Input*") ; hack for bytecomp...
|
|
|
|
|
(setq on-p nil))
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(if (not on-p)
|
|
|
|
|
(remove-hook 'after-change-functions 'font-lock-after-change-function)
|
|
|
|
|
(make-local-variable 'after-change-functions)
|
|
|
|
|
(add-hook 'after-change-functions 'font-lock-after-change-function))
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(set (make-local-variable 'font-lock-mode) on-p)
|
|
|
|
|
(cond (on-p
|
|
|
|
|
(font-lock-set-defaults)
|
1994-02-01 01:32:48 +00:00
|
|
|
|
(make-local-variable 'before-revert-hook)
|
1994-01-18 19:23:14 +00:00
|
|
|
|
(make-local-variable 'after-revert-hook)
|
1994-02-01 01:32:48 +00:00
|
|
|
|
;; If buffer is reverted, must clean up the state.
|
|
|
|
|
(add-hook 'before-revert-hook 'font-lock-revert-setup)
|
|
|
|
|
(add-hook 'after-revert-hook 'font-lock-revert-cleanup)
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(run-hooks 'font-lock-mode-hook)
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(cond (font-lock-fontified
|
|
|
|
|
nil)
|
|
|
|
|
((or (null font-lock-maximum-size)
|
|
|
|
|
(> font-lock-maximum-size (buffer-size)))
|
|
|
|
|
(font-lock-fontify-buffer))
|
|
|
|
|
(font-lock-verbose
|
|
|
|
|
(message "Fontifying %s... buffer too big." (buffer-name)))))
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(font-lock-fontified
|
|
|
|
|
(setq font-lock-fontified nil)
|
1994-02-01 01:32:48 +00:00
|
|
|
|
(remove-hook 'before-revert-hook 'font-lock-revert-setup)
|
|
|
|
|
(remove-hook 'after-revert-hook 'font-lock-revert-cleanup)
|
1995-03-02 10:57:07 +00:00
|
|
|
|
(font-lock-unfontify-region (point-min) (point-max))
|
|
|
|
|
(font-lock-thing-lock-cleanup))
|
|
|
|
|
(t
|
1995-05-29 06:59:49 +00:00
|
|
|
|
(remove-hook 'before-revert-hook 'font-lock-revert-setup)
|
|
|
|
|
(remove-hook 'after-revert-hook 'font-lock-revert-cleanup)
|
1995-03-02 10:57:07 +00:00
|
|
|
|
(font-lock-thing-lock-cleanup)))
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(force-mode-line-update)))
|
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun turn-on-font-lock ()
|
|
|
|
|
"Unconditionally turn on Font Lock mode."
|
|
|
|
|
(font-lock-mode 1))
|
|
|
|
|
|
1995-07-09 13:26:41 +00:00
|
|
|
|
;; Turn off other related packages if they're on. I prefer a hook. --sm.
|
1995-05-29 06:59:49 +00:00
|
|
|
|
;; These explicit calls are easier to understand
|
|
|
|
|
;; because people know what they will do.
|
1995-07-09 13:26:41 +00:00
|
|
|
|
;; A hook is a mystery because it might do anything whatever. --rms.
|
1995-03-02 10:57:07 +00:00
|
|
|
|
(defun font-lock-thing-lock-cleanup ()
|
|
|
|
|
(cond ((and (boundp 'fast-lock-mode) fast-lock-mode)
|
|
|
|
|
(fast-lock-mode -1))
|
|
|
|
|
((and (boundp 'lazy-lock-mode) lazy-lock-mode)
|
|
|
|
|
(lazy-lock-mode -1))))
|
|
|
|
|
|
1995-04-24 10:49:03 +00:00
|
|
|
|
;; Do something special for these packages after fontifying. I prefer a hook.
|
|
|
|
|
(defun font-lock-after-fontify-buffer ()
|
|
|
|
|
(cond ((and (boundp 'fast-lock-mode) fast-lock-mode)
|
|
|
|
|
(fast-lock-after-fontify-buffer))
|
|
|
|
|
((and (boundp 'lazy-lock-mode) lazy-lock-mode)
|
|
|
|
|
(lazy-lock-after-fontify-buffer))))
|
|
|
|
|
|
1995-05-29 06:59:49 +00:00
|
|
|
|
;; If the buffer is about to be reverted, it won't be fontified afterward.
|
1994-02-01 01:32:48 +00:00
|
|
|
|
(defun font-lock-revert-setup ()
|
|
|
|
|
(setq font-lock-fontified nil))
|
|
|
|
|
|
1995-05-29 06:59:49 +00:00
|
|
|
|
;; If the buffer has just been reverted, normally that turns off
|
|
|
|
|
;; Font Lock mode. So turn the mode back on if necessary.
|
1994-02-01 01:32:48 +00:00
|
|
|
|
(defun font-lock-revert-cleanup ()
|
1995-05-29 06:59:49 +00:00
|
|
|
|
(font-lock-mode 1))
|
1994-02-01 01:32:48 +00:00
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;;;###autoload
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(defun font-lock-fontify-buffer ()
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
"Fontify the current buffer the way `font-lock-mode' would."
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(let ((was-on font-lock-mode)
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(verbose (and (or font-lock-verbose (interactive-p))
|
|
|
|
|
(not (zerop (buffer-size)))))
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(modified (buffer-modified-p)))
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(set (make-local-variable 'font-lock-fontified) nil)
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(if verbose (message "Fontifying %s..." (buffer-name)))
|
1994-10-12 09:23:37 +00:00
|
|
|
|
;; Turn it on to run hooks and get the right `font-lock-keywords' etc.
|
1993-10-26 20:46:34 +00:00
|
|
|
|
(or was-on (font-lock-set-defaults))
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(condition-case nil
|
|
|
|
|
(save-excursion
|
1995-03-02 10:57:07 +00:00
|
|
|
|
(if font-lock-no-comments
|
|
|
|
|
(font-lock-unfontify-region (point-min) (point-max))
|
|
|
|
|
(font-lock-fontify-region (point-min) (point-max) verbose))
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(font-lock-hack-keywords (point-min) (point-max) verbose)
|
|
|
|
|
(setq font-lock-fontified t))
|
|
|
|
|
;; We don't restore the old fontification, so it's best to unfontify.
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(quit (font-lock-unfontify-region (point-min) (point-max))))
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(if verbose (message "Fontifying %s... %s." (buffer-name)
|
|
|
|
|
(if font-lock-fontified "done" "aborted")))
|
|
|
|
|
(and (buffer-modified-p)
|
|
|
|
|
(not modified)
|
1995-03-02 10:57:07 +00:00
|
|
|
|
(set-buffer-modified-p nil))
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(font-lock-after-fontify-buffer)))
|
1995-08-10 13:57:18 +00:00
|
|
|
|
|
|
|
|
|
(defun font-lock-choose-keywords (keywords level)
|
|
|
|
|
;; Return LEVELth element of KEYWORDS. A LEVEL of nil is equal to a
|
|
|
|
|
;; LEVEL of 0, a LEVEL of t is equal to (1- (length KEYWORDS)).
|
|
|
|
|
(cond ((symbolp keywords)
|
|
|
|
|
keywords)
|
|
|
|
|
((numberp level)
|
|
|
|
|
(or (nth level keywords) (car (reverse keywords))))
|
|
|
|
|
((eq level t)
|
|
|
|
|
(car (reverse keywords)))
|
|
|
|
|
(t
|
|
|
|
|
(car keywords))))
|
|
|
|
|
|
|
|
|
|
(defun font-lock-set-defaults ()
|
|
|
|
|
"Set fontification defaults appropriately for this mode.
|
|
|
|
|
Sets `font-lock-keywords', `font-lock-no-comments', `font-lock-syntax-table'
|
|
|
|
|
and `font-lock-keywords-case-fold-search' using `font-lock-defaults' (or, if
|
|
|
|
|
nil, using `font-lock-defaults-alist') and `font-lock-maximum-decoration'."
|
|
|
|
|
;; Set face defaults.
|
|
|
|
|
(font-lock-make-faces)
|
|
|
|
|
;; Set fontification defaults.
|
|
|
|
|
(or font-lock-keywords
|
|
|
|
|
(let ((defaults (or font-lock-defaults
|
|
|
|
|
(cdr (assq major-mode font-lock-defaults-alist)))))
|
|
|
|
|
;; Keywords?
|
|
|
|
|
(setq font-lock-keywords
|
|
|
|
|
(font-lock-compile-keywords
|
|
|
|
|
(eval (font-lock-choose-keywords (nth 0 defaults)
|
|
|
|
|
font-lock-maximum-decoration))))
|
|
|
|
|
;; Syntactic?
|
|
|
|
|
(if (nth 1 defaults)
|
|
|
|
|
(set (make-local-variable 'font-lock-no-comments) t))
|
|
|
|
|
;; Case fold?
|
|
|
|
|
(if (nth 2 defaults)
|
|
|
|
|
(set (make-local-variable 'font-lock-keywords-case-fold-search) t))
|
|
|
|
|
;; Syntax table?
|
|
|
|
|
(if (nth 3 defaults)
|
|
|
|
|
(let ((slist (nth 3 defaults)))
|
|
|
|
|
(set (make-local-variable 'font-lock-syntax-table)
|
|
|
|
|
(copy-syntax-table (syntax-table)))
|
|
|
|
|
(while slist
|
|
|
|
|
(modify-syntax-entry (car (car slist)) (cdr (car slist))
|
|
|
|
|
font-lock-syntax-table)
|
|
|
|
|
(setq slist (cdr slist)))))
|
|
|
|
|
;; Syntactic cache function?
|
|
|
|
|
(if (nth 4 defaults)
|
|
|
|
|
(set (make-local-variable 'font-lock-beginning-of-syntax-function)
|
|
|
|
|
(nth 4 defaults))))))
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;;; Various information shared by several modes.
|
|
|
|
|
;;; Information specific to a single mode should go in its load library.
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
|
|
|
|
(defconst lisp-font-lock-keywords-1
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(list
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;; Everything not a variable or type declaration is fontified as a function.
|
|
|
|
|
;; It would be cleaner to allow preceding whitespace, but it would also be
|
|
|
|
|
;; about five times slower.
|
|
|
|
|
(list (concat "^(\\(def\\("
|
|
|
|
|
;; Variable declarations.
|
|
|
|
|
"\\(const\\(\\|ant\\)\\|ine-key\\(\\|-after\\)\\|var\\)\\|"
|
|
|
|
|
;; Structure declarations.
|
|
|
|
|
"\\(class\\|struct\\|type\\)\\|"
|
|
|
|
|
;; Everything else is a function declaration.
|
|
|
|
|
"\\([^ \t\n\(\)]+\\)"
|
|
|
|
|
"\\)\\)\\>"
|
|
|
|
|
;; Any whitespace and declared object.
|
|
|
|
|
"[ \t'\(]*"
|
|
|
|
|
"\\([^ \t\n\)]+\\)?")
|
|
|
|
|
'(1 font-lock-keyword-face)
|
|
|
|
|
'(8 (cond ((match-beginning 3) font-lock-variable-name-face)
|
|
|
|
|
((match-beginning 6) font-lock-type-face)
|
|
|
|
|
(t font-lock-function-name-face))
|
|
|
|
|
nil t)))
|
1995-06-26 11:55:25 +00:00
|
|
|
|
"Subdued level highlighting Lisp modes.")
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
|
|
|
|
(defconst lisp-font-lock-keywords-2
|
1995-03-02 10:57:07 +00:00
|
|
|
|
(append lisp-font-lock-keywords-1
|
|
|
|
|
(let ((word-char "[-+a-zA-Z0-9_:*]"))
|
|
|
|
|
(list
|
|
|
|
|
;;
|
1995-07-09 13:26:41 +00:00
|
|
|
|
;; Control structures. ELisp and CLisp combined.
|
1995-08-10 13:57:18 +00:00
|
|
|
|
; (make-regexp
|
|
|
|
|
; '("cond" "if" "while" "let\\*?" "prog[nv12*]?" "catch" "throw"
|
|
|
|
|
; "save-restriction" "save-excursion" "save-window-excursion"
|
|
|
|
|
; "save-selected-window" "save-match-data" "unwind-protect"
|
|
|
|
|
; "condition-case" "track-mouse"
|
|
|
|
|
; "eval-after-load" "eval-and-compile" "eval-when-compile"
|
|
|
|
|
; "when" "unless" "do" "flet" "labels" "return" "return-from"))
|
1995-03-02 10:57:07 +00:00
|
|
|
|
(cons
|
|
|
|
|
(concat
|
|
|
|
|
"(\\("
|
1995-08-10 13:57:18 +00:00
|
|
|
|
"\\(c\\(atch\\|ond\\(\\|ition-case\\)\\)\\|do\\|"
|
|
|
|
|
"eval-\\(a\\(fter-load\\|nd-compile\\)\\|when-compile\\)\\|flet\\|"
|
|
|
|
|
"if\\|l\\(abels\\|et\\*?\\)\\|prog[nv12*]?\\|return\\(\\|-from\\)\\|"
|
|
|
|
|
"save-\\(excursion\\|match-data\\|restriction\\|selected-window\\|"
|
|
|
|
|
"window-excursion\\)\\|t\\(hrow\\|rack-mouse\\)\\|"
|
|
|
|
|
"un\\(less\\|wind-protect\\)\\|wh\\(en\\|ile\\)\\)"
|
1995-03-02 10:57:07 +00:00
|
|
|
|
"\\)\\>") 1)
|
|
|
|
|
;;
|
|
|
|
|
;; Function names in emacs-lisp docstrings (in the syntax that
|
|
|
|
|
;; `substitute-command-keys' understands).
|
1995-04-24 10:49:03 +00:00
|
|
|
|
(list (concat "\\\\\\\\\\[\\(" word-char "+\\)]")
|
|
|
|
|
1 font-lock-reference-face t)
|
1995-03-02 10:57:07 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Words inside `' which tend to be symbol names.
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(list (concat "`\\(" word-char word-char "+\\)'")
|
1995-03-02 10:57:07 +00:00
|
|
|
|
1 'font-lock-reference-face t)
|
|
|
|
|
;;
|
1995-07-09 13:26:41 +00:00
|
|
|
|
;; CLisp `:' keywords as references.
|
|
|
|
|
(list (concat "\\<:" word-char "+\\>") 0 font-lock-reference-face t)
|
|
|
|
|
;;
|
|
|
|
|
;; ELisp and CLisp `&' keywords as types.
|
1995-03-02 10:57:07 +00:00
|
|
|
|
'("\\&\\(optional\\|rest\\|whole\\)\\>" . font-lock-type-face)
|
|
|
|
|
)))
|
1995-06-26 11:55:25 +00:00
|
|
|
|
"Gaudy level highlighting for Lisp modes.")
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
1995-06-26 11:55:25 +00:00
|
|
|
|
(defvar lisp-font-lock-keywords lisp-font-lock-keywords-1
|
|
|
|
|
"Default expressions to highlight in Lisp modes.")
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
|
|
|
|
|
1995-08-10 13:57:18 +00:00
|
|
|
|
(defvar scheme-font-lock-keywords
|
|
|
|
|
(list
|
|
|
|
|
;;
|
|
|
|
|
;; Declarations.
|
|
|
|
|
'("^[ \t]*(\\(define\\)\\>[ \t]*(?\\([^ \t\n\)]+\\)?"
|
|
|
|
|
(1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
|
|
|
|
|
;;
|
|
|
|
|
;; Control structures.
|
|
|
|
|
;(make-regexp '("begin" "call-with-current-continuation" "call/cc"
|
|
|
|
|
; "call-with-input-file" "call-with-output-file" "case" "cond"
|
|
|
|
|
; "define-syntax" "do" "else" "for-each" "if" "lambda"
|
|
|
|
|
; "let-syntax" "let\\*?" "letrec" "letrec-syntax"
|
|
|
|
|
; ;; Stefan Monnier <stefan.monnier@epfl.ch> says don't bother.
|
|
|
|
|
; ;;"quasiquote" "quote" "unquote" "unquote-splicing"
|
|
|
|
|
; "map" "syntax" "syntax-rules"))
|
|
|
|
|
(cons
|
|
|
|
|
(concat "(\\("
|
|
|
|
|
"begin\\|c\\(a\\(ll\\(-with-\\(current-continuation\\|"
|
|
|
|
|
"input-file\\|output-file\\)\\|/cc\\)\\|se\\)\\|ond\\)\\|"
|
|
|
|
|
"d\\(efine-syntax\\|o\\)\\|else\\|for-each\\|if\\|"
|
|
|
|
|
"l\\(ambda\\|et\\(-syntax\\|\\*?\\|rec\\(\\|-syntax\\)\\)\\)\\|"
|
|
|
|
|
"map\\|syntax\\(\\|-rules\\)"
|
|
|
|
|
"\\)\\>") 1))
|
|
|
|
|
"Default expressions to highlight in Scheme modes.")
|
|
|
|
|
|
|
|
|
|
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(defconst c-font-lock-keywords-1 nil
|
1995-06-26 11:55:25 +00:00
|
|
|
|
"Subdued level highlighting for C modes.")
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
|
|
|
|
(defconst c-font-lock-keywords-2 nil
|
1995-06-26 11:55:25 +00:00
|
|
|
|
"Gaudy level highlighting for C modes.")
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
1994-03-05 23:32:27 +00:00
|
|
|
|
(defconst c++-font-lock-keywords-1 nil
|
1995-06-26 11:55:25 +00:00
|
|
|
|
"Subdued level highlighting for C++ modes.")
|
1994-03-05 23:32:27 +00:00
|
|
|
|
|
|
|
|
|
(defconst c++-font-lock-keywords-2 nil
|
1995-06-26 11:55:25 +00:00
|
|
|
|
"Gaudy level highlighting for C++ modes.")
|
1994-03-05 23:32:27 +00:00
|
|
|
|
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(let ((c-keywords
|
|
|
|
|
; ("break" "continue" "do" "else" "for" "if" "return" "switch" "while")
|
|
|
|
|
"break\\|continue\\|do\\|else\\|for\\|if\\|return\\|switch\\|while")
|
|
|
|
|
(c-type-types
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum"
|
|
|
|
|
; "signed" "unsigned" "short" "long" "int" "char" "float" "double"
|
1994-10-12 09:23:37 +00:00
|
|
|
|
; "void" "volatile" "const")
|
|
|
|
|
(concat "auto\\|c\\(har\\|onst\\)\\|double\\|e\\(num\\|xtern\\)\\|"
|
|
|
|
|
"float\\|int\\|long\\|register\\|"
|
|
|
|
|
"s\\(hort\\|igned\\|t\\(atic\\|ruct\\)\\)\\|typedef\\|"
|
|
|
|
|
"un\\(ion\\|signed\\)\\|vo\\(id\\|latile\\)")) ; 6 ()s deep.
|
|
|
|
|
(c++-keywords
|
|
|
|
|
; ("break" "continue" "do" "else" "for" "if" "return" "switch" "while"
|
|
|
|
|
; "asm" "catch" "delete" "new" "operator" "sizeof" "this" "throw" "try"
|
|
|
|
|
; "protected" "private" "public")
|
|
|
|
|
(concat "asm\\|break\\|c\\(atch\\|ontinue\\)\\|d\\(elete\\|o\\)\\|"
|
|
|
|
|
"else\\|for\\|if\\|new\\|operator\\|"
|
|
|
|
|
"p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\|return\\|"
|
|
|
|
|
"s\\(izeof\\|witch\\)\\|t\\(h\\(is\\|row\\)\\|ry\\)\\|while"))
|
|
|
|
|
(c++-type-types
|
|
|
|
|
; ("auto" "extern" "register" "static" "typedef" "struct" "union" "enum"
|
|
|
|
|
; "signed" "unsigned" "short" "long" "int" "char" "float" "double"
|
|
|
|
|
; "void" "volatile" "const" "class" "inline" "friend" "bool"
|
|
|
|
|
; "virtual" "complex" "template")
|
|
|
|
|
(concat "auto\\|bool\\|c\\(har\\|lass\\|o\\(mplex\\|nst\\)\\)\\|"
|
|
|
|
|
"double\\|e\\(num\\|xtern\\)\\|f\\(loat\\|riend\\)\\|"
|
|
|
|
|
"in\\(line\\|t\\)\\|long\\|register\\|"
|
|
|
|
|
"s\\(hort\\|igned\\|t\\(atic\\|ruct\\)\\)\\|"
|
|
|
|
|
"t\\(emplate\\|ypedef\\)\\|un\\(ion\\|signed\\)\\|"
|
|
|
|
|
"v\\(irtual\\|o\\(id\\|latile\\)\\)")) ; 11 ()s deep.
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(ctoken "[a-zA-Z0-9_:~]+"))
|
1994-02-26 00:14:42 +00:00
|
|
|
|
(setq c-font-lock-keywords-1
|
|
|
|
|
(list
|
|
|
|
|
;;
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; Fontify filenames in #include <...> preprocessor directives.
|
1994-02-26 00:14:42 +00:00
|
|
|
|
'("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
|
|
|
|
|
;;
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; Fontify function macro names.
|
|
|
|
|
'("^#[ \t]*define[ \t]+\\(\\(\\sw+\\)(\\)" 2 font-lock-function-name-face)
|
1994-02-26 00:14:42 +00:00
|
|
|
|
;;
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; Fontify otherwise as symbol names, and the preprocessor directive names.
|
|
|
|
|
'("^\\(#[ \t]*[a-z]+\\)\\>[ \t]*\\(\\sw+\\)?"
|
|
|
|
|
(1 font-lock-reference-face) (2 font-lock-variable-name-face nil t))
|
1994-02-26 00:14:42 +00:00
|
|
|
|
;;
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; Fontify function name definitions (without type on line).
|
|
|
|
|
(list (concat "^\\(" ctoken "\\)[ \t]*(") 1 'font-lock-function-name-face)
|
1994-02-26 00:14:42 +00:00
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
(setq c-font-lock-keywords-2
|
|
|
|
|
(append c-font-lock-keywords-1
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(list
|
|
|
|
|
;;
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; Fontify all storage classes and type specifiers (before declarations).
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(cons (concat "\\<\\(" c-type-types "\\)\\>") 'font-lock-type-face)
|
1993-07-09 20:27:43 +00:00
|
|
|
|
;;
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; Fontify variable/structure name declarations and definitions, or
|
|
|
|
|
;; function name declarations (plus definitions with type on same line).
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(list (concat "\\<\\(" c-type-types "\\)[ \t*]+"
|
|
|
|
|
"\\(" ctoken "[ \t*]+\\)*"
|
|
|
|
|
"\\(" ctoken "\\)[ \t]*\\((\\)?")
|
|
|
|
|
9
|
|
|
|
|
'(if (match-beginning 10)
|
|
|
|
|
font-lock-function-name-face
|
|
|
|
|
font-lock-variable-name-face))
|
|
|
|
|
;;
|
|
|
|
|
;; Fontify function/variable name declarations at the start of the line.
|
|
|
|
|
;; (Not everyone follows the GNU convention of function name at the start.)
|
|
|
|
|
(list (concat "^" ctoken "[ \t*]+"
|
|
|
|
|
"\\(" ctoken "[ \t*]+\\)*"
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
"\\(" ctoken "\\)[ \t]*\\((\\)?")
|
1994-10-12 09:23:37 +00:00
|
|
|
|
2
|
|
|
|
|
'(if (match-beginning 3)
|
|
|
|
|
font-lock-function-name-face
|
|
|
|
|
font-lock-variable-name-face))
|
1993-07-09 20:27:43 +00:00
|
|
|
|
;;
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; Fontify variable names declared with structures, or typedef names.
|
1994-10-12 09:23:37 +00:00
|
|
|
|
'("}[ \t*]*\\(\\sw+\\)[ \t]*[;,[]" 1 font-lock-variable-name-face)
|
1993-07-09 20:27:43 +00:00
|
|
|
|
;;
|
1994-10-12 09:23:37 +00:00
|
|
|
|
;; Fontify all builtin keywords (except case, default and goto; see below).
|
|
|
|
|
(concat "\\<\\(" c-keywords "\\)\\>")
|
1993-07-09 20:27:43 +00:00
|
|
|
|
;;
|
1994-10-12 09:23:37 +00:00
|
|
|
|
;; Fontify case/goto keywords and targets, and goto tags (incl "default:").
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
'("\\<\\(case\\|goto\\)\\>[ \t]*\\([^ \t\n:;]+\\)?"
|
|
|
|
|
(1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
|
|
|
|
|
'("^[ \t]*\\(\\sw+\\)[ \t]*:" 1 font-lock-reference-face)
|
1994-02-26 00:14:42 +00:00
|
|
|
|
)))
|
1994-03-05 23:32:27 +00:00
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(setq c++-font-lock-keywords-1 c-font-lock-keywords-1)
|
1994-03-05 23:32:27 +00:00
|
|
|
|
(setq c++-font-lock-keywords-2
|
1994-10-12 09:23:37 +00:00
|
|
|
|
(append c++-font-lock-keywords-1
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
(list
|
1994-10-12 09:23:37 +00:00
|
|
|
|
;; We don't just add to the C keywords for subtle differences and speed.
|
|
|
|
|
;; See the above comments for `c-font-lock-keywords-2'.
|
|
|
|
|
(cons (concat "\\<\\(" c++-type-types "\\)\\>") 'font-lock-type-face)
|
|
|
|
|
(list (concat "\\<\\(" c++-type-types "\\)[ \t*&]+"
|
|
|
|
|
"\\(" ctoken "[ \t*&]+\\)*"
|
1995-08-10 13:57:18 +00:00
|
|
|
|
"\\(" ctoken "\\)[ \t<>=!+-]*\\((\\)?")
|
1994-10-12 09:23:37 +00:00
|
|
|
|
14
|
|
|
|
|
'(if (match-beginning 15)
|
|
|
|
|
font-lock-function-name-face
|
|
|
|
|
font-lock-variable-name-face))
|
|
|
|
|
(list (concat "^" ctoken "[ \t*]+"
|
|
|
|
|
"\\(" ctoken "[ \t*]+\\)*"
|
1995-08-10 13:57:18 +00:00
|
|
|
|
"\\(" ctoken "\\)[ \t<>=!+-]*\\((\\)?")
|
1994-10-12 09:23:37 +00:00
|
|
|
|
2
|
|
|
|
|
'(if (match-beginning 3)
|
|
|
|
|
font-lock-function-name-face
|
|
|
|
|
font-lock-variable-name-face))
|
|
|
|
|
'("}[ \t*]*\\(\\sw+\\)[ \t]*[;,[]" 1 font-lock-variable-name-face)
|
|
|
|
|
(concat "\\<\\(" c++-keywords "\\)\\>")
|
|
|
|
|
'("\\<\\(case\\|goto\\)\\>[ \t]*\\([^ \t\n:;]+\\)?"
|
|
|
|
|
(1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
|
|
|
|
|
'("^[ \t]*\\(\\sw+\\)[ \t]*:[^:]" 1 font-lock-reference-face))))
|
1994-02-26 00:14:42 +00:00
|
|
|
|
)
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
1995-06-26 11:55:25 +00:00
|
|
|
|
(defvar c-font-lock-keywords c-font-lock-keywords-1
|
|
|
|
|
"Default expressions to highlight in C mode.")
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
1995-06-26 11:55:25 +00:00
|
|
|
|
(defvar c++-font-lock-keywords c++-font-lock-keywords-1
|
|
|
|
|
"Default expressions to highlight in C++ mode.")
|
1993-07-09 20:27:43 +00:00
|
|
|
|
|
1995-08-10 13:57:18 +00:00
|
|
|
|
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(defvar tex-font-lock-keywords
|
1995-08-10 13:57:18 +00:00
|
|
|
|
; ;; Regexps updated with help from Ulrik Dickow <dickow@nbi.dk>.
|
|
|
|
|
; '(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}"
|
|
|
|
|
; 2 font-lock-function-name-face)
|
|
|
|
|
; ("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}"
|
|
|
|
|
; 2 font-lock-reference-face)
|
|
|
|
|
; ;; It seems a bit dubious to use `bold' and `italic' faces since we might
|
|
|
|
|
; ;; not be able to display those fonts.
|
|
|
|
|
; ("{\\\\bf\\([^}]+\\)}" 1 'bold keep)
|
|
|
|
|
; ("{\\\\\\(em\\|it\\|sl\\)\\([^}]+\\)}" 2 'italic keep)
|
|
|
|
|
; ("\\\\\\([a-zA-Z@]+\\|.\\)" . font-lock-keyword-face)
|
|
|
|
|
; ("^[ \t\n]*\\\\def[\\\\@]\\(\\w+\\)" 1 font-lock-function-name-face keep))
|
|
|
|
|
;; Rewritten and extended for LaTeX2e by Ulrik Dickow <dickow@nbi.dk>.
|
1995-04-24 10:49:03 +00:00
|
|
|
|
'(("\\\\\\(begin\\|end\\|newcommand\\){\\([a-zA-Z0-9\\*]+\\)}"
|
|
|
|
|
2 font-lock-function-name-face)
|
|
|
|
|
("\\\\\\(cite\\|label\\|pageref\\|ref\\){\\([^} \t\n]+\\)}"
|
|
|
|
|
2 font-lock-reference-face)
|
1995-08-10 13:57:18 +00:00
|
|
|
|
("^[ \t]*\\\\def\\\\\\(\\(\\w\\|@\\)+\\)" 1 font-lock-function-name-face)
|
|
|
|
|
("\\\\\\([a-zA-Z@]+\\|.\\)" . font-lock-keyword-face)
|
1995-04-24 10:49:03 +00:00
|
|
|
|
;; It seems a bit dubious to use `bold' and `italic' faces since we might
|
|
|
|
|
;; not be able to display those fonts.
|
1995-08-10 13:57:18 +00:00
|
|
|
|
;; LaTeX2e: \emph{This is emphasized}.
|
|
|
|
|
("\\\\emph{\\([^}]+\\)}" 1 'italic keep)
|
|
|
|
|
;; LaTeX2e: \textbf{This is bold}, \textit{...}, \textsl{...}
|
|
|
|
|
("\\\\text\\(\\(bf\\)\\|it\\|sl\\){\\([^}]+\\)}"
|
|
|
|
|
3 (if (match-beginning 2) 'bold 'italic) keep)
|
|
|
|
|
;; Old-style bf/em/it/sl. Stop at `\\' and un-escaped `&', for good tables.
|
|
|
|
|
("\\\\\\(\\(bf\\)\\|em\\|it\\|sl\\)\\>\\(\\([^}&\\]\\|\\\\[^\\]\\)+\\)"
|
|
|
|
|
3 (if (match-beginning 2) 'bold 'italic) keep))
|
|
|
|
|
"Additional expressions to highlight in TeX modes.")
|
|
|
|
|
|
(compilation-mode-font-lock-keywords,
rmail-summary-font-lock-keywords, dired-font-lock-keywords,
shell-font-lock-keywords, texi-font-lock-keywords,
perl-font-lock-keywords): Deleted.
(font-lock-mode): Doc fix; use add/remove-hook, not
setq; removed make-local-variable of font-lock-no-comments.
(font-lock-set-defaults): Do it there, and use:
(font-lock-defaults-alist): Use it to set font-lock-keywords,
font-lock-keywords-case-fold-search and font-lock-no-comments.
(turn-on-font-lock): New function.
(font-lock-fontify-buffer): Made interruptible; deleted messages.
(font-lock-fontify-region): Made syntax state reliable
by widening within new restriction; let cstart and cend for speed;
outputs message.
(font-lock-after-change-function): Remove spurious goto-char and use
forward-line, not 1+ end-of-line, for end of fontification region.
(font-lock-any-properties-p): Removed, use text-property-not-all.
(font-lock-*-face): facename values are themselves.
(font-lock-variable-name-face, font-lock-reference-face): New vars.
(font-lock-doc-string-face): Removed.
(font-lock-keywords): Extended value syntax.
(font-lock-hack-keywords): Cope with it; outputs initial message.
Merged in face-lock.el:
(font-lock-display-type, font-lock-background-mode)
(font-lock-face-attributes): New variables, use it.
(font-lock-make-face): New function, use them.
1994-10-07 10:23:26 +00:00
|
|
|
|
;; Install ourselves:
|
|
|
|
|
|
|
|
|
|
(or (assq 'font-lock-mode minor-mode-alist)
|
|
|
|
|
(setq minor-mode-alist (cons '(font-lock-mode " Font") minor-mode-alist)))
|
|
|
|
|
|
|
|
|
|
;; Provide ourselves:
|
1994-05-13 21:24:47 +00:00
|
|
|
|
|
1993-07-09 20:27:43 +00:00
|
|
|
|
(provide 'font-lock)
|
|
|
|
|
|
|
|
|
|
;;; font-lock.el ends here
|