changeset 16752:6409ef81a2a8

(single_keymap_panes): New arg DEPTH. Cut off recursion at that depth. Callers changed.
author Richard M. Stallman <rms@gnu.org>
date Thu, 26 Dec 1996 21:06:19 +0000
parents d393cbcfb69c
children ab63a77c3a23
files src/xmenu.c
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/xmenu.c	Thu Dec 26 21:01:10 1996 +0000
+++ b/src/xmenu.c	Thu Dec 26 21:06:19 1996 +0000
@@ -504,7 +504,7 @@
      But don't make a pane that is empty--ignore that map instead.
      P is the number of panes we have made so far.  */
   for (mapno = 0; mapno < nmaps; mapno++)
-    single_keymap_panes (keymaps[mapno], Qnil, Qnil, notreal);
+    single_keymap_panes (keymaps[mapno], Qnil, Qnil, notreal, 10);
 
   finish_menu_items ();
 }
@@ -514,19 +514,25 @@
    The other arguments are passed along
    or point to local variables of the previous function.
    If NOTREAL is nonzero,
-   don't bother really computing whether an item is enabled.  */
+   don't bother really computing whether an item is enabled.
+
+   If we encounter submenus deeper than MAXDEPTH levels, ignore them.  */
 
 static void
-single_keymap_panes (keymap, pane_name, prefix, notreal)
+single_keymap_panes (keymap, pane_name, prefix, notreal, maxdepth)
      Lisp_Object keymap;
      Lisp_Object pane_name;
      Lisp_Object prefix;
      int notreal;
+     int maxdepth;
 {
   Lisp_Object pending_maps;
   Lisp_Object tail, item, item1, item_string, table;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
 
+  if (maxdepth <= 0)
+    return;
+
   pending_maps = Qnil;
 
   push_menu_pane (pane_name, prefix);
@@ -593,7 +599,8 @@
 			{
 			  push_submenu_start ();
 			  single_keymap_panes (submap, Qnil,
-					       XCONS (item)->car, notreal);
+					       XCONS (item)->car, notreal,
+					       maxdepth - 1);
 			  push_submenu_end ();
 			}
 #endif
@@ -662,7 +669,8 @@
 			    {
 			      push_submenu_start ();
 			      single_keymap_panes (submap, Qnil,
-						   character, notreal);
+						   character, notreal,
+						   maxdepth - 1);
 			      push_submenu_end ();
 			    }
 #endif
@@ -683,7 +691,7 @@
       /* We no longer discard the @ from the beginning of the string here.
 	 Instead, we do this in xmenu_show.  */
       single_keymap_panes (Fcar (elt), string,
-			   XCONS (eltcdr)->cdr, notreal);
+			   XCONS (eltcdr)->cdr, notreal, maxdepth - 1);
       pending_maps = Fcdr (pending_maps);
     }
 }
@@ -1425,7 +1433,7 @@
 	  push_menu_item (item_name, Qt, item_key, mapvec[i], Qnil);
 	}
       else
-	single_keymap_panes (mapvec[i], item_name, item_key, 0);
+	single_keymap_panes (mapvec[i], item_name, item_key, 0, 10);
     }
 
   /* Create a tree of widget_value objects