From: Jean Louis <bugs@gnu.support>
To: Ship Mints <shipmints@gmail.com>
Cc: 75361@debbugs.gnu.org
Subject: bug#75361: SOLVED - Re: bug#75361: 31.0.50; run-with-idle-timer not working unless there is some activity
Date: Sat, 4 Jan 2025 22:21:51 +0300 [thread overview]
Message-ID: <Z3mKT_fOiBY815rF@lco2> (raw)
In-Reply-To: <CAN+1HbphdwZgs5XHMYFeQnigKVRW04jmoJk7t_-xqTRACwHaew@mail.gmail.com>
* Ship Mints <shipmints@gmail.com> [2025-01-04 20:58]:
> I believe this is intended behavior. You should use a regular interval
> timer if you want repeating executions that do not depend upon Emacs
> entering the idle state. Not sure why you think this worked differently in
> the recent past.
>
> "Emacs becomes *idle* when it starts waiting for user input (unless it
> waits for input with a timeout, see Reading One Event
> <https://www.gnu.org/software/emacs/manual/html_node/elisp/Reading-One-Event.html>),
> and it remains idle until the user provides some input. If a timer is set
> for five seconds of idleness, it runs approximately five seconds after
> Emacs first becomes idle. Even if repeat is non-nil, this timer will not
> run again as long as Emacs remains idle, because the duration of idleness
> will continue to increase and will not go down to five seconds again."
Okay I got it. Though I am surprised as I was using idle timer
thousands of times. I was thinking it repeated itself, while it
didn't.
Recently I started observing and have seen it is getting blocked, I
wondered why, due to lack of understanding.
I have found solution to my problem, so I will simply run the function
`run-with-timer` and then check if user is idle to execute it.
Basically, I do not need executions if user is not idle.
(defun my-hello ()
(when (and (current-idle-time)
(>= (cadr (current-idle-time)) 5))
(rcd-message "Current idle time: %s" (cadr (current-idle-time)))))
(run-with-timer 5 5 'my-hello)
So in the sense of how I understand it, `run-with-idle-timer` only
sounds as the function I need, while it is not.
I can make it this way:
(run-with-timer 10 10 'rcd-run-repeatingly-when-idle 5 'my-hello)
(defun rcd-run-repeatingly-when-idle (secs function &rest args)
(when (and (current-idle-time)
(>= (cadr (current-idle-time)) secs))
(apply 'funcall function args)))
As that way it will use `run-with-timer` though only when user is idle
for SECS.
--
Jean Louis
next prev parent reply other threads:[~2025-01-04 19:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-03 22:30 bug#75361: 31.0.50; run-with-idle-timer not working unless there is some activity Jean Louis
2025-01-04 17:56 ` Ship Mints
2025-01-04 19:21 ` Jean Louis [this message]
2025-01-06 20:47 ` bug#75361: SOLVED - " Ship Mints
2025-01-10 15:42 ` Jean Louis
2025-01-10 20:22 ` Eli Zaretskii
2025-01-04 18:46 ` Eli Zaretskii
2025-01-06 21:28 ` Stefan Kangas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z3mKT_fOiBY815rF@lco2 \
--to=bugs@gnu.support \
--cc=75361@debbugs.gnu.org \
--cc=shipmints@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).