aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/font-core.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/font-core.el')
-rw-r--r--lisp/font-core.el16
1 files changed, 13 insertions, 3 deletions
diff --git a/lisp/font-core.el b/lisp/font-core.el
index 056c1b3515b..a78e21a762f 100644
--- a/lisp/font-core.el
+++ b/lisp/font-core.el
@@ -88,6 +88,8 @@ settings. See the variable `font-lock-defaults', which takes precedence.")
88It will be passed one argument, which is the current value of 88It will be passed one argument, which is the current value of
89`font-lock-mode'.") 89`font-lock-mode'.")
90 90
91;; The mode for which font-lock was initialized, or nil if none.
92(defvar font-lock-mode-major-mode)
91(define-minor-mode font-lock-mode 93(define-minor-mode font-lock-mode
92 "Toggle Font Lock mode. 94 "Toggle Font Lock mode.
93With arg, turn Font Lock mode off if and only if arg is a non-positive 95With arg, turn Font Lock mode off if and only if arg is a non-positive
@@ -156,7 +158,9 @@ your own function which is called when `font-lock-mode' is toggled via
156 ;; Arrange to unfontify this buffer if we change major mode later. 158 ;; Arrange to unfontify this buffer if we change major mode later.
157 (if font-lock-mode 159 (if font-lock-mode
158 (add-hook 'change-major-mode-hook 'font-lock-change-mode nil t) 160 (add-hook 'change-major-mode-hook 'font-lock-change-mode nil t)
159 (remove-hook 'change-major-mode-hook 'font-lock-change-mode t))) 161 (remove-hook 'change-major-mode-hook 'font-lock-change-mode t))
162 (when font-lock-mode
163 (setq font-lock-mode-major-mode major-mode)))
160 164
161;; Get rid of fontification for the old major mode. 165;; Get rid of fontification for the old major mode.
162;; We do this when changing major modes. 166;; We do this when changing major modes.
@@ -175,6 +179,7 @@ this function onto `change-major-mode-hook'."
175 '(font-lock-face))) 179 '(font-lock-face)))
176 (restore-buffer-modified-p modp))) 180 (restore-buffer-modified-p modp)))
177 181
182(defvar font-lock-set-defaults)
178(defun font-lock-default-function (mode) 183(defun font-lock-default-function (mode)
179 ;; Turn on Font Lock mode. 184 ;; Turn on Font Lock mode.
180 (when mode 185 (when mode
@@ -201,9 +206,14 @@ this function onto `change-major-mode-hook'."
201 ;; Only do hard work if the mode has specified stuff in 206 ;; Only do hard work if the mode has specified stuff in
202 ;; `font-lock-defaults'. 207 ;; `font-lock-defaults'.
203 (when (or font-lock-defaults 208 (when (or font-lock-defaults
204 (and (boundp 'font-lock-keywords) font-lock-keywords) 209 (if (boundp 'font-lock-keywords) font-lock-keywords)
205 (with-no-warnings 210 (with-no-warnings
206 (cdr (assq major-mode font-lock-defaults-alist)))) 211 (cdr (assq major-mode font-lock-defaults-alist)))
212 (and mode
213 (boundp 'font-lock-set-defaults)
214 font-lock-set-defaults
215 font-lock-mode-major-mode
216 (not (eq font-lock-mode-major-mode major-mode))))
207 (font-lock-mode-internal mode))) 217 (font-lock-mode-internal mode)))
208 218
209(defun turn-on-font-lock () 219(defun turn-on-font-lock ()