Don't clobber match data in 'y-or-n-p'

* lisp/subr.el (y-or-n-p): Avoid clobbering caller's match data.
(Bug#61091)
This commit is contained in:
Eli Zaretskii 2023-02-04 10:15:18 +02:00
parent 4c765d93ab
commit 3a64f81ebc

View file

@ -3573,12 +3573,14 @@ like) while `y-or-n-p' is running)."
(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').