I think I might have found a bug in GNU Emacs but I want to check my understanding first.
In Search Based Fontification it is possible to specify a function
as a matcher
. It must obey the contract
it receives one argument, the limit of the search; it should begin searching at point, and not search beyond the limit. It should return non-nil if it succeeds, and set the match data to describe the match that was found. Returning nil indicates failure of the search.
In addition, for multi-line matches it is possible to extent the region to be fontified by adding a routine to font-lock-extend-region-functions
that in-place updates the font-lock-beg
or font-lock-end
variables (these variables are not visible in a function matcher
).
Indeed, I have confirmed that if I extend the region in a font-lock-extend-region-functions
then the limit
does increase in my function matcher
!
However, if we use an an anchored matcher, having the form (matcher . anchored-highlighter)
, where the anchored-highlighter
is a function
, my custom font-lock-{beg,end}
regions are ignored!
Is there something I need to do so that anchored matchers receive the calculated regions or are they only designed to extend to the end of the current line by default?
font-lock
is a "we call you API" that's documented in quite some detail in the docs I linked from the question. I think this one needs a font lock expert :-)font-lock-fontify-buffer
, JIT lock presumably won't be used.font-lock-extend-region-functions
is not always called, at least not in a straightforward way (for example byfont-lock-extend-jit-lock-region-after-change
). Over and out