From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <87r05jpm38.fsf@gnu.support> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14398"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.2.12 (2023-09-09) Cc: 75361@debbugs.gnu.org To: Ship Mints Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 06 21:30:45 2025 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tUtkL-0003bc-Cp for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Jan 2025 21:30:45 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUtjx-0005NH-Ks; Mon, 06 Jan 2025 15:30:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tUtjh-0005Fy-7K for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 15:30:05 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tUtjf-0006Ak-9O for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 15:30:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=In-Reply-To:Mime-Version:References:From:Date:To:Subject; bh=Jm5FSGaRD3yFum4m7ucBA8G4wQdkTvYGWQijmfjEYn0=; b=XDWM5VI46X0rFvhcuoQiLuKlF3rTQBDiRN4R21wG0Te79TgPR4oa8rhTrhkUIVvCxYL/7TvEI2VFMm/M1uh9ygvt2ICsgjCfC1wmAAHTGoN1fecE+mefXmlOUVPnIMJ2xxog4uS9RhotVRakA6AISAd9Ip/5zAOz8Mbeie/RZldqYSgEm+hKyJ1AlJUkzmgCfvu00cWLj3OTwEUGnQUFQT/ENhYwQTi+CtKNwPoflbx+c/27d5i6cBB8eVPnT8OLj7rvgcF9YRIMBxKUZLv+Gq146fB2QVjWg7hUD/Jo7ZOCdTAh938Ifgus+fCAGkd/PrkVTymWBw+kbup50sXbqg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tUtje-0001Da-Am for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 15:30:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jean Louis Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Jan 2025 20:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75361 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 75361-submit@debbugs.gnu.org id=B75361.17361953894638 (code B ref 75361); Mon, 06 Jan 2025 20:30:02 +0000 Original-Received: (at 75361) by debbugs.gnu.org; 6 Jan 2025 20:29:49 +0000 Original-Received: from localhost ([127.0.0.1]:40303 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tUtjR-0001Cj-Ai for submit@debbugs.gnu.org; Mon, 06 Jan 2025 15:29:49 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:47543) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tUtjO-0001CU-7C for 75361@debbugs.gnu.org; Mon, 06 Jan 2025 15:29:47 -0500 Original-Received: from localhost ([::ffff:41.75.173.43]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000001BF3B.00000000677C3D37.001A8DC5; Mon, 06 Jan 2025 13:29:42 -0700 Content-Disposition: inline In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:298698 Archived-At: * Ship Mints [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 > ), > 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