emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 9449e0740c: Add face help-key-binding in help-char echo


From: Stefan Kangas
Subject: master 9449e0740c: Add face help-key-binding in help-char echo
Date: Wed, 5 Oct 2022 09:23:56 -0400 (EDT)

branch: master
commit 9449e0740cd97bbcdbaeb4713dc2dd51e65994fd
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    Add face help-key-binding in help-char echo
    
    * src/keyboard.c (echo_add_key): Add help-key-binding face to the
    "?" key in 'help-char' echo.  (Bug#57906)
    (syms_of_keyboard) <Qhelp_key_binding>: New DEFSYM.
---
 src/keyboard.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/src/keyboard.c b/src/keyboard.c
index da244904a4..8ab4a451b4 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -499,27 +499,18 @@ echo_add_key (Lisp_Object c)
                        STRING_MULTIBYTE (name), 1);
     }
 
+  Lisp_Object new_string = make_string (buffer, ptr - buffer);
   if ((NILP (echo_string) || SCHARS (echo_string) == 0)
       && help_char_p (c))
     {
-      static const char text[] = " (Type ? for further options)";
-      int len = sizeof text - 1;
-
-      if (size - (ptr - buffer) < len)
-       {
-         ptrdiff_t offset = ptr - buffer;
-         size += len;
-         buffer = SAFE_ALLOCA (size);
-         ptr = buffer + offset;
-       }
-
-      memcpy (ptr, text, len);
-      ptr += len;
+      AUTO_STRING (str, " (Type ? for further options)");
+      AUTO_LIST2 (props, Qface, Qhelp_key_binding);
+      Fadd_text_properties (make_fixnum (7), make_fixnum (8), props, str);
+      new_string = concat2 (new_string, str);
     }
 
-  kset_echo_string
-    (current_kboard,
-     concat2 (echo_string, make_string (buffer, ptr - buffer)));
+  kset_echo_string (current_kboard,
+                   concat2 (echo_string, new_string));
   SAFE_FREE ();
 }
 
@@ -12252,6 +12243,8 @@ syms_of_keyboard (void)
 
   DEFSYM (Qhelp_form_show, "help-form-show");
 
+  DEFSYM (Qhelp_key_binding, "help-key-binding");
+
   DEFSYM (Qecho_keystrokes, "echo-keystrokes");
 
   Fset (Qinput_method_exit_on_first_char, Qnil);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]