comparison lisp/font-core.el @ 45476:e1671f561407

(font-lock-function): New variable. (font-lock-default-function): New function, created from `font-lock-mode'. (font-lock-mode): Just funcall `font-lock-default-function'.
author Colin Walters <walters@gnu.org>
date Thu, 23 May 2002 03:38:22 +0000
parents e879dd65b980
children d78e68782e6e
comparison
equal deleted inserted replaced
45475:87bde9ae0aab 45476:e1671f561407
142 buffer text for display to the user (i.e. buffer-menu, occur), but 142 buffer text for display to the user (i.e. buffer-menu, occur), but
143 wish to have fontification turned on and off by Font Lock. If this 143 wish to have fontification turned on and off by Font Lock. If this
144 variable is non-nil, then calling `font-lock-mode' will simply toggle 144 variable is non-nil, then calling `font-lock-mode' will simply toggle
145 the symbol property `face' of CATEGORY-SYMBOL.") 145 the symbol property `face' of CATEGORY-SYMBOL.")
146 146
147 (defvar font-lock-function 'font-lock-default-function
148 "A function which is called when `font-lock-mode' is toggled.
149 It will be passed one argument, which is the current value of
150 `font-lock-mode'.")
151 (make-variable-buffer-local 'font-lock-default-function)
152
147 (define-minor-mode font-lock-mode 153 (define-minor-mode font-lock-mode
148 "Toggle Font Lock mode. 154 "Toggle Font Lock mode.
149 With arg, turn Font Lock mode off if and only if arg is a non-positive 155 With arg, turn Font Lock mode off if and only if arg is a non-positive
150 number; if arg is nil, toggle Font Lock mode; anything else turns Font 156 number; if arg is nil, toggle Font Lock mode; anything else turns Font
151 Lock on. 157 Lock on.
196 lines around point), perhaps because modification on the current line caused 202 lines around point), perhaps because modification on the current line caused
197 syntactic change on other lines, you can use \\[font-lock-fontify-block]. 203 syntactic change on other lines, you can use \\[font-lock-fontify-block].
198 204
199 See the variable `font-lock-defaults-alist' for the Font Lock mode default 205 See the variable `font-lock-defaults-alist' for the Font Lock mode default
200 settings. You can set your own default settings for some mode, by setting a 206 settings. You can set your own default settings for some mode, by setting a
201 buffer local value for `font-lock-defaults', via its mode hook." 207 buffer local value for `font-lock-defaults', via its mode hook.
208
209 The above is the default behavior of `font-lock-mode'; you may specify
210 your own function which is called when `font-lock-mode' is toggled via
211 `font-lock-function'. "
202 nil nil nil 212 nil nil nil
203 ;; Don't turn on Font Lock mode if we don't have a display (we're running a 213 ;; Don't turn on Font Lock mode if we don't have a display (we're running a
204 ;; batch job) or if the buffer is invisible (the name starts with a space). 214 ;; batch job) or if the buffer is invisible (the name starts with a space).
205 (when (or noninteractive (eq (aref (buffer-name) 0) ?\ )) 215 (when (or noninteractive (eq (aref (buffer-name) 0) ?\ ))
206 (setq font-lock-mode nil)) 216 (setq font-lock-mode nil))
207 217 (funcall font-lock-function font-lock-mode))
218
219 (defun font-lock-default-function (font-lock-mode)
208 ;; Turn on Font Lock mode. 220 ;; Turn on Font Lock mode.
209 (when font-lock-mode 221 (when font-lock-mode
210 (font-lock-set-defaults) 222 (font-lock-set-defaults)
211 (dolist (elt font-lock-category-alist) 223 (dolist (elt font-lock-category-alist)
212 (put (car elt) 'face (cdr elt))) 224 (put (car elt) 'face (cdr elt)))