[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: Stefan Monnier
Subject: Re: Last steps for pretesting (font-lock-extend-region-function)
Date: Thu, 20 Apr 2006 16:58:44 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

>> So your code needs extend-region both in a-c-f and in f-l-d-f-r ?

> Yes.  The region needs extending in two distinct circumstances:
> (i) In after-change, to determine the entire region which needs
>   refontifying;
> (ii) In jit-lock-fontify-now, to ensure that each chunk starts and stops
>   at a "safe place".
> These are logically disjoint.  But it seems that the major mode code to
> do each of them is so similar, that we might as well just have a single
> function, font-lock-extend-region-function, called in two different ways.

IIRC part (i) needs more than an after-change-function: it also needs
a before-change-function.  And (again IIRC) it's the part that can already
be solved by placing (from one of the font-lock-keywords rules)
a font-lock-multiline property.  Basically it's the part that makes sure
that if a multiline element loses its multiline status, the whole
(previously atomic) text gets properly refreshed.

I find it very hard to believe that b-f-c + a-f-c ends up being as
efficient/elegant/robust as placing a font-lock-multiline property.  In all
likely hood, adding the font-lock-multiline property is a matter of adding
a single line of code at the right place (the place where you fontify
the corresponding multiline entity).

Here is the problems I see with your proposal:
- an `extend-region' hook in font-lock-fontify-region is needed
- the font-lock-multiline property should be enough in all cases to make
  it unnecessary to use an after-change-function hook.
- adding an after-change-function hook additionally to
  a font-lock-fontify-region hook means making font-lock that much more
  complex to use and maintain, especially since that after-change-function
  basically can't be used without also adding a before-change-function.
- an after-change-function is expensive, and even more when it comes bundled
  with a before-change-function, and even more so when compared to
  code that's only run during font-locking.


reply via email to

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