emacs-devel
[Top][All Lists]
Advanced

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

Re: Is there something like `on-display-functions'?


From: Stefan Monnier
Subject: Re: Is there something like `on-display-functions'?
Date: Fri, 29 Jan 2010 13:08:22 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux)

>> >> > Note that the JIT Lock function that gets invoked via
>> >> > fontification-functions always starts from the beginning of the line
>> >> > to which the position it was invoked with belongs.  So it is already
>> >> > doing something similar, albeit for different reasons.
>> >> That used to be the case, but now this region-extension has been moved
>> >> to font-lock (where it belongs).
>> > The effect is the same.
>> Not quite: there are other users of jit-lock than font-lock (mostly
>> glasses-mode, but Alan might become the third user, linum could be
>> another user, ...).
> My point was that the Lisp function which is invoked via this
> mechanism can do its work in any position it finds fit, not
> necessarily the position passed to it by the display engine.

Right, but for efficiency reason, we'd like to make sure it does its job
at a place that's useful.  With a single fontification-function, the
`fontified' text property provides this information very precisely.

>> This assumption is currently not true.  Recording which part is already
>> handled and which part is not yet handled is usually done either by the
>> `fontified' property (if you use fontification-functions) or somehow by
>> `jit-lock'.
> That ``somehow'' is what I meant when I mentioned that the function
> could record where it left off in some variable.

jit-lock uses the `fontified' text property for that, and then forces
all its clients to fontify (at least) the same part of the buffer, which
is what fontification-functions can't do because it only provides the
`start' but not the `end' argument.

>> If such a problem of efficiency needs to be solved, we could indeed
>> probably hack it up via some such variable, tho it would be mighty ugly,
>> since the function wouldn't necessarily know what happened between the
>> last time it was called and the current time, so it would need to
>> somehow figure out whether "nothing happened and I can just return" or
>> whether in the contrary the buffer has been modified and the
>> fontification that was computed last time needs to be refreshed.
> Anything that's needed for such a decision except the position and the
> buffer or window id?

MODIFF, probably.

>> > Fine with me.  But I do think we may wish to have some more general
>> > redisplay-hook feature, that isn't tailored to fontification.
>> Not sure what you're thinking of.
> I was thinking about a hook that does not depend on the `fontified'
> property.

What would it depend on and what info would it provide to its functions?

>> I'd be interested in a before-redisplay-hook
> Why ``before''?  There isn't much a Lisp code can do to affect
> redisplay, if it is called _by_ redisplay.

Just like fontification-functions, it can affect the faces, the color,
... everything.  See my examples of reveal-mode and cursor color.

> I'd say calling the hook when redisplay is done is more useful.

That's an alternative, indeed, tho I'm not sure what it could be used
for (I do see that it could receive extra info such as which part of
which buffer needed redisply and things like that, but again, no
use-case springs to mind).


        Stefan




reply via email to

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