Variable: font-lock-extend-after-change-region-function
font-lock-extend-after-change-region-function is a buffer-local
variable defined in font-lock.el.gz.
Documentation
A function that determines the region to refontify after a change.
This variable is either nil, or is a function that determines the
region to refontify after a change.
It is usually set by the major mode via font-lock-defaults.
Font-lock calls this function after each buffer change.
The function is given three parameters, the standard BEG, END, and OLD-LEN
from after-change-functions. It should return either a cons of the beginning
and end buffer positions (in that order) of the region to refontify, or nil
(which directs the caller to fontify a default region).
This function should preserve the match data.
The region it returns may start or end in the middle of a line.
Source Code
;; Defined in /usr/src/emacs/lisp/font-lock.el.gz
;;; Fontification functions.
;; Rather than the function, e.g., `font-lock-fontify-region' containing the
;; code to fontify a region, the function runs the function whose name is the
;; value of the variable, e.g., `font-lock-fontify-region-function'. Normally,
;; the value of this variable is, e.g., `font-lock-default-fontify-region'
;; which does contain the code to fontify a region. However, the value of the
;; variable could be anything and thus, e.g., `font-lock-fontify-region' could
;; do anything. The indirection of the fontification functions gives major
;; modes the capability of modifying the way font-lock.el fontifies. Major
;; modes can modify the values of, e.g., `font-lock-fontify-region-function',
;; via the variable `font-lock-defaults'.
;;
;; For example, Rmail mode sets the variable `font-lock-defaults' so that
;; font-lock.el uses its own function for buffer fontification. This function
;; makes fontification be on a message-by-message basis and so visiting an
;; RMAIL file is much faster. A clever implementation of the function might
;; fontify the headers differently from the message body. (It should, and
;; correspondingly for Mail mode, but I can't be bothered to do the work. Can
;; you?) This hints at a more interesting use...
;;
;; Languages that contain text normally contained in different major modes
;; could define their own fontification functions that treat text differently
;; depending on its context. For example, Perl mode could arrange that here
;; docs are fontified differently from Perl code. Or Yacc mode could fontify
;; rules one way and C code another. Neat!
;;
;; A further reason to use the fontification indirection feature is when the
;; default syntactic fontification, or the default fontification in general,
;; is not flexible enough for a particular major mode. For example, perhaps
;; comments are just too hairy for `font-lock-fontify-syntactically-region' to
;; cope with. You need to write your own version of that function, e.g.,
;; `hairy-fontify-syntactically-region', and make your own version of
;; `hairy-fontify-region' call that function before calling
;; `font-lock-fontify-keywords-region' for the normal regexp fontification
;; pass. And Hairy mode would set `font-lock-defaults' so that font-lock.el
;; would call your region fontification function instead of its own. For
;; example, TeX modes could fontify {\foo ...} and \bar{...} etc. multi-line
;; directives correctly and cleanly. (It is the same problem as fontifying
;; multi-line strings and comments; regexps are not appropriate for the job.)
(defvar-local font-lock-extend-after-change-region-function nil
"A function that determines the region to refontify after a change.
This variable is either nil, or is a function that determines the
region to refontify after a change.
It is usually set by the major mode via `font-lock-defaults'.
Font-lock calls this function after each buffer change.
The function is given three parameters, the standard BEG, END, and OLD-LEN
from `after-change-functions'. It should return either a cons of the beginning
and end buffer positions \(in that order) of the region to refontify, or nil
\(which directs the caller to fontify a default region).
This function should preserve the match data.
The region it returns may start or end in the middle of a line.")