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.bugs Subject: bug#67836: 29.1.90; map-y-or-n-p doesn't terminate when run in a kmacro in batch mode Date: Fri, 15 Dec 2023 10:44:47 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18974"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Monnier To: 67836@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 15 16:45:23 2023 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 1rEANO-0004gp-Jl for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 Dec 2023 16:45:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rEAN7-0001Mw-B9; Fri, 15 Dec 2023 10:45:05 -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 1rEAN4-0001Mh-PU for bug-gnu-emacs@gnu.org; Fri, 15 Dec 2023 10:45:03 -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 1rEAN4-0000KI-8M for bug-gnu-emacs@gnu.org; Fri, 15 Dec 2023 10:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rEAN4-0005Ky-64 for bug-gnu-emacs@gnu.org; Fri, 15 Dec 2023 10:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Dec 2023 15:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67836 X-GNU-PR-Package: emacs Original-Received: via spool by 67836-submit@debbugs.gnu.org id=B67836.170265509520486 (code B ref 67836); Fri, 15 Dec 2023 15:45:02 +0000 Original-Received: (at 67836) by debbugs.gnu.org; 15 Dec 2023 15:44:55 +0000 Original-Received: from localhost ([127.0.0.1]:53379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rEAMw-0005KM-L2 for submit@debbugs.gnu.org; Fri, 15 Dec 2023 10:44:55 -0500 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:40195) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rEAMu-0005K9-OY for 67836@debbugs.gnu.org; Fri, 15 Dec 2023 10:44:53 -0500 In-Reply-To: (Spencer Baugh's message of "Fri, 15 Dec 2023 10:38:47 -0500") 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:276275 Archived-At: --=-=-= Content-Type: text/plain Patch fixing this. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Make-ding-terminate-keyboard-macros-even-in-batch-mo.patch >From f894cbede9b65e6449c80393efb9d3417c9f661c Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Fri, 15 Dec 2023 09:57:19 -0500 Subject: [PATCH] Make ding terminate keyboard macros even in batch mode ding's docstring states that it terminates keyboard macros. But, due to what seems to be an oversight, it does not do that while executing in batch mode. Generally, this means that some functions may infinite loop while run in a keyboard macro in batch mode. One concrete example: map-y-or-n-p will infinite-loop if run in a keyboard macro while in batch mode. Now ding properly terminates keyboard macros while running in batch mode. A test showing map-y-or-n-p behaves correctly in keyboard macros is included. * src/dispnew.c (bitch_at_user): Always signal while in a keyboard macro, even if in batch mode. (bug#67836) * test/lisp/emacs-lisp/map-ynp-tests.el (map-ynp-tests-simple-call) (test-map-ynp-kmacro): Add. --- src/dispnew.c | 6 ++-- test/lisp/emacs-lisp/map-ynp-tests.el | 46 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 test/lisp/emacs-lisp/map-ynp-tests.el diff --git a/src/dispnew.c b/src/dispnew.c index e4037494775..645311be8c0 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -6185,14 +6185,14 @@ DEFUN ("ding", Fding, Sding, 0, 1, 0, void bitch_at_user (void) { - if (noninteractive) - putchar (07); - else if (!INTERACTIVE) /* Stop executing a keyboard macro. */ + if (!NILP (Vexecuting_kbd_macro)) /* Stop executing a keyboard macro. */ { const char *msg = "Keyboard macro terminated by a command ringing the bell"; Fsignal (Quser_error, list1 (build_string (msg))); } + else if (noninteractive) + putchar (07); else ring_bell (XFRAME (selected_frame)); } diff --git a/test/lisp/emacs-lisp/map-ynp-tests.el b/test/lisp/emacs-lisp/map-ynp-tests.el new file mode 100644 index 00000000000..4f5d10ee7f9 --- /dev/null +++ b/test/lisp/emacs-lisp/map-ynp-tests.el @@ -0,0 +1,46 @@ +;;; map-ynp-tests.el --- Tests for map-ynp.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Free Software Foundation, Inc. + +;; Author: Spencer Baugh +;; Maintainer: emacs-devel@gnu.org + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;; Tests for map-ynp.el. + +;;; Code: + +(require 'ert) + +(defun map-ynp-tests-simple-call () + (map-y-or-n-p "" #'ignore '(1))) + +(ert-deftest test-map-ynp-kmacro () + "Test that map-y-or-n-p in a kmacro terminates on end of input" + (execute-kbd-macro (read-kbd-macro "M-: (map-ynp-tests-simple-call) RET y")) + (should-error + (execute-kbd-macro (read-kbd-macro "M-: (map-ynp-tests-simple-call) RET"))) + (unless noninteractive + (let ((noninteractive t)) + (execute-kbd-macro (read-kbd-macro "M-: (map-ynp-tests-simple-call) RET y")) + (should-error + (execute-kbd-macro (read-kbd-macro "M-: (map-ynp-tests-simple-call) RET")))))) + +(provide 'map-ynp-tests) +;;; map-ynp-tests.el ends here -- 2.39.3 --=-=-=--