Re: How to reset the idle timer?
Eli Zaretskii <[email protected]>
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <[email protected]> |
> From: [email protected] > Cc: [email protected], [email protected] > Date: Sun, 01 Mar 2026 18:08:19 +0100 > > On 2026-03-01, at 13:42, Eli Zaretskii <[email protected]> wrote: > > >> From: [email protected] > >> Cc: [email protected] > >> Date: Sun, 01 Mar 2026 08:57:07 +0100 > >> > >> Here is my use case. When I close my laptop (not sure what it's > >> technically called - sleep? hibernation?), and then open it again (say, > >> after a few hours), I'd like Emacs to set up an idle timer to do > >> something, say, 1 minute after I stop pressing any buttons. I have > >> a (not great, but working) way to run some Elisp after I open my laptop, > >> but when I set up an idle timer then, it runs immediately, since the > >> idle time is several hours. I'd like to reset that idle time so that my > >> idle timer will really run after 1 minute of idleness - so, 1 minute > >> /after/ opening the laptop if I don't do anything else, and later if > >> I do something in Emacs within 60 seconds of opening my laptop. > > > > When the laptop is open, call run-with-timer to set up a normal > > (non-idle) timer that runs 1 min after that, and in the timer function > > of that timer start an idle timer. > > That's interesting. I have a feeling that it's a bit convoluted and > hackish, but then maybe so is my idea of "resetting" the idle time. > Still, I think that a "reset" like this may be more elegant and simpler. > WDYT? Is `(setq unread-command-events nil)' a good idea, then? No, I don't think so. It might work, by sheer luck.