help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: overlays and movement


From: Tassilo Horn
Subject: Re: overlays and movement
Date: Tue, 28 Jun 2022 12:39:38 +0200
User-agent: mu4e 1.7.28; emacs 29.0.50

Manuel Giraud <manuel@ledu-giraud.fr> writes:

Hi Manuel,

> I'd like to have some overlays (just 2 in fact) that have to be
> updated each time I'm moving into the buffer.

What does that mean exactly?  Do you mean "the position of point changes
in that buffer" or "the buffer becomes shown in a window"?  If it's the
former, I'd use a buffer-local post-command-hook checking if point moved
by comparing to the former value and recording that.  If it's the
latter, a buffer-local window-configuration-change-hook.

If you only need to update the overlays when the buffer contents have
changed, then after-change-functions are your friend.

> I have tried to add a hook on `post-command-hook'. It kind of works
> but it seems to lag sometimes and the docstring says that this is a
> bad idea anyway.

It says it's a bad idea for expensive functions.  But when you can
cheaply detect that nothing has to be done in most of the cases and you
do it buffer-locally, it won't be too bad, I guess.

Bye,
Tassilo



reply via email to

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