Subject: bug#20146: font-lock-extend-jit-lock-region-after-change: results are discarded instead of being returned.

From: Alan Mackenzie <[email-masked]>
Date: Wed, 25 Mar 2015 17:12:05 +0000

Hello, Stefan.

On Sun, Mar 22, 2015 at 10:01:53PM -0400, Stefan Monnier wrote:
> >> >> The major mode sets font-lock-extend-region-function and this functions'
> >> >> result should be (and is) respected by the rest of font-lock.
> >> > If only, but this is simply not the case at the moment.
> >> > jit-lock-fontify-now has a hard-coded extension to whole lines,
> >> > regardless of the contents of font-lock-extend-region-functions.
> >> There's no relationship between the two.  The bounds that
> >> font-lock-fontify-region [gets] are not under the major mode's control.
> > Yes they are.  They can be set by
> > font-lock-extend-after-change-region-function, as described in the elisp
> > manual.

> That's where you're confused:
> font-lock-extend-after-change-region-function affects the region that's
> declared as "in need of refresh because of a change".  But that doesn't
> mean that this region will then be passed to font-lock-fontify-region.
> For example, if that region is not currently visible in any window, then
> jit-lock will typically do nothing.  And if only some part of that
> region is visible in a window, then maybe only that part will be then
> passed to font-lock-fontify-region so as to actually refresh it.
> And maybe that part will be combined with some other parts that were
> also in need of refresh and are now newly visible.  Or maybe that part
> will actually be fontified in several steps (i.e. several calls to
> font-lock-fontify-region).

Yes, I was confused about that.  I hope I've got it now.  Thanks for the
help.

[ ... ]

> > Looking more critically at jit-lock-fontify-now, there is simply no need
> > for it to expand the region to whole lines.

> I agree with this statement (I actually have such a change in my local
> tree), but that won't help you.
> Looking at jit-lock as the source of your pain is a waste of time.

OK.  But I have to be aware of how jit-lock works: in particular how the
actions in after-change-functions influence those of
jit-lock-fontify-now and font-lock-fontify-region.

[ ... ]

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).