From: Richard M. Stallman Date: Thu, 29 Jun 1995 18:43:24 +0000 (+0000) Subject: (single_submenu): Handle commands appearing directly in the menu bar. X-Git-Tag: emacs-19.34~3427 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=71dca3e3da179d831d3a9426d3ee208cc783b6a4;p=emacs.git (single_submenu): Handle commands appearing directly in the menu bar. --- diff --git a/src/xmenu.c b/src/xmenu.c index f8d3b143ceb..54b1d50e096 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -1300,6 +1300,7 @@ single_submenu (item_key, item_name, maps) widget_value **submenu_stack; int mapno; int previous_items = menu_items_used; + int top_level_items = 0; length = Flength (maps); len = XINT (length); @@ -1317,7 +1318,16 @@ single_submenu (item_key, item_name, maps) /* Loop over the given keymaps, making a pane for each map. But don't make a pane that is empty--ignore that map instead. */ for (i = 0; i < len; i++) - single_keymap_panes (mapvec[i], item_name, item_key, 0); + { + if (SYMBOLP (mapvec[i])) + { + top_level_items = 1; + push_menu_pane (Qnil, Qnil); + push_menu_item (item_name, Qt, item_key, mapvec[i], Qnil); + } + else + single_keymap_panes (mapvec[i], item_name, item_key, 0); + } /* Create a tree of widget_value objects representing the panes and their items. */ @@ -1330,6 +1340,7 @@ single_submenu (item_key, item_name, maps) wv->enabled = 1; first_wv = wv; save_wv = 0; + prev_wv = 0; /* Loop over all panes and items made during this call and construct a tree of widget_value objects. @@ -1405,8 +1416,9 @@ single_submenu (item_key, item_name, maps) wv = malloc_widget_value (); if (prev_wv) prev_wv->next = wv; - else + else save_wv->contents = wv; + wv->name = (char *) XSTRING (item_name)->data; if (!NILP (descrip)) wv->key = (char *) XSTRING (descrip)->data; @@ -1421,6 +1433,15 @@ single_submenu (item_key, item_name, maps) } } + /* If we have just one "menu item" + that was originally a button, return it by itself. */ + if (top_level_items && first_wv->contents && first_wv->contents->next == 0) + { + wv = first_wv->contents; + free_widget_value (first_wv); + return wv; + } + return first_wv; }