From 00dd992be17bd02b03332998aff325bb7dad9457 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 16 Dec 2024 21:46:12 +0100 Subject: [PATCH] Use substitute-command-keys in map-y-or-n-p * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): Use substitute-command-keys. (cherry picked from commit 5c1889c964c99fa3cb0cd91b7703d59bd9fcb495) --- lisp/emacs-lisp/map-ynp.el | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el index 7b135c54a15..8ba88972a89 100644 --- a/lisp/emacs-lisp/map-ynp.el +++ b/lisp/emacs-lisp/map-ynp.el @@ -135,8 +135,10 @@ The function's value is the number of actions taken." mouse-event last-nonmenu-event)) (setq user-keys (if action-alist (concat (mapconcat (lambda (elt) - (key-description - (vector (car elt)))) + (substitute-command-keys + (format "\\`%s'" + (key-description + (vector (car elt)))))) action-alist ", ") " ") "") @@ -165,10 +167,13 @@ The function's value is the number of actions taken." 'quit)) ;; Prompt in the echo area. (let ((cursor-in-echo-area (not no-cursor-in-echo-area))) - (message (apply 'propertize "%s(y, n, !, ., q, %sor %s) " - minibuffer-prompt-properties) - prompt user-keys - (key-description (vector help-char))) + (message (substitute-command-keys + (format + (apply #'propertize + "%s(\\`y', \\`n', \\`!', \\`.', \\`q', %sor \\`%s') " + minibuffer-prompt-properties) + prompt user-keys + (key-description (vector help-char))))) (if minibuffer-auto-raise (raise-frame (window-frame (minibuffer-window)))) (unwind-protect @@ -184,12 +189,14 @@ The function's value is the number of actions taken." (when (fboundp 'set-text-conversion-style) (set-text-conversion-style text-conversion-style))) ;; Show the answer to the question. - (message "%s(y, n, !, ., q, %sor %s) %s" - prompt user-keys - (key-description (vector help-char)) - (if (equal char -1) - "[end-of-keyboard-macro]" - (single-key-description char)))) + (message (substitute-command-keys + (format + "%s(\\`y', \\`n', \\`!', \\`.', \\`q', %sor \\`%s') %s" + prompt user-keys + (key-description (vector help-char)) + (if (equal char -1) + "[end-of-keyboard-macro]" + (single-key-description char)))))) (setq def (lookup-key map (vector char)))) (cond ((eq def 'exit) (setq next (lambda () nil))) @@ -264,8 +271,10 @@ Type \\`SPC' or \\`y' to %s the current %s; (funcall try-again)) (t ;; Random char. - (message "Type %s for help." - (key-description (vector help-char))) + (message (substitute-command-keys + (format + "Type \\`%s' for help" + (key-description (vector help-char))))) (beep) (sit-for 1) (funcall try-again)))) -- 2.39.5