Function: lazy-lock-mode
lazy-lock-mode is an interactive and byte-compiled function defined in
lazy-lock.el.gz.
Signature
(lazy-lock-mode &optional ARG)
Documentation
Toggle Lazy Lock mode.
With arg, turn Lazy Lock mode on if and only if arg is positive. Enable it
automatically in your ~/.emacs by:
(setq font-lock-support-mode 'lazy-lock-mode)
For a newer font-lock support mode with similar functionality, see
jit-lock-mode(var)/jit-lock-mode(fun). Eventually, Lazy Lock mode will be deprecated in
JIT Lock's favor.
When Lazy Lock mode is enabled, fontification can be lazy in a number of ways:
- Demand-driven buffer fontification if lazy-lock-minimum-size is non-nil.
This means initial fontification does not occur if the buffer is greater than
lazy-lock-minimum-size characters in length. Instead, fontification occurs
when necessary, such as when scrolling through the buffer would otherwise
reveal unfontified areas. This is useful if buffer fontification is too slow
for large buffers.
- Deferred scroll fontification if lazy-lock-defer-on-scrolling is non-nil.
This means demand-driven fontification does not occur as you scroll.
Instead, fontification is deferred until after lazy-lock-defer-time seconds
of Emacs idle time, while Emacs remains idle. This is useful if
fontification is too slow to keep up with scrolling.
- Deferred on-the-fly fontification if lazy-lock-defer-on-the-fly is non-nil.
This means on-the-fly fontification does not occur as you type. Instead,
fontification is deferred until after lazy-lock-defer-time seconds of Emacs
idle time, while Emacs remains idle. This is useful if fontification is too
slow to keep up with your typing.
- Deferred context fontification if lazy-lock-defer-contextually is non-nil.
This means fontification updates the buffer corresponding to true syntactic
context, after lazy-lock-defer-time seconds of Emacs idle time, while Emacs
remains idle. Otherwise, fontification occurs on modified lines only, and
subsequent lines can remain fontified corresponding to previous syntactic
contexts. This is useful where strings or comments span lines.
- Stealthy buffer fontification if lazy-lock-stealth-time is non-nil.
This means remaining unfontified areas of buffers are fontified if Emacs has
been idle for lazy-lock-stealth-time seconds, while Emacs remains idle.
This is useful if any buffer has any deferred fontification.
Basic Font Lock mode on-the-fly fontification behavior fontifies modified
lines only. Thus, if lazy-lock-defer-contextually is non-nil, Lazy Lock mode
on-the-fly fontification may fontify differently, albeit correctly. In any
event, to refontify some lines you can use M-x font-lock-fontify-block (font-lock-fontify-block).
Stealth fontification only occurs while the system remains unloaded.
If the system load rises above lazy-lock-stealth-load percent, stealth
fontification is suspended. Stealth fontification intensity is controlled via
the variable lazy-lock-stealth-nice and lazy-lock-stealth-lines, and
verbosity is controlled via the variable lazy-lock-stealth-verbose.
Probably introduced at or before Emacs version 19.32.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/obsolete/lazy-lock.el.gz
;; User Functions:
;;;###autoload
(defun lazy-lock-mode (&optional arg)
"Toggle Lazy Lock mode.
With arg, turn Lazy Lock mode on if and only if arg is positive. Enable it
automatically in your `~/.emacs' by:
(setq font-lock-support-mode \\='lazy-lock-mode)
For a newer font-lock support mode with similar functionality, see
`jit-lock-mode'. Eventually, Lazy Lock mode will be deprecated in
JIT Lock's favor.
When Lazy Lock mode is enabled, fontification can be lazy in a number of ways:
- Demand-driven buffer fontification if `lazy-lock-minimum-size' is non-nil.
This means initial fontification does not occur if the buffer is greater than
`lazy-lock-minimum-size' characters in length. Instead, fontification occurs
when necessary, such as when scrolling through the buffer would otherwise
reveal unfontified areas. This is useful if buffer fontification is too slow
for large buffers.
- Deferred scroll fontification if `lazy-lock-defer-on-scrolling' is non-nil.
This means demand-driven fontification does not occur as you scroll.
Instead, fontification is deferred until after `lazy-lock-defer-time' seconds
of Emacs idle time, while Emacs remains idle. This is useful if
fontification is too slow to keep up with scrolling.
- Deferred on-the-fly fontification if `lazy-lock-defer-on-the-fly' is non-nil.
This means on-the-fly fontification does not occur as you type. Instead,
fontification is deferred until after `lazy-lock-defer-time' seconds of Emacs
idle time, while Emacs remains idle. This is useful if fontification is too
slow to keep up with your typing.
- Deferred context fontification if `lazy-lock-defer-contextually' is non-nil.
This means fontification updates the buffer corresponding to true syntactic
context, after `lazy-lock-defer-time' seconds of Emacs idle time, while Emacs
remains idle. Otherwise, fontification occurs on modified lines only, and
subsequent lines can remain fontified corresponding to previous syntactic
contexts. This is useful where strings or comments span lines.
- Stealthy buffer fontification if `lazy-lock-stealth-time' is non-nil.
This means remaining unfontified areas of buffers are fontified if Emacs has
been idle for `lazy-lock-stealth-time' seconds, while Emacs remains idle.
This is useful if any buffer has any deferred fontification.
Basic Font Lock mode on-the-fly fontification behavior fontifies modified
lines only. Thus, if `lazy-lock-defer-contextually' is non-nil, Lazy Lock mode
on-the-fly fontification may fontify differently, albeit correctly. In any
event, to refontify some lines you can use \\[font-lock-fontify-block].
Stealth fontification only occurs while the system remains unloaded.
If the system load rises above `lazy-lock-stealth-load' percent, stealth
fontification is suspended. Stealth fontification intensity is controlled via
the variable `lazy-lock-stealth-nice' and `lazy-lock-stealth-lines', and
verbosity is controlled via the variable `lazy-lock-stealth-verbose'."
(interactive "P")
(let* ((was-on lazy-lock-mode)
(now-on (unless (memq 'lazy-lock-mode font-lock-inhibit-thing-lock)
(if arg (> (prefix-numeric-value arg) 0) (not was-on)))))
(cond ((and now-on (not font-lock-mode))
;; Turned on `lazy-lock-mode' rather than `font-lock-mode'.
(message "Use font-lock-support-mode rather than calling lazy-lock-mode")
(sit-for 2))
(now-on
;; Turn ourselves on.
(set (make-local-variable 'lazy-lock-mode) t)
(lazy-lock-install))
(was-on
;; Turn ourselves off.
(set (make-local-variable 'lazy-lock-mode) nil)
(lazy-lock-unstall)))))