From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#48603: 27.2; [PATCH] Quit minibuffers without aborting kmacros Date: Wed, 01 Sep 2021 08:58:04 +0200 Message-ID: <87o89cdbpf.fsf@miha-pc> References: <86eedx7c0u.fsf@miha-pc> <877djmegh8.fsf@gnus.org> <86r1hu4hws.fsf@miha-pc> <877dhlf9ex.fsf@gnus.org> <87czqbzo5g.fsf@tcd.ie> Reply-To: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5019"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48603@debbugs.gnu.org To: "Basil L. Contovounesios" , Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 01 09:01:48 2021 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 1mLKFm-00012g-4d for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Sep 2021 09:01:46 +0200 Original-Received: from localhost ([::1]:42404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLKFk-0002K2-V1 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Sep 2021 03:01:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLKAH-0005NT-AQ for bug-gnu-emacs@gnu.org; Wed, 01 Sep 2021 02:56:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52667) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mLKAE-00028m-0I for bug-gnu-emacs@gnu.org; Wed, 01 Sep 2021 02:56:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mLKAD-0002At-Sz for bug-gnu-emacs@gnu.org; Wed, 01 Sep 2021 02:56:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Sep 2021 06:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48603 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 48603-submit@debbugs.gnu.org id=B48603.16304793158306 (code B ref 48603); Wed, 01 Sep 2021 06:56:01 +0000 Original-Received: (at 48603) by debbugs.gnu.org; 1 Sep 2021 06:55:15 +0000 Original-Received: from localhost ([127.0.0.1]:35980 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mLK9S-00029t-Vt for submit@debbugs.gnu.org; Wed, 01 Sep 2021 02:55:15 -0400 Original-Received: from kamnitnik.top ([209.250.245.214]:56548 helo=mail.kamnitnik.top) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mLK9O-00029e-Tg for 48603@debbugs.gnu.org; Wed, 01 Sep 2021 02:55:13 -0400 Original-Received: from localhost (unknown [IPv6:2a00:ee2:e04:9300:e609:6c46:d026:8c47]) by mail.kamnitnik.top (Postfix) with ESMTPSA id 569D6BCF6B; Wed, 1 Sep 2021 06:55:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1630479308; bh=FJTBU/IOL8SbUXUo41iSCklJ5XptfNnZADlvjZA4Gvo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=mXieUL0zMCGUsta38Nf/pYqPAZPeKyFv+MbIoLp1MCp7H33t0GKB0aA4mYm2OGHEq ZKf3tbIEsvyCh9duV1VVbVJl4pk79DEJvsEgQD+sx2ygA7tUI/5365y2CyzS0h7VMH p1xbJtPEhKcYkxcs4zemx1iuKoyfGsGG0bBTo2uYKJOiScgGGAqvFw9NgNA4VfhmTC TJbxwYbirdKJkqIOqUNyErctdZNa6wHO9QmTwg7VMB4SIm12X3w0DPu/690K0Dp1BI acGygaCx8yuTjqTOOj/uorJW3OhgCWfHbj+TVbl39nbjlysCNWcRbKxEKkqIPZHGrl CoX0CzQiIpJbw== In-Reply-To: <87czqbzo5g.fsf@tcd.ie> 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" Xref: news.gmane.io gmane.emacs.bugs:213141 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" writes: > Lars Ingebrigtsen [2021-07-20 14:37 +0200] wrote: > >> writes: >> >>> Good idea, attaching a revised patch (which also adds two NEWS entries.) >> >> Sorry; I forgot all about this. I've now re-read and tested the patch, >> and it seems to work fine for me, so I've pushed it to Emacs 28. > > Thanks, but given the following file quit.el, which is distilled from > the Ivy package's batch-run test suite: > [...] > IOW, it's no longer possible to catch the quit around execute-kbd-macro. > I tried wrapping it in (catch 'exit ...) as well, but to no avail. > Surely it should always be possible to catch a quit condition from Lisp? > In order to make C-g from a minibuffer not abort kmacro execution, execute-kbd-macro was made to catch the minibuffer-quit condition, handle it with the default error handler (command-error-function) and continue with kmacro execution. In batch mode, this error handler kills Emacs with status 255. Please consider the attached patch, which avoids killing for the minibuffer-quit condition. However, even with this patch, slight change in behaviour still remains: - In Emacs 27, C-g in the minibuffer is bound to abort-recursive-edit which makes execute-kbd-macro signal an error (a quit). - In Emacs 28, C-g is bound to abort-minibuffers. This command will not make execute-kbd-macro signal any errors. I hope this change in default behaviour is acceptable, otherwise it wouldn't be possible to have C-g continue with kmacro execution. For test suites, you can get back the old behaviour with (define-key minibuffer-local-map "\C-g" #'abort-recursive-edit) Sorry for late reply, best regards. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-In-batch-mode-avoid-killing-Emacs-with-C-g-in-the-mi.patch Content-Transfer-Encoding: quoted-printable From=20dac1a0ccca5678dda4b331d1a788a8432c9a7a03 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Miha=3D20Rihtar=3DC5=3DA1i=3DC4=3D8D?=3D Date: Wed, 1 Sep 2021 08:32:25 +0200 Subject: [PATCH] In batch mode, avoid killing Emacs with C-g in the minibuf= fer * src/keyboard.c (Fcommand_error_default_function): Don't kill emacs when handling the minibuffer-quit condition (bug#48603). =2D-- src/keyboard.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/keyboard.c b/src/keyboard.c index 81ff9df153..6a8c33ae3b 100644 =2D-- a/src/keyboard.c +++ b/src/keyboard.c @@ -1009,25 +1009,28 @@ DEFUN ("command-error-default-function", Fcommand_e= rror_default_function, (Lisp_Object data, Lisp_Object context, Lisp_Object signal) { struct frame *sf =3D SELECTED_FRAME (); =2D Lisp_Object conditions; + Lisp_Object conditions =3D Fget (XCAR (data), Qerror_conditions); + int is_minibuffer_quit =3D !NILP (Fmemq (Qminibuffer_quit, conditions)); =20 CHECK_STRING (context); =20 /* If the window system or terminal frame hasn't been initialized =2D yet, or we're not interactive, write the message to stderr and exit= . */ =2D if (!sf->glyphs_initialized_p =2D /* The initial frame is a special non-displaying frame. It =2D will be current in daemon mode when there are no frames =2D to display, and in non-daemon mode before the real frame =2D has finished initializing. If an error is thrown in the =2D latter case while creating the frame, then the frame =2D will never be displayed, so the safest thing to do is =2D write to stderr and quit. In daemon mode, there are =2D many other potential errors that do not prevent frames =2D from being created, so continuing as normal is better in =2D that case. */ =2D || (!IS_DAEMON && FRAME_INITIAL_P (sf)) =2D || noninteractive) + yet, or we're not interactive, write the message to stderr and exit. + Don't do this for the minibuffer-quit condition. */ + if (!is_minibuffer_quit + && (!sf->glyphs_initialized_p + /* The initial frame is a special non-displaying frame. It + will be current in daemon mode when there are no frames + to display, and in non-daemon mode before the real frame + has finished initializing. If an error is thrown in the + latter case while creating the frame, then the frame + will never be displayed, so the safest thing to do is + write to stderr and quit. In daemon mode, there are + many other potential errors that do not prevent frames + from being created, so continuing as normal is better in + that case. */ + || (!IS_DAEMON && FRAME_INITIAL_P (sf)) + || noninteractive)) { print_error_message (data, Qexternal_debugging_output, SSDATA (context), signal); @@ -1036,12 +1039,10 @@ DEFUN ("command-error-default-function", Fcommand_e= rror_default_function, } else { =2D conditions =3D Fget (XCAR (data), Qerror_conditions); =2D clear_message (1, 0); message_log_maybe_newline (); =20 =2D if (!NILP (Fmemq (Qminibuffer_quit, conditions))) + if (is_minibuffer_quit) { Fding (Qt); } =2D-=20 2.32.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmEvJHwTHG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZP5cDEACwU1+7dNdOwPII8AGFRq0BjlosYItc 8Zzkv2Q/CUUqUKCLI7dUO6pjjrYXdtLBa7OlTGQt8n6MJbX+TRPfXWAR7cY3CX+m egwG0JKK4ZFBUm6ferkzDxZxY0kWAhVX2w8K1jq3zziBO6HLIWevswJ/6DgAGRqn NFIWuBSdR3S7tLH5PlUgn5oJwkYW15tMbIqgcFXbQIro8qOGbI+qVuFfEEFPj2TK CGUfyvdjR+5J45bvfZ1aqlSOl0A8hA9SOitxrnMPHxGR4m66j7Uaka8XKH7F3oqV BsLtgGEntiOmzLPNxX4pu/aduDcemXRuC6tjEpmEWrW4gFk3F3YNYJKFbb4/VF23 tHKa3PhIDP2glRo7sd2aUiSez+ybk29clComVTH2No7vKS3DZM1YjJs0wiV2fste oJAMB97GpsrU//wzm+c6Pu7OX2WhqRi1zYx7OmO2I/rloha7BKdmgQi79kfNOYxS wZwAPucP75OVwgbFOeockCJV4AVfzvgnnk4luMKvdIdPHhOuYaKGdjd71TIoH7Kg WySgA9FsRtgGJcayez69VF3zZXRQqS/kbwBaPGXPt65aM60QCwkjNYq+zKnwEpcK cLjrh8zxEdYHPfxBCSyN3a5QGpszY6LiOWvXDaNaxck47yIhogPfd5kPKwUrNU25 QRADHpKvaBcXvg== =kgxU -----END PGP SIGNATURE----- --==-=-=--