From 4e8448b4bc5aae297c053080bc04208f5a0793e8 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 11 Jul 2022 14:51:34 +0200 Subject: [PATCH] Allow commands that call `yes-or-no-p' to be repeatable again * lisp/subr.el (y-or-n-p): Enable commands that call this function to be repeatable (bug#45999). This stopped working after this function started using read-from-minibuffer. * src/fns.c (Fyes_or_no_p): Ditto. --- lisp/subr.el | 7 +++++-- src/fns.c | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/subr.el b/lisp/subr.el index f8b386e5631..ef2edcff102 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3482,8 +3482,11 @@ like) while `y-or-n-p' is running)." (format "(y, n or %s) " (key-description (vector help-char))) - "(y or n) " - ))))))) + "(y or n) ")))))) + ;; Preserve the actual command that eventually called + ;; `y-or-n-p' (otherwise `repeat' will be repeating + ;; `exit-minibuffer'). + (real-this-command real-this-command)) (cond (noninteractive (setq prompt (funcall padded prompt)) diff --git a/src/fns.c b/src/fns.c index eb83471649e..1f57e675b12 100644 --- a/src/fns.c +++ b/src/fns.c @@ -2975,6 +2975,9 @@ if `last-nonmenu-event' is nil, and `use-dialog-box' is non-nil. */) specpdl_ref count = SPECPDL_INDEX (); specbind (Qenable_recursive_minibuffers, Qt); + /* Preserve the actual command that eventually called `yes-or-no-p' + (otherwise `repeat' will be repeating `exit-minibuffer'). */ + specbind (Qreal_this_command, Vreal_this_command); while (1) { @@ -6129,4 +6132,6 @@ The same variable also affects the function `read-answer'. */); defsubr (&Sbuffer_hash); defsubr (&Slocale_info); defsubr (&Sbuffer_line_statistics); + + DEFSYM (Qreal_this_command, "real-this-command"); } -- 2.39.5