[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible support for buffer local idle timers?
From: |
Campbell Barton |
Subject: |
Re: Possible support for buffer local idle timers? |
Date: |
Tue, 21 Sep 2021 01:50:47 +1000 |
On Tue, Sep 21, 2021 at 1:31 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Campbell Barton <ideasman42@gmail.com>
> > Date: Mon, 20 Sep 2021 23:49:28 +1000
> >
> > Hi, I was wondering if buffer-local idle timers had been considered.
>
> I'm not sure I understand how would that work. Timers run as part of
> the Emacs main command loop, so they are by their nature global. How
> did you imagine that a buffer-local timer would express its "locality"?
Yes, the idle timers themselves would be global, but only some buffers
would have call-backs registered to run with these timers.
Exactly how this works internally is an implementation detail, for the
purpose of discussion it could work like this:
;; Setup might look like this.
(setq-local my-timer-handle (run-with-idle-timer-local delay t 'my-fn))
Internally a pool of repeating timers would be kept, one for each
unique delay used by one or more handles, this handle would be created
and added to a list of handles associated with this timer.
Running the timer would loop over callbacks running them if their
buffer matches the current buffer. Any deleted buffers could have
their timer-handles discarded at this point.
;; Cancel might look like this.
(cancel-timer-local buffer timer-handle)
This would remove the handle as well as the timer if there are no
timer-handles left using this timer.
--
- Campbell
- Possible support for buffer local idle timers?, Campbell Barton, 2021/09/20
- Re: Possible support for buffer local idle timers?, Eli Zaretskii, 2021/09/20
- Re: Possible support for buffer local idle timers?,
Campbell Barton <=
- Re: Possible support for buffer local idle timers?, Eli Zaretskii, 2021/09/20
- Re: Possible support for buffer local idle timers?, Campbell Barton, 2021/09/20
- Re: Possible support for buffer local idle timers?, Eli Zaretskii, 2021/09/21
- Re: Possible support for buffer local idle timers?, Lars Ingebrigtsen, 2021/09/21
- Re: Possible support for buffer local idle timers?, Campbell Barton, 2021/09/21
- Re: Possible support for buffer local idle timers?, Eli Zaretskii, 2021/09/21
- Re: Possible support for buffer local idle timers?, Campbell Barton, 2021/09/25