diff --git a/lisp/help.el b/lisp/help.el index 72a4f8a800d..4a93e1cd915 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -2253,6 +2253,22 @@ help-form-show (with-output-to-temp-buffer " *Char Help*" (princ msg))))) +(defun help--append-suffix (str map) + (catch 'res + (dolist (val help-event-list) + (let ((key (vector (if (eql val 'help) + help-char + val)))) + (unless (and map (lookup-key map key)) + (throw 'res + (concat + str + (substitute-command-keys + (format + " (\\`%s' for help)" + (key-description key)))))))) + str)) + (defun help--docstring-quote (string) "Return a doc string that represents STRING. diff --git a/src/keyboard.c b/src/keyboard.c index 10cdef67348..8467b48c266 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -335,7 +335,7 @@ #define GROW_RAW_KEYBUF \ static void recursive_edit_unwind (Lisp_Object buffer); static Lisp_Object command_loop (void); -static void echo_now (void); +static void echo_now (Lisp_Object map); static ptrdiff_t echo_length (void); static void safe_run_hooks_maybe_narrowed (Lisp_Object, struct window *); @@ -553,7 +553,7 @@ echo_add_key (Lisp_Object c) character. */ static void -echo_dash (void) +echo_dash (Lisp_Object map) { /* Do nothing if not echoing at all. */ if (NILP (KVAR (current_kboard, echo_string))) @@ -595,15 +595,14 @@ echo_dash (void) if (echo_keystrokes_help) { - Lisp_Object help; - - help = build_string (" (\\`C-h' or \\`' for help)"); - kset_echo_string (current_kboard, - concat2 (KVAR (current_kboard, echo_string), - calln (Qsubstitute_command_keys, help))); + kset_echo_string (current_kboard, + CALLN (Ffuncall, + intern_c_string ("help--append-suffix"), + KVAR (current_kboard, echo_string), + map)); } - echo_now (); + echo_now (map); } static void @@ -629,7 +628,7 @@ echo_update (void) echo_add_key (c); } - echo_now (); + echo_now (Qnil); } } @@ -637,7 +636,7 @@ echo_update (void) doing so. */ static void -echo_now (void) +echo_now (Lisp_Object map) { if (!current_kboard->immediate_echo /* This test breaks calls that use `echo_now' to display the echo_prompt. @@ -646,7 +645,7 @@ echo_now (void) current_kboard->immediate_echo = true; echo_update (); /* Put a dash at the end to invite the user to type more. */ - echo_dash (); + echo_dash (map); } echoing = true; @@ -1597,7 +1596,7 @@ command_loop_1 (void) { current_kboard->immediate_echo = false; /* Refresh the echo message. */ - echo_now (); + echo_now (Qnil); } else cancel_echoing (); @@ -2739,7 +2738,7 @@ read_char (int commandflag, Lisp_Object map, || ok_to_echo_at_next_pause == NULL)) cancel_echoing (); else - echo_dash (); + echo_dash (map); /* Try reading a character via menu prompting in the minibuf. Try this before the sit-for, because the sit-for @@ -2846,7 +2845,7 @@ read_char (int commandflag, Lisp_Object map, This is because we are probably about to display a menu, and we don't want to delay before doing so. */ if (EVENT_HAS_PARAMETERS (prev_event)) - echo_now (); + echo_now (map); else { Lisp_Object tem0; @@ -2859,7 +2858,7 @@ read_char (int commandflag, Lisp_Object map, unbind_to (count, Qnil); if (EQ (tem0, Qt) && ! CONSP (Vunread_command_events)) - echo_now (); + echo_now (map); } } @@ -3263,7 +3262,7 @@ read_char (int commandflag, Lisp_Object map, kset_echo_string (current_kboard, saved_echo_string); kset_echo_prompt (current_kboard, saved_echo_prompt); if (saved_immediate_echo) - echo_now (); + echo_now (map); /* The input method can return no events. */ if (! CONSP (tem)) @@ -10490,7 +10489,7 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt, since it forces us to fiddle with current_kboard->immediate_echo before and after. */ current_kboard->immediate_echo = false; - echo_now (); + echo_now (Qnil); if (!echo_keystrokes_p ()) current_kboard->immediate_echo = false; } @@ -10499,7 +10498,7 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt, && echo_keystrokes_p ()) /* This doesn't put in a dash if the echo buffer is empty, so you don't always see a dash hanging out in the minibuffer. */ - echo_dash (); + echo_dash (Qnil); } /* Record the initial state of the echo area and this_command_keys; @@ -10695,7 +10694,7 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt, /* Set immediate_echo to false so as to force echo_now to redisplay (it will set immediate_echo right back to true). */ current_kboard->immediate_echo = false; - echo_now (); + echo_now (Qnil); } used_mouse_menu = used_mouse_menu_history[t]; }