Variable: font-lock-extend-region-functions

font-lock-extend-region-functions is a buffer-local variable defined in font-lock.el.gz.

Documentation

Special hook run just before proceeding to fontify a region.

This is used to allow major modes to help font-lock find safe buffer positions as beginning and end of the fontified region. Its most common use is to solve the problem of /identification/ of multiline elements by providing a function that tries to find such elements and move the boundaries such that they do not fall in the middle of one. Each function is called with no argument; it is expected to adjust the dynamically bound variables font-lock-beg and font-lock-end; and return non-nil if it did make such an adjustment. These functions are run in turn repeatedly until they all return nil. Put first the functions more likely to cause a change and cheaper to compute.

Probably introduced at or before Emacs version 22.1.

Source Code

;; Defined in /usr/src/emacs/lisp/font-lock.el.gz
(defvar-local font-lock-extend-region-functions
  '(font-lock-extend-region-wholelines
    ;; This use of font-lock-multiline property is unreliable but is just
    ;; a handy heuristic: in case you don't have a function that does
    ;; /identification/ of multiline elements, you may still occasionally
    ;; discover them by accident (or you may /identify/ them but not in all
    ;; cases), in which case the font-lock-multiline property can help make
    ;; sure you will properly *re*identify them during refontification.
    font-lock-extend-region-multiline)
  "Special hook run just before proceeding to fontify a region.
This is used to allow major modes to help font-lock find safe buffer positions
as beginning and end of the fontified region.  Its most common use is to solve
the problem of /identification/ of multiline elements by providing a function
that tries to find such elements and move the boundaries such that they do
not fall in the middle of one.
Each function is called with no argument; it is expected to adjust the
dynamically bound variables `font-lock-beg' and `font-lock-end'; and return
non-nil if it did make such an adjustment.
These functions are run in turn repeatedly until they all return nil.
Put first the functions more likely to cause a change and cheaper to compute.")