From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.devel Subject: Re: unwind-protect within while-no-input Date: Thu, 09 May 2024 08:57:57 -0400 Organization: Jane Street Capital Message-ID: References: <86msp1a24a.fsf@gnu.org> <87le4l2btq.fsf@yahoo.com> <874jb8il6t.fsf@web.de> <87y18kh6eg.fsf@web.de> <87h6f8gu43.fsf@web.de> <87v83of30t.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35377"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: emacs-devel@gnu.org Cancel-Lock: sha1:zFReFw0tC2hDmZZjej8E251mF0w= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu May 09 15:49:57 2024 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 1s549k-0008wl-V8 for ged-emacs-devel@m.gmane-mx.org; Thu, 09 May 2024 15:49:56 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s549B-0007sU-A7; Thu, 09 May 2024 09:49:21 -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 1s53Ld-0003Xj-PP for emacs-devel@gnu.org; Thu, 09 May 2024 08:58:09 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s53Lc-0007Az-4b for emacs-devel@gnu.org; Thu, 09 May 2024 08:58:09 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1s53LZ-0002gW-Aj for emacs-devel@gnu.org; Thu, 09 May 2024 14:58:05 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 09 May 2024 09:49:20 -0400 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:319078 Archived-At: Michael Heerdegen via "Emacs development discussions." writes: > Spencer Baugh writes: > >> > #+begin_src emacs-lisp >> > (let (foo) >> > (while-no-input >> > (unwind-protect (while t nil) >> > (let ((inhibit-quit t)) >> > (sleep-for 10) >> > (setq foo 'interrupted) >> > (message "foo: %s" foo))) >> > (message "foo: %s" foo))) >> > #+end_src >> > >> > (unwind forms are not per se protected from nonlocal exiting - see >> > documentation) >> >> That seems to work, but is it robust? >> >> If while-no-input can raise a quit between the start of executing >> unwindforms and the binding of inhibit-quit, then the unwind forms will >> not execute. > > AFAIK, unwind forms are always handled, but they can be exited > nonlocally. Above there is only one, and is protected, so I guess it is > save. That unwind-form is only protected once inhibit-quit is bound. But at the start of its evaluation, it is not protected because inhibit-quit is not bound. Is it possible for a quit to be raised there, before the protection starts? >> Can while-no-input/throw-on-input actually raise a quit then? And is >> this behavior documented anywhere? > > I don't understand the first question. The fact that we protect code > against quitting does not prevent quit being triggered - only in > which way the stack is unwinded...right? > > Michael.