;;; font-lock.el --- Electric font lock mode
-;; Copyright (C) 1992-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1992-2012 Free Software Foundation, Inc.
;; Author: Jamie Zawinski
;; Richard Stallman
;;
;; The syntactic keyword pass places `syntax-table' text properties in the
;; buffer according to the variable `font-lock-syntactic-keywords'. It is
-;; necessary because Emacs' syntax table is not powerful enough to describe all
+;; necessary because Emacs's syntax table is not powerful enough to describe all
;; the different syntactic constructs required by the sort of people who decide
;; that a single quote can be syntactic or not depending on the time of day.
;; (What sort of person could decide to overload the meaning of a quote?)
;; User variables.
(defcustom font-lock-maximum-size 256000
- "Maximum size of a buffer for buffer fontification.
-Only buffers less than this can be fontified when Font Lock mode is turned on.
+ "Maximum buffer size for unsupported buffer fontification.
+When `font-lock-support-mode' is nil, only buffers smaller than
+this are fontified. This variable has no effect if a Font Lock
+support mode (usually `jit-lock-mode') is enabled.
+
If nil, means size is irrelevant.
If a list, each element should be a cons pair of the form (MAJOR-MODE . SIZE),
where MAJOR-MODE is a symbol or t (meaning the default). For example:
(const :tag "none" nil)
(integer :tag "size")))))
:group 'font-lock)
+(make-obsolete-variable 'font-lock-maximum-size nil "24.1")
(defcustom font-lock-maximum-decoration t
"Maximum decoration level for fontification.
;; and they give users another mechanism for changing face appearance.
;; We now allow a FACENAME in `font-lock-keywords' to be any expression that
;; returns a face. So the easiest thing is to continue using these variables,
-;; rather than sometimes evaling FACENAME and sometimes not. sm.
+;; rather than sometimes evalling FACENAME and sometimes not. sm.
;; Note that in new code, in the vast majority of cases there is no
;; need to create variables that specify face names. Simply using
;; Shut up the byte compiler.
(defvar font-lock-face-attributes)) ; Obsolete but respected if set.
-(defun font-lock-mode-internal (arg)
- ;; Turn on Font Lock mode.
- (when arg
- (add-hook 'after-change-functions 'font-lock-after-change-function t t)
- (font-lock-set-defaults)
- (font-lock-turn-on-thing-lock)
- ;; Fontify the buffer if we have to.
+(defun font-lock-specified-p (mode)
+ "Return non-nil if the current buffer is ready for fontification.
+The MODE argument, if non-nil, means Font Lock mode is about to
+be enabled."
+ (or font-lock-defaults
+ (and (boundp 'font-lock-keywords)
+ font-lock-keywords)
+ (and mode
+ (boundp 'font-lock-set-defaults)
+ font-lock-set-defaults
+ font-lock-major-mode
+ (not (eq font-lock-major-mode major-mode)))))
+
+(defun font-lock-initial-fontify ()
+ ;; The first fontification after turning the mode on. This must
+ ;; only be called after the mode hooks have been run.
+ (when (and font-lock-mode
+ (font-lock-specified-p t))
(let ((max-size (font-lock-value-in-major-mode font-lock-maximum-size)))
(cond (font-lock-fontified
nil)
(font-lock-fontify-buffer))
(font-lock-verbose
(message "Fontifying %s...buffer size greater than font-lock-maximum-size"
- (buffer-name))))))
+ (buffer-name)))))))
+
+(defun font-lock-mode-internal (arg)
+ ;; Turn on Font Lock mode.
+ (when arg
+ (add-hook 'after-change-functions 'font-lock-after-change-function t t)
+ (font-lock-set-defaults)
+ (font-lock-turn-on-thing-lock))
;; Turn off Font Lock mode.
(unless font-lock-mode
(remove-hook 'after-change-functions 'font-lock-after-change-function t)
;; rules one way and C code another. Neat!
;;
;; A further reason to use the fontification indirection feature is when the
-;; default syntactual fontification, or the default fontification in general,
+;; default syntactic fontification, or the default fontification in general,
;; is not flexible enough for a particular major mode. For example, perhaps
;; comments are just too hairy for `font-lock-fontify-syntactically-region' to
;; cope with. You need to write your own version of that function, e.g.,
keyword)))
(defun font-lock-eval-keywords (keywords)
- "Evalulate KEYWORDS if a function (funcall) or variable (eval) name."
+ "Evaluate KEYWORDS if a function (funcall) or variable (eval) name."
(if (listp keywords)
keywords
(font-lock-eval-keywords (if (fboundp keywords)
"save-selected-window" "save-window-excursion"
"save-match-data" "save-current-buffer"
"combine-after-change-calls" "unwind-protect"
- "condition-case" "condition-case-no-debug"
+ "condition-case" "condition-case-unless-debug"
"track-mouse" "eval-after-load" "eval-and-compile"
"eval-when-compile" "eval-when" "eval-next-after-load"
"with-case-table" "with-category-table"
"with-selected-window" "with-selected-frame"
"with-silent-modifications" "with-syntax-table"
"with-temp-buffer" "with-temp-file" "with-temp-message"
- "with-timeout" "with-timeout-handler") t)
+ "with-timeout" "with-timeout-handler" "with-wrapper-hook") t)
"\\>")
. 1)
;; Control structures. Common Lisp forms.