From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#70221: [PATCH] New function `funcall-later` Date: Sat, 06 Apr 2024 16:00:53 -0400 Message-ID: References: <86zfu73smn.fsf@gnu.org> <864jce34yv.fsf@gnu.org> <86wmpa1n7s.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7019"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 70221@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 06 22:02:16 2024 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 1rtCEw-0001Zh-Tx for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Apr 2024 22:02:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rtCEj-0004Ca-MU; Sat, 06 Apr 2024 16:02:01 -0400 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 1rtCEf-0004CI-Go for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2024 16:01:57 -0400 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 1rtCEf-0003Rx-8y for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2024 16:01:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rtCEl-0003GW-7B for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2024 16:02:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Apr 2024 20:02:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70221 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70221-submit@debbugs.gnu.org id=B70221.171243367312382 (code B ref 70221); Sat, 06 Apr 2024 20:02:03 +0000 Original-Received: (at 70221) by debbugs.gnu.org; 6 Apr 2024 20:01:13 +0000 Original-Received: from localhost ([127.0.0.1]:41006 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rtCDw-0003DZ-BH for submit@debbugs.gnu.org; Sat, 06 Apr 2024 16:01:13 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:3149) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rtCDr-0003CQ-QS for 70221@debbugs.gnu.org; Sat, 06 Apr 2024 16:01:10 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D207880C88; Sat, 6 Apr 2024 16:00:55 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1712433654; bh=1/diFS5+SttDUoti+GjwqHB/M48Odn3/KBpZNNalKqw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=T/EtbYOooix2m08NCH88v0l6x88v8EA8o3ebp6pbevKSbwZt9tKwkDHKlcsMmgYDd f1M3DZj25uvTDaqYHcHM2bbaRwlWDv3JLr2wvllzsXfFwyb4MJW573N2qdDW8Y+rtC CA9kMeXcCcGHERIPwpjBqgNKRqOxOOK2aMX59EURntM0EUmezvsiiKGV7MSeCsX2QM stYgly+ODz5s1PHA+Qml7C/RvMh17YQLjqZma1cegvIUMksiiTR0KX1958aozA43mz BWZmCidhNYOmPpe8s+lgBVcTlE3cO5mSbPzL3ObwV8+15kGy6stexRjIIcyt9jCxXR IDtaEyW10fSPw== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D7366808F9; Sat, 6 Apr 2024 16:00:54 -0400 (EDT) Original-Received: from pastel (unknown [45.72.201.215]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B5E1D120611; Sat, 6 Apr 2024 16:00:54 -0400 (EDT) In-Reply-To: <86wmpa1n7s.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 06 Apr 2024 19:15:51 +0300") 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:282821 Archived-At: >> `condition-case-unless-debug` is very different from `safe_calln`. >> It doesn't prevent non-local exits nor prevent showing a debugger. > It catches errors, doesn't it? What's good about it? > That's what bothers me with CALLN. With CALLN the errors don't get caught by `safe_calln` so they get caught further up the stack, which seems fine by me. What problem/scenario are you thinking about? >> >> I can't see any good reason why we'd need to protect the >> >> C code from non-local exits in `timer_check_2`. >> > Because it will prevent timers from being called? >> >> Why would it? after the non-exit is caught somewhere up the stack, we'd >> eventually come back to `timer_check_2` and run the timer then. > > Unless the same buggy funcall-later is again in the list, right? No: we bump it off the list before the CALLN, specifically to avoid this problem. They don't auto-repeat like some timers. >> > From my POV, any code that runs from some background facility must >> > inhibit QUIT, because the user can type C-g at any moment. >> Agreed, and `funcall-later` doesn't run it "in the background", it runs >> it at the end of the current code. > How is this different from running timers? Non-0s timers are run in the context of some future command (or in the middle of "idle" time). `funcall-later` are run before we get to idle time or to the next user input, so if the user hits C-g during them, it's no different from hitting C-g during the main part of the command. It's realy more like `post-command-hook` (incidentally, I've been thinking that maybe we should call `internal--run-pending-funcalls` when we run `post-command-hook`). >> - It determines which part of the time-behavior we should consider as >> something we want to document and guarantee, as opposed to the part >> which is incidental and which we may prefer to document as not to be >> relied on. > I'm not sure I understand where you are going with this. It seems > very easy to tell when the delayed functions will be called, so why > are we arguing? I'm not sure the current implementation provides the behavior we want. So I think it's worthwhile thinking about what it is that we want. E.g. another implementation could be to have a separate thread running those functions. Or as mentioned above we could run them from `post-command-hook`. ... Stefan