]> git.eshelyaron.com Git - emacs.git/commitdiff
Use substitute-command-keys in map-y-or-n-p
authorStefan Kangas <stefankangas@gmail.com>
Mon, 16 Dec 2024 20:46:12 +0000 (21:46 +0100)
committerEshel Yaron <me@eshelyaron.com>
Mon, 23 Dec 2024 15:06:27 +0000 (16:06 +0100)
* 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

index 7b135c54a150947091ef6139ee98fe76cf9f9d47..8ba88972a89e3ca6f1aaa1e43ffff185ba71f80d 100644 (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))))