From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Filipp Gunbin Newsgroups: gmane.emacs.devel Subject: Re: Why doesn't Emacs have an `active-timer-p' command, or why can't I find it? Date: Fri, 12 Nov 2021 17:12:24 +0300 Message-ID: References: <83lf1uzaw8.fsf@gnu.org> <87r1bmo068.fsf@telefonica.net> <87h7ci3x6h.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37563"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin) Cc: emacs-devel@gnu.org To: Rudolf Schlatte Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 12 15:14:17 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mlXJo-0009Ui-4X for ged-emacs-devel@m.gmane-mx.org; Fri, 12 Nov 2021 15:14:17 +0100 Original-Received: from localhost ([::1]:44684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlXJm-0005Nu-9P for ged-emacs-devel@m.gmane-mx.org; Fri, 12 Nov 2021 09:14:14 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlXIB-0004ex-1J for emacs-devel@gnu.org; Fri, 12 Nov 2021 09:12:35 -0500 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:37125) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlXI6-0007dZ-3Q for emacs-devel@gnu.org; Fri, 12 Nov 2021 09:12:31 -0500 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 96FD15C007C; Fri, 12 Nov 2021 09:12:27 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 12 Nov 2021 09:12:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type:content-transfer-encoding; s=fm1; bh= szpVkVAWtTGAD+T01W+zKtbkPc4zcHEJs0Nmmu3WBJU=; b=Yct893y6c6L/HG6n FPkf7p2zqIzzvx8EUdygrF4hThIfFeB0DnYvEr+UpLZocsjj90J5vQkGnl7dzSzV hkiSSxXtEFl/4m8oYNmWMxziuyKB3bGqibDwm5F8M9J9Pu7yeBX6u6anuwnN9GQ4 T+wyAThQ6wxl76UGV2Fcg0EhX3WeiksxDKhVCC5ngZcuZQTOWVXV5Nt4e6LhL/xK MX5VOFMFzP57Y1tqaue04TQQhykJY1SkVKbpdP7c4uT1I4mngEWgA+sVbNH1WuM4 rB660ffWbmIBCR+9gXoiEKnWLcg7cTk2IjAQa8b7Z9rVhN1UsYjUr1fr3TRvSThc FuZU5A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=szpVkVAWtTGAD+T01W+zKtbkPc4zcHEJs0Nmmu3WB JU=; b=jdj/MNTSEyQGHWRPVr5WoMbnfDUuiJ1KM2m8d1xDMfGyE3J6jXkDWzG58 y4hz+IWUVkMj4fAbUGiXXRL791Mny7ZcAnizFs+/CnyUbDA295yDDaFmd3zsnY0P VaobtmqjxITn8pLnkUJuK6rcS+yVh3UMZ8yO6aSfygduMX/cTJdzJuiySd+LQcBo TsxFy15//YXE2rfcQ81khdGLEsXVuOX1cue4hr/b5lAD2lJMEaaCi4wXKneuBZok 5StrIzSJRQOFkHHhGf/Ki/hIVS9cnRMVsZEGbLCGf8bb4S38B3ZebwzxI/GgHccc B9HadBzqr1Tz09a0wl4+wLrZ6nAng== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrvdefgdehkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufgjfhgffffkgggtgfesthhqre dttderjeenucfhrhhomhephfhilhhiphhpucfiuhhnsghinhcuoehfghhunhgsihhnsehf rghsthhmrghilhdrfhhmqeenucggtffrrghtthgvrhhnpeekvdekudelvddtvdelveejge etudfgvdelgfeftefgkeejheehvefhgfetffeigfenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehfghhunhgsihhnsehfrghsthhmrghilhdrfh hm X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 12 Nov 2021 09:12:26 -0500 (EST) In-Reply-To: (Rudolf Schlatte's message of "Fri, 12 Nov 2021 14:13:00 +0100") Received-SPF: pass client-ip=66.111.4.25; envelope-from=fgunbin@fastmail.fm; helo=out1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:279294 Archived-At: On 12/11/2021 14:13 +0100, Rudolf Schlatte wrote: > Lars Ingebrigtsen writes: > >> =C3=93scar Fuentes writes: >> >>> An implementation would be >>> >>> (defun timer-active-p (timer) >>> (timer--check timer) >>> (or (memq timer timer-list)) >>> (memq timer timer-idle-list)) >> >> Sounds useful to me. > > Of course, the form > > (when (timer-active-p my-timer) > (do-something-that-errors-when-timer-inactive my-timer)) > > can still throw an error, since the return value of `timer-active-p' is > outdated as soon as the function returns.. (Or can timers only fire > when Emacs is otherwise idle?) >From (elisp) Timers: --8<---------------cut here---------------start------------->8--- Emacs cannot run timers at any arbitrary point in a Lisp program; it can run them only when Emacs could accept output from a subprocess: namely, while waiting or inside certain primitive functions such as =E2=80=98sit-for=E2=80=99 or =E2=80=98read-event=E2=80=99 which _can_ wait.= Therefore, a timer=E2=80=99s execution may be delayed if Emacs is busy. However, the time of execution is very precise if Emacs is idle. --8<---------------cut here---------------end--------------->8--- So it depends on what do-something-that-errors-when-timer-inactive does.