aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier2003-04-14 23:07:49 +0000
committerStefan Monnier2003-04-14 23:07:49 +0000
commite350babd40ddb71d15025af03d18f4154f31334f (patch)
treeb9c8e4d22f3ab5dd59f15778e0570cd2aba77645 /lisp
parentf8115798d77d20c0cf7be19413095be1afb7ad38 (diff)
downloademacs-e350babd40ddb71d15025af03d18f4154f31334f.tar.gz
emacs-e350babd40ddb71d15025af03d18f4154f31334f.zip
(font-lock-maximum-size, font-lock-verbose): Remove.
(font-lock-multiline, font-lock-fontified, font-lock-set-defaults): Move back to font-lock.el (font-lock-default-function): Use font-lock-mode-internal.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/font-core.el61
1 files changed, 10 insertions, 51 deletions
diff --git a/lisp/font-core.el b/lisp/font-core.el
index fb1fe943e03..40f192bb572 100644
--- a/lisp/font-core.el
+++ b/lisp/font-core.el
@@ -25,9 +25,6 @@
25 25
26;;; Code: 26;;; Code:
27 27
28(defvar font-lock-maximum-size)
29(defvar font-lock-verbose)
30
31;; This variable is used by mode packages that support Font Lock mode by 28;; This variable is used by mode packages that support Font Lock mode by
32;; defining their own keywords to use for `font-lock-keywords'. (The mode 29;; defining their own keywords to use for `font-lock-keywords'. (The mode
33;; command should make it buffer-local and set it to provide the set up.) 30;; command should make it buffer-local and set it to provide the set up.)
@@ -130,20 +127,10 @@ where MAJOR-MODE is a symbol and FONT-LOCK-DEFAULTS is a list of default
130settings. See the variable `font-lock-defaults', which takes precedence.") 127settings. See the variable `font-lock-defaults', which takes precedence.")
131(make-obsolete-variable 'font-lock-defaults-alist 'font-lock-defaults) 128(make-obsolete-variable 'font-lock-defaults-alist 'font-lock-defaults)
132 129
133(defvar font-lock-multiline nil
134 "Whether font-lock should cater to multiline keywords.
135If nil, don't try to handle multiline patterns.
136If t, always handle multiline patterns.
137If `undecided', don't try to handle multiline patterns until you see one.
138Major/minor modes can set this variable if they know which option applies.")
139
140(defvar font-lock-fontified nil) ; Whether we have fontified the buffer.
141
142(defvar font-lock-function 'font-lock-default-function 130(defvar font-lock-function 'font-lock-default-function
143 "A function which is called when `font-lock-mode' is toggled. 131 "A function which is called when `font-lock-mode' is toggled.
144It will be passed one argument, which is the current value of 132It will be passed one argument, which is the current value of
145`font-lock-mode'.") 133`font-lock-mode'.")
146(make-variable-buffer-local 'font-lock-function)
147 134
148(define-minor-mode font-lock-mode 135(define-minor-mode font-lock-mode
149 "Toggle Font Lock mode. 136 "Toggle Font Lock mode.
@@ -222,7 +209,7 @@ your own function which is called when `font-lock-mode' is toggled via
222 209
223(defun font-lock-defontify () 210(defun font-lock-defontify ()
224 "Clear out all `font-lock-face' properties in current buffer. 211 "Clear out all `font-lock-face' properties in current buffer.
225A major mode that uses `font-lock-face' properties should put 212A major mode that uses `font-lock-face' properties might want to put
226this function onto `change-major-mode-hook'." 213this function onto `change-major-mode-hook'."
227 (let ((modp (buffer-modified-p)) 214 (let ((modp (buffer-modified-p))
228 (inhibit-read-only t)) 215 (inhibit-read-only t))
@@ -235,7 +222,6 @@ this function onto `change-major-mode-hook'."
235(defun font-lock-default-function (mode) 222(defun font-lock-default-function (mode)
236 ;; Turn on Font Lock mode. 223 ;; Turn on Font Lock mode.
237 (when mode 224 (when mode
238 (font-lock-set-defaults)
239 (set (make-local-variable 'char-property-alias-alist) 225 (set (make-local-variable 'char-property-alias-alist)
240 (copy-tree char-property-alias-alist)) 226 (copy-tree char-property-alias-alist))
241 ;; Add `font-lock-face' as an alias for the `face' property. 227 ;; Add `font-lock-face' as an alias for the `face' property.
@@ -243,21 +229,7 @@ this function onto `change-major-mode-hook'."
243 (if elt 229 (if elt
244 (unless (memq 'font-lock-face (cdr elt)) 230 (unless (memq 'font-lock-face (cdr elt))
245 (setcdr elt (nconc (cdr elt) (list 'font-lock-face)))) 231 (setcdr elt (nconc (cdr elt) (list 'font-lock-face))))
246 (push (list 'face 'font-lock-face) char-property-alias-alist))) 232 (push (list 'face 'font-lock-face) char-property-alias-alist))))
247 ;; Only do hard work if the mode has specified stuff in
248 ;; `font-lock-defaults'.
249 (when font-lock-defaults
250 (add-hook 'after-change-functions 'font-lock-after-change-function t t)
251 (font-lock-turn-on-thing-lock)
252 ;; Fontify the buffer if we have to.
253 (let ((max-size (font-lock-value-in-major-mode font-lock-maximum-size)))
254 (cond (font-lock-fontified
255 nil)
256 ((or (null max-size) (> max-size (buffer-size)))
257 (font-lock-fontify-buffer))
258 (font-lock-verbose
259 (message "Fontifying %s...buffer size greater than font-lock-maximum-size"
260 (buffer-name)))))))
261 ;; Turn off Font Lock mode. 233 ;; Turn off Font Lock mode.
262 (unless mode 234 (unless mode
263 ;; Remove `font-lock-face' as an alias for the `face' property. 235 ;; Remove `font-lock-face' as an alias for the `face' property.
@@ -267,33 +239,20 @@ this function onto `change-major-mode-hook'."
267 (when elt 239 (when elt
268 (setcdr elt (remq 'font-lock-face (cdr elt))) 240 (setcdr elt (remq 'font-lock-face (cdr elt)))
269 (when (null (cdr elt)) 241 (when (null (cdr elt))
270 (setq char-property-alias-alist (delq elt char-property-alias-alist))))) 242 (setq char-property-alias-alist
271 (when font-lock-defaults 243 (delq elt char-property-alias-alist))))))
272 (remove-hook 'after-change-functions 'font-lock-after-change-function t) 244
273 (font-lock-unfontify-buffer) 245 ;; Only do hard work if the mode has specified stuff in
274 (font-lock-turn-off-thing-lock)))) 246 ;; `font-lock-defaults'.
247 (when (or font-lock-defaults
248 (cdr (assq major-mode font-lock-defaults-alist)))
249 (font-lock-mode-internal mode)))
275 250
276(defun turn-on-font-lock () 251(defun turn-on-font-lock ()
277 "Turn on Font Lock mode (only if the terminal can display it)." 252 "Turn on Font Lock mode (only if the terminal can display it)."
278 (unless font-lock-mode 253 (unless font-lock-mode
279 (font-lock-mode))) 254 (font-lock-mode)))
280 255
281(defvar font-lock-set-defaults nil) ; Whether we have set up defaults.
282
283(defun font-lock-set-defaults ()
284 "Set fontification defaults appropriately for this mode.
285Sets various variables using `font-lock-defaults' (or, if nil, using
286`font-lock-defaults-alist') and `font-lock-maximum-decoration'."
287 (unless font-lock-set-defaults
288 (set (make-local-variable 'font-lock-set-defaults) t)
289 (make-local-variable 'font-lock-fontified)
290 (make-local-variable 'font-lock-multiline)
291 (let ((defaults (or font-lock-defaults
292 (cdr (assq major-mode font-lock-defaults-alist)))))
293 (when defaults
294 (require 'font-lock)
295 (font-lock-set-defaults-1)))))
296
297;;; Global Font Lock mode. 256;;; Global Font Lock mode.
298 257
299;; A few people have hassled in the past for a way to make it easier to turn on 258;; A few people have hassled in the past for a way to make it easier to turn on