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 (or (zerop l) (eq ?\s (aref prompt (1- l))))
"" " ") "" " ")
(if dialog "" (if dialog ""
(substitute-command-keys ;; Don't clobber caller's match data.
(if help-form (save-match-data
(format "(\\`y', \\`n' or \\`%s') " (substitute-command-keys
(key-description (if help-form
(vector help-char))) (format "(\\`y', \\`n' or \\`%s') "
"(\\`y' or \\`n') "))))))) (key-description
(vector help-char)))
"(\\`y' or \\`n') "))))))))
;; Preserve the actual command that eventually called ;; Preserve the actual command that eventually called
;; `y-or-n-p' (otherwise `repeat' will be repeating ;; `y-or-n-p' (otherwise `repeat' will be repeating
;; `exit-minibuffer'). ;; `exit-minibuffer').