changeset 12710:26c09987d2f3

(describe_buffer_bindings): Print bindings from Vfunction_key_map and from Vkey_translation_map. (describe_translation): New function. (describe_command): Handle vector like string. (describe_map_tree): New arg TRANSL. Callers changed.
author Richard M. Stallman <rms@gnu.org>
date Fri, 28 Jul 1995 02:57:41 +0000
parents a3d74b20e0e2
children a8feaa42d775
files src/keymap.c
diffstat 1 files changed, 59 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/keymap.c	Fri Jul 28 02:54:28 1995 +0000
+++ b/src/keymap.c	Fri Jul 28 02:57:41 1995 +0000
@@ -73,6 +73,9 @@
    documentation.  */
 Lisp_Object Vfunction_key_map;
 
+/* Keymap mapping ASCII function key sequences onto their preferred forms.  */
+Lisp_Object Vkey_translation_map;
+
 /* A list of all commands given new bindings since a certain time
    when nil was stored here.
    This is used to speed up recomputation of menu key equivalents
@@ -90,7 +93,7 @@
 
 static Lisp_Object define_as_prefix ();
 static Lisp_Object describe_buffer_bindings ();
-static void describe_command ();
+static void describe_command (), describe_translation ();
 static void describe_map ();
 
 /* Keymap object support - constructors and predicates.			*/
@@ -1839,7 +1842,7 @@
   Fset_buffer (Vstandard_output);
 
   /* Report on alternates for keys.  */
-  if (STRINGP (Vkeyboard_translate_table))
+  if (STRINGP (Vkeyboard_translate_table) && !NILP (prefix))
     {
       int c;
       unsigned char *translate = XSTRING (Vkeyboard_translate_table)->data;
@@ -1869,6 +1872,10 @@
       insert ("\n", 1);
     }
 
+  if (!NILP (Vkey_translation_map))
+    describe_map_tree (Vkey_translation_map, 0, Qnil, prefix,
+		       "Key translations", 0, 1);
+
   {
     int i, nmaps;
     Lisp_Object *modes, *maps;
@@ -1876,6 +1883,7 @@
     /* Temporarily switch to descbuf, so that we can get that buffer's
        minor modes correctly.  */
     Fset_buffer (descbuf);
+
     if (!NILP (current_kboard->Voverriding_terminal_local_map)
 	|| !NILP (Voverriding_local_map))
       nmaps = 0;
@@ -1905,7 +1913,7 @@
 	p += sizeof (" Minor Mode Bindings") - 1;
 	*p = 0;
 
-	describe_map_tree (maps[i], 0, shadow, prefix, title, 0);
+	describe_map_tree (maps[i], 0, shadow, prefix, title, 0, 0);
 	shadow = Fcons (maps[i], shadow);
       }
   }
@@ -1921,12 +1929,17 @@
   if (!NILP (start1))
     {
       describe_map_tree (start1, 0, shadow, prefix,
-			 "Major Mode Bindings", 0);
+			 "Major Mode Bindings", 0, 0);
       shadow = Fcons (start1, shadow);
     }
 
   describe_map_tree (current_global_map, 0, shadow, prefix,
-		     "Global Bindings", 0);
+		     "Global Bindings", 0, 0);
+
+  /* Print the function-key-map translations under this prefix.  */
+  if (!NILP (Vfunction_key_map))
+    describe_map_tree (Vfunction_key_map, 0, Qnil, prefix,
+		       "Function key map translations", 0, 1);
 
   call0 (intern ("help-mode"));
   Fset_buffer (descbuf);
@@ -1943,14 +1956,18 @@
    PREFIX, if non-nil, says mention only keys that start with PREFIX.
    TITLE, if not 0, is a string to insert at the beginning.
    TITLE should not end with a colon or a newline; we supply that.
-   If NOMENU is not 0, then omit menu-bar commands.  */
+   If NOMENU is not 0, then omit menu-bar commands.
+
+   If TRANSL is nonzero, the definitions are actually key translations
+   so print strings and vectors differently.  */
 
 void
-describe_map_tree (startmap, partial, shadow, prefix, title, nomenu)
+describe_map_tree (startmap, partial, shadow, prefix, title, nomenu, transl)
      Lisp_Object startmap, shadow, prefix;
      int partial;
      char *title;
      int nomenu;
+     int transl;
 {
   Lisp_Object maps, seen, sub_shadows;
   struct gcpro gcpro1, gcpro2, gcpro3;
@@ -2041,7 +2058,8 @@
 	    sub_shadows = Fcons (shmap, sub_shadows);
 	}
 
-      describe_map (Fcdr (elt), Fcar (elt), describe_command,
+      describe_map (Fcdr (elt), Fcar (elt),
+		    transl ? describe_translation : describe_command,
 		    partial, sub_shadows, &seen);
 
     skip: ;
@@ -2067,7 +2085,7 @@
       insert1 (tem1);
       insert_string ("\n");
     }
-  else if (STRINGP (definition))
+  else if (STRINGP (definition) || VECTORP (definition))
     insert_string ("Keyboard Macro\n");
   else
     {
@@ -2079,6 +2097,32 @@
     }
 }
 
+static void
+describe_translation (definition)
+     Lisp_Object definition;
+{
+  register Lisp_Object tem1;
+
+  Findent_to (make_number (16), make_number (1));
+
+  if (SYMBOLP (definition))
+    {
+      XSETSTRING (tem1, XSYMBOL (definition)->name);
+      insert1 (tem1);
+      insert_string ("\n");
+    }
+  else if (STRINGP (definition) || VECTORP (definition))
+    insert1 (Fkey_description (definition));
+  else
+    {
+      tem1 = Fkeymapp (definition);
+      if (!NILP (tem1))
+	insert_string ("Prefix Command\n");
+      else
+	insert_string ("??\n");
+    }
+}
+
 /* Like Flookup_key, but uses a list of keymaps SHADOW instead of a single map.
    Returns the first non-nil binding found in any of those maps.  */
 
@@ -2460,6 +2504,12 @@
 key, typing `ESC O P x' would return [f1 x].");
   Vfunction_key_map = Fmake_sparse_keymap (Qnil);
 
+  DEFVAR_LISP ("key-translation-map", &Vkey_translation_map,
+    "Keymap of key translations that can override keymaps.\n\
+This keymap works like `function-key-map', but comes after that,\n\
+and applies even for keys that have ordinary bindings.");
+  Vkey_translation_map = Qnil;
+
   Qsingle_key_description = intern ("single-key-description");
   staticpro (&Qsingle_key_description);