aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/jit-lock.el18
1 files changed, 11 insertions, 7 deletions
diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el
index cf1261e3652..3b672aaf680 100644
--- a/lisp/jit-lock.el
+++ b/lisp/jit-lock.el
@@ -210,19 +210,19 @@ the variable `jit-lock-stealth-nice'."
210 'jit-lock-fontify-buffer)) 210 'jit-lock-fontify-buffer))
211 211
212 ;; Install an idle timer for stealth fontification. 212 ;; Install an idle timer for stealth fontification.
213 (when (and jit-lock-stealth-time 213 (when (and jit-lock-stealth-time (null jit-lock-stealth-timer))
214 (null jit-lock-stealth-timer))
215 (setq jit-lock-stealth-timer 214 (setq jit-lock-stealth-timer
216 (run-with-idle-timer jit-lock-stealth-time 215 (run-with-idle-timer jit-lock-stealth-time
217 jit-lock-stealth-time 216 jit-lock-stealth-time
218 'jit-lock-stealth-fontify))) 217 'jit-lock-stealth-fontify)))
219 218
220 ;; Initialize deferred contextual fontification if requested. 219 ;; Initialize deferred contextual fontification if requested.
221 (when (or (eq jit-lock-defer-contextually 'always) 220 (when (or (eq jit-lock-defer-contextually t)
222 (and (not (eq jit-lock-defer-contextually 'never)) 221 (and jit-lock-defer-contextually
223 (boundp 'font-lock-keywords-only) 222 (boundp 'font-lock-keywords-only)
224 (null font-lock-keywords-only))) 223 (null font-lock-keywords-only)))
225 (setq jit-lock-first-unfontify-pos (point-max))) 224 (setq jit-lock-first-unfontify-pos
225 (or jit-lock-first-unfontify-pos (point-max))))
226 226
227 ;; Setup our after-change-function 227 ;; Setup our after-change-function
228 ;; and remove font-lock's (if any). 228 ;; and remove font-lock's (if any).
@@ -252,11 +252,15 @@ the variable `jit-lock-stealth-nice'."
252 'font-lock-after-change-function nil t)) 252 'font-lock-after-change-function nil t))
253 (remove-hook 'fontification-functions 'jit-lock-function)))) 253 (remove-hook 'fontification-functions 'jit-lock-function))))
254 254
255(defun jit-lock-register (fun) 255;;;###autoload
256(defun jit-lock-register (fun &optional contextual)
256 "Register FUN as a fontification function to be called in this buffer. 257 "Register FUN as a fontification function to be called in this buffer.
257FUN will be called with two arguments START and END indicating the region 258FUN will be called with two arguments START and END indicating the region
258that need to be (re)fontified." 259that needs to be (re)fontified.
260If non-nil, CONTEXTUAL means that a contextual fontification would be useful."
259 (add-hook 'jit-lock-functions fun nil t) 261 (add-hook 'jit-lock-functions fun nil t)
262 (when (and contextual jit-lock-defer-contextually)
263 (set (make-local-variable 'jit-lock-defer-contextually) t))
260 (jit-lock-mode t)) 264 (jit-lock-mode t))
261 265
262(defun jit-lock-unregister (fun) 266(defun jit-lock-unregister (fun)