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.
This commit is contained in:
Stefan Kangas 2024-12-16 21:46:12 +01:00
parent 826b11ddc6
commit 5c1889c964

View file

@ -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))))