# HG changeset patch # User Richard M. Stallman # Date 761813169 0 # Node ID 51d9a0c72a29e1b3f881435121c860c16b7cf247 # Parent cf744280a5a49ab96f878d2cda1dc4bfb690ea60 (single_keymap_panes): Properly skip help-string if any. Rename item2 to item_string. GCPRO some things. (menu_item_equiv_key): Use either VECTORP or STRINGP, not both. diff -r cf744280a5a4 -r 51d9a0c72a29 src/xmenu.c --- a/src/xmenu.c Mon Feb 21 02:49:58 1994 +0000 +++ b/src/xmenu.c Mon Feb 21 06:46:09 1994 +0000 @@ -1,5 +1,5 @@ /* X Communication module for terminals which understand the X protocol. - Copyright (C) 1986, 1988, 1993 Free Software Foundation, Inc. + Copyright (C) 1986, 1988, 1993, 1994 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -1183,15 +1183,11 @@ /* Get out the saved equivalent-keyboard-key info. */ savedkey = descrip = Qnil; - if (CONSP (overdef) - && (STRINGP (XCONS (overdef)->car) - || VECTORP (XCONS (overdef)->car))) + if (CONSP (overdef) && VECTORP (XCONS (overdef)->car)) { savedkey = XCONS (overdef)->car; def = XCONS (def)->cdr; - if (CONSP (def) - && (STRINGP (XCONS (def)->car) - || VECTORP (XCONS (def)->car))) + if (CONSP (def) && STRINGP (XCONS (def)->car)) { descrip = XCONS (def)->car; def = XCONS (def)->cdr; @@ -1222,17 +1218,13 @@ /* Store back the recorded keyboard key sequence if we changed it. */ if (!NILP (savedkey) - && CONSP (overdef) - && (STRINGP (XCONS (overdef)->car) - || VECTORP (XCONS (overdef)->car))) + && CONSP (overdef) && VECTORP (XCONS (overdef)->car)) { if (changed) { XCONS (overdef)->car = savedkey; def1 = XCONS (overdef)->cdr; - if (CONSP (def1) - && (STRINGP (XCONS (def1)->car) - || VECTORP (XCONS (def1)->car))) + if (CONSP (def1) && STRINGP (XCONS (def1)->car)) XCONS (def1)->car = descrip; } } @@ -1240,16 +1232,11 @@ else if (!NILP (savedkey)) XCONS (item1)->cdr = overdef = Fcons (savedkey, Fcons (descrip, def)); - /* If we had one but no longer should have one, - delete it. */ - else if (CONSP (overdef) - && (STRINGP (XCONS (overdef)->car) - || VECTORP (XCONS (overdef)->car))) + /* If we had one but no longer should have one, delete it. */ + else if (CONSP (overdef) && VECTORP (XCONS (overdef)->car)) { XCONS (item1)->cdr = overdef = XCONS (overdef)->cdr; - if (CONSP (overdef) - && (STRINGP (XCONS (overdef)->car) - || VECTORP (XCONS (overdef)->car))) + if (CONSP (overdef) && STRINGP (XCONS (overdef)->car)) XCONS (item1)->cdr = overdef = XCONS (overdef)->cdr; } @@ -1333,7 +1320,8 @@ { int i; Lisp_Object pending_maps; - Lisp_Object tail, item, item1, item2, table; + Lisp_Object tail, item, item1, item_string, table; + struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; pending_maps = Qnil; @@ -1396,8 +1384,8 @@ item1 = XCONS (item)->cdr; if (XTYPE (item1) == Lisp_Cons) { - item2 = XCONS (item1)->car; - if (XTYPE (item2) == Lisp_String) + item_string = XCONS (item1)->car; + if (XTYPE (item_string) == Lisp_String) { /* This is the real definition--the function to run. */ Lisp_Object def; @@ -1406,6 +1394,12 @@ Lisp_Object savedkey, descrip; Lisp_Object tem, enabled; + /* If a help string follows the item string, + skip it. */ + if (CONSP (XCONS (item1)->cdr) + && STRINGP (XCONS (XCONS (item1)->cdr)->car)) + item1 = XCONS (item1)->cdr; + def = menu_item_equiv_key (item1, &savedkey, &descrip); enabled = Qt; @@ -1414,24 +1408,30 @@ /* No property, or nil, means enable. Otherwise, enable if value is not nil. */ tem = Fget (def, Qmenu_enable); + /* GCPRO because we will call eval. + Protecting KEYMAP preserves everything we use; + aside from that, must protect whatever might be + a string. */ + GCPRO3 (keymap, def, descrip, item_string); if (!NILP (tem)) /* (condition-case nil (eval tem) (error nil)) */ enabled = internal_condition_case_1 (Feval, tem, Qerror, single_keymap_panes_1); + UNGCPRO; } tem = Fkeymapp (def); - if (XSTRING (item2)->data[0] == '@' && !NILP (tem)) - pending_maps = Fcons (Fcons (def, Fcons (item2, XCONS (item)->car)), + if (XSTRING (item_string)->data[0] == '@' && !NILP (tem)) + pending_maps = Fcons (Fcons (def, Fcons (item_string, XCONS (item)->car)), pending_maps); else { Lisp_Object concat; if (!NILP (descrip)) - concat = concat2 (item2, descrip); + concat = concat2 (item_string, descrip); else - concat = item2; + concat = item_string; (*names)[*p_ptr][i] = (char *) XSTRING (concat)->data; /* The menu item "value" is the key bound here. */ (*vector)[*p_ptr][i] = XCONS (item)->car; @@ -1454,8 +1454,8 @@ item1 = XVECTOR (item)->contents[c]; if (XTYPE (item1) == Lisp_Cons) { - item2 = XCONS (item1)->car; - if (XTYPE (item2) == Lisp_String) + item_string = XCONS (item1)->car; + if (XTYPE (item_string) == Lisp_String) { Lisp_Object def; @@ -1464,12 +1464,23 @@ Lisp_Object savedkey, descrip; Lisp_Object tem, enabled; + /* If a help string follows the item string, + skip it. */ + if (CONSP (XCONS (item1)->cdr) + && STRINGP (XCONS (XCONS (item1)->cdr)->car)) + item1 = XCONS (item1)->cdr; + def = menu_item_equiv_key (item1, &savedkey, &descrip); enabled = Qt; if (XTYPE (def) == Lisp_Symbol) { tem = Fget (def, Qmenu_enable); + /* GCPRO because we will call eval. + Protecting KEYMAP preserves everything we use; + aside from that, must protect whatever might be + a string. */ + GCPRO3 (keymap, def, descrip, item_string); /* No property, or nil, means enable. Otherwise, enable if value is not nil. */ if (!NILP (tem)) @@ -1478,19 +1489,20 @@ enabled = internal_condition_case_1 (Feval, tem, Qerror, single_keymap_panes_1); + UNGCPRO; } tem = Fkeymapp (def); - if (XSTRING (item2)->data[0] == '@' && !NILP (tem)) - pending_maps = Fcons (Fcons (def, Fcons (item2, character)), + if (XSTRING (item_string)->data[0] == '@' && !NILP (tem)) + pending_maps = Fcons (Fcons (def, Fcons (item_string, character)), pending_maps); else { Lisp_Object concat; if (!NILP (descrip)) - concat = concat2 (item2, descrip); + concat = concat2 (item_string, descrip); else - concat = item2; + concat = item_string; (*names)[*p_ptr][i] = (char *) XSTRING (concat)->data; /* The menu item "value" is the key bound here. */