From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#61091: 30.0.50; y-or-n-p clobbers match data Date: Sat, 04 Feb 2023 10:16:54 +0200 Message-ID: <83357lvo95.fsf@gnu.org> References: <83bkmkct2s.fsf@gnu.org> <83ilgp972w.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24906"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61091-done@debbugs.gnu.org To: rms@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 04 09:18:53 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 1pODl6-0006H9-DY for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 Feb 2023 09:18:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pODkv-000795-3f; Sat, 04 Feb 2023 03:18:43 -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 1pODkM-0006zX-LR for bug-gnu-emacs@gnu.org; Sat, 04 Feb 2023 03:18:07 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pODkJ-00064L-1o for bug-gnu-emacs@gnu.org; Sat, 04 Feb 2023 03:18:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pODkI-0007Qv-BE for bug-gnu-emacs@gnu.org; Sat, 04 Feb 2023 03:18:02 -0500 Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Feb 2023 08:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 61091 X-GNU-PR-Package: emacs Mail-Followup-To: 61091@debbugs.gnu.org, eliz@gnu.org, rms@gnu.org Original-Received: via spool by 61091-done@debbugs.gnu.org id=D61091.167549862228498 (code D ref 61091); Sat, 04 Feb 2023 08:18:02 +0000 Original-Received: (at 61091-done) by debbugs.gnu.org; 4 Feb 2023 08:17:02 +0000 Original-Received: from localhost ([127.0.0.1]:40603 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pODjK-0007PS-4J for submit@debbugs.gnu.org; Sat, 04 Feb 2023 03:17:02 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:34800) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pODjG-0007P2-Cv for 61091-done@debbugs.gnu.org; Sat, 04 Feb 2023 03:17:00 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pODjB-0005hk-5X for 61091-done@debbugs.gnu.org; Sat, 04 Feb 2023 03:16:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=aOvm8SdAMF/9DI/GdT7uMwebAEhEAP/yf8IAY2bi37U=; b=M0/g5MrDsbnR yjEUdO5kSSL4fCyDUFkBzIakcnfuOLAH0IfTUqq2e1gx6TV5veTnRA7O1z7INRjigLuN6lVq3XJTS L5UKNLQY9ctT3gkY3qJDyqAwCHvKwy8Xzds+9H+I7QZiPhF2NODo/v+/hBU22K4UUmbtzjwqqbLBC sou/PJWL9rhwEzTAnSVXPBphd0bVTFY5Y8M77/rmw2+czzMdOH6y/GiissvML+r0BJQ5fJ/y1MvKR 48CCgHgPhct0pKmF1yYZ0i8lfdielplx1u3cSTZoyY+h5W4bUjiaKvFH9JRAP5Jg5sOOWMrYrLDVi 84IKKlKMn7ds/Dp2MS6VjA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pODj5-0007he-35; Sat, 04 Feb 2023 03:16:47 -0500 In-Reply-To: (message from Richard Stallman on Sat, 04 Feb 2023 00:15:24 -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:254754 Archived-At: > From: Richard Stallman > Cc: 61091@debbugs.gnu.org > Date: Sat, 04 Feb 2023 00:15:24 -0500 > > > > Allowance should be made for the fact that `y-or-n-p' > > > was safe for the match data for over 35 years. > > > I don't object if it's easy to do so. > > I think it should be easy. How about trying it? Done with the patch below. diff --git a/lisp/subr.el b/lisp/subr.el index 0f754fc..32c9974 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3573,12 +3573,14 @@ y-or-n-p (if (or (zerop l) (eq ?\s (aref prompt (1- l)))) "" " ") (if dialog "" - (substitute-command-keys - (if help-form - (format "(\\`y', \\`n' or \\`%s') " - (key-description - (vector help-char))) - "(\\`y' or \\`n') "))))))) + ;; Don't clobber caller's match data. + (save-match-data + (substitute-command-keys + (if help-form + (format "(\\`y', \\`n' or \\`%s') " + (key-description + (vector help-char))) + "(\\`y' or \\`n') ")))))))) ;; Preserve the actual command that eventually called ;; `y-or-n-p' (otherwise `repeat' will be repeating ;; `exit-minibuffer').