[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Last steps for pretesting (font-lock-extend-region-function)

From: Alan Mackenzie
Subject: Re: Last steps for pretesting (font-lock-extend-region-function)
Date: Tue, 25 Apr 2006 22:16:23 +0000 (GMT)

Hi, Ralf!

On Tue, 25 Apr 2006, Ralf Angeli wrote:

>* Alan Mackenzie (2006-04-24) writes:

>> after-change-functions is the canonical way of solving problems related
>> to buffer changes.  This includes Font Locking.

>But extending the region in the after-change case does not help with
>"normal" fontification by region as e.g. done by jit-lock.

>> I say to you again - your solution is not robust.  I don't think it's
>> been tried at all (correct me if I'm wrong).

>Hopefully I understand "your solution" correctly here if I am assuming
>this relates to putting the hook into

Yes - more precisely, putting the hook ONLY into f-l-d-f-r.

>I've implemented a variant of this approach for AUCTeX by using a
>custom-made function for `font-lock-fontify-region-function' which calls
>other functions for extending the region and then calls
>`font-lock-default-fontify-region' with the extended region as
>arguments.  There is no special code in `after-change-functions' and the
>approach actually works quite well.

>> We are both aware of a refinement which is needed, namely calling some
>> sort of f-l-extend-region-f from f-l-d-f-r and j-l-f-n.

>If putting the hook into `font-lock-default-fontify-region' works
>reliably, why do you need it in `after-change-functions' and
>`jit-lock-fontify-now' as well?

It doesn't work reliably.  The region which needs fontification after a
buffer change depends on that _change_, not merely on what the buffer
looks like after the change.  If the f-l-extend-region-f isn't called
from after-change-functions, necessary information gets lost.  Take, once
more, the standard canonical example:

1: "string \
2: over \
3: several  <======= point is here, having just deleted a character.
4: lines."

Point is at EOL 3, having just deleted a character.  A hook in
f-l-after-change-functions cannot determine whether L4 belongs to the
region, without knowing whether the deleted character was a \.  A hook is
thus necessary in font-lock-after-change-functions too, to record this
information in some fashion.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]