From: Eli Zaretskii <eliz@gnu.org>
To: rms@gnu.org
Cc: 61091-done@debbugs.gnu.org
Subject: bug#61091: 30.0.50; y-or-n-p clobbers match data
Date: Sat, 04 Feb 2023 10:16:54 +0200 [thread overview]
Message-ID: <83357lvo95.fsf@gnu.org> (raw)
In-Reply-To: <E1pOAtY-0008CG-Ku@fencepost.gnu.org> (message from Richard Stallman on Sat, 04 Feb 2023 00:15:24 -0500)
> From: Richard Stallman <rms@gnu.org>
> 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').
prev parent reply other threads:[~2023-02-04 8:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-27 4:05 bug#61091: 30.0.50; y-or-n-p clobbers match data Richard Stallman
2023-01-27 7:52 ` Eli Zaretskii
2023-01-27 14:38 ` Michael Heerdegen
2023-01-27 15:00 ` Eli Zaretskii
2023-01-29 5:18 ` Richard Stallman
2023-01-29 6:40 ` Eli Zaretskii
2023-02-04 5:15 ` Richard Stallman
2023-02-04 8:16 ` Eli Zaretskii [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83357lvo95.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=61091-done@debbugs.gnu.org \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.