changeset 4023:5e4f918d5d44

(describe_map_tree): When inserting TITLE, mention PREFIX. Insert newline at end, if inserted anything else. (describe_buffer_bindings): Corresponding changes. For minor mode maps, build up a title string, then let describe_map_tree insert it.
author Richard M. Stallman <rms@gnu.org>
date Wed, 07 Jul 1993 18:40:35 +0000
parents a3d3d7eef5ce
children b9f3b023e5c9
files src/keymap.c
diffstat 1 files changed, 39 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/keymap.c	Wed Jul 07 17:55:55 1993 +0000
+++ b/src/keymap.c	Wed Jul 07 18:40:35 1993 +0000
@@ -1735,18 +1735,32 @@
     /* Print the minor mode maps.  */
     for (i = 0; i < nmaps; i++)
       {
+	/* Tht title for a minor mode keymap
+	   is constructed at run time.
+	   We let describe_map_tree do the actual insertion
+	   because it takes care of other features when doing so.  */
+	char *title = (char *) alloca (40 + XSYMBOL (modes[i])->name->size);
+	char *p = title;
+
 	if (XTYPE (modes[i]) == Lisp_Symbol)
 	  {
-	    insert_char ('`');
-	    insert_string (XSYMBOL (modes[i])->name->data);
-	    insert_char ('\'');
+	    *p++ = '`';
+	    bcopy (XSYMBOL (modes[i])->name->data, p,
+		   XSYMBOL (modes[i])->name->size);
+	    p += XSYMBOL (modes[i])->name->size;
+	    *p++ = '\'';
 	  }
 	else
-	  insert_string ("Strangely Named");
-	insert_string (" Minor Mode Bindings:\n");
-	describe_map_tree (maps[i], 0, shadow, prefix, 0);
+	  {
+	    bcopy ("Strangely Named", p, sizeof ("Strangely Named"));
+	    p += sizeof ("Strangely Named");
+	  }
+	bcopy (" Minor Mode Bindings", p, sizeof (" Minor Mode Bindings"));
+	p += sizeof (" Minor Mode Bindings");
+	*p = 0;
+
+	describe_map_tree (maps[i], 0, shadow, prefix, title);
 	shadow = Fcons (maps[i], shadow);
-	insert_char ('\n');
       }
   }
 
@@ -1755,13 +1769,12 @@
   if (!NILP (start1))
     {
       describe_map_tree (start1, 0, shadow, prefix,
-			 "Major Mode Bindings:\n");
+			 "Major Mode Bindings");
       shadow = Fcons (start1, shadow);
-      insert_string ("\n");
     }
 
   describe_map_tree (current_global_map, 0, shadow, prefix,
-		     "Global Bindings:\n");
+		     "Global Bindings");
 
   Fset_buffer (descbuf);
   return Qnil;
@@ -1774,7 +1787,8 @@
    If SHADOW is non-nil, it is a list of maps;
     don't mention keys which would be shadowed by any of them.
    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, if not 0, is a string to insert at the beginning.
+   TITLE should not end with a colon or a newline; we supply that.  */
 
 void
 describe_map_tree (startmap, partial, shadow, prefix, title)
@@ -1784,6 +1798,7 @@
 {
   Lisp_Object maps;
   struct gcpro gcpro1;
+  int something = 0;
   char *key_heading
     = "\
 key             binding\n\
@@ -1795,8 +1810,17 @@
   if (!NILP (maps))
     {
       if (title)
-	insert_string (title);
+	{
+	  insert_string (title);
+	  if (!NILP (prefix))
+	    {
+	      insert_string (" Starting With ");
+	      insert1 (Fkey_description (prefix));
+	    }
+	  insert_string (":\n");
+	}
       insert_string (key_heading);
+      something = 1;
     }
 
   for (; !NILP (maps); maps = Fcdr (maps))
@@ -1846,6 +1870,9 @@
     skip: ;
     }
 
+  if (something)
+    insert_string ("\n");
+
   UNGCPRO;
 }