emacs-devel
[Top][All Lists]
Advanced

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

Re: Possible support for buffer local idle timers?


From: Eli Zaretskii
Subject: Re: Possible support for buffer local idle timers?
Date: Mon, 20 Sep 2021 19:08:16 +0300

> From: Campbell Barton <ideasman42@gmail.com>
> Date: Tue, 21 Sep 2021 01:50:47 +1000
> Cc: emacs-devel@gnu.org
> 
> > 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.

So you want such a "buffer-local" timer call its timer function only
if/when the buffer is the current buffer?  That raises some issues
that I think would need to be figured out:

  . does the timer start measuring idle time only when the buffer is
    the current buffer, or regardless of that?
  . what to do when the timer expired but the buffer wasn't current,
    and then the buffer became current? does the callback gets called
    right away, or do we "miss" the timer in that case?
  . how to handle repeated timers?



reply via email to

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