# HG changeset patch # User Stefan Monnier # Date 1257692810 0 # Node ID 414b8a7a333445ab091d7593d61ef60ef7ebab01 # Parent 26de05188183a2f13f38f1d43e38df4f1f5be4db (parse_menu_item): Handle `notreal' a bit earlier. Use `tem' less. Make sure KEYEQ holds a string or nil (bug#4879). diff -r 26de05188183 -r 414b8a7a3334 src/ChangeLog --- a/src/ChangeLog Sun Nov 08 10:49:06 2009 +0000 +++ b/src/ChangeLog Sun Nov 08 15:06:50 2009 +0000 @@ -1,3 +1,8 @@ +2009-11-08 Stefan Monnier + + * keyboard.c (parse_menu_item): Handle `notreal' a bit earlier. + Use `tem' less. Make sure KEYEQ holds a string or nil (bug#4879). + 2009-11-08 Chong Yidong * xmenu.c (Fx_popup_menu): Extract event timestamp. Pass it to diff -r 26de05188183 -r 414b8a7a3334 src/keyboard.c --- a/src/keyboard.c Sun Nov 08 10:49:06 2009 +0000 +++ b/src/keyboard.c Sun Nov 08 15:06:50 2009 +0000 @@ -8068,65 +8068,70 @@ if (inmenubar > 0) return 1; - /* This is a command. See if there is an equivalent key binding. */ - tem = AREF (item_properties, ITEM_PROPERTY_KEYEQ); - /* The previous code preferred :key-sequence to :keys, so we - preserve this behavior. */ - if (STRINGP (tem) && !CONSP (keyhint)) - tem = Fsubstitute_command_keys (tem); - else - { - Lisp_Object prefix = AREF (item_properties, ITEM_PROPERTY_KEYEQ); - Lisp_Object keys = Qnil; - - if (CONSP (prefix)) - { - def = XCAR (prefix); - prefix = XCDR (prefix); - } - else - def = AREF (item_properties, ITEM_PROPERTY_DEF); - - if (CONSP (keyhint) && !NILP (XCAR (keyhint))) - { - keys = XCAR (keyhint); - tem = Fkey_binding (keys, Qnil, Qnil, Qnil); - - /* We have a suggested key. Is it bound to the command? */ - if (NILP (tem) - || (!EQ (tem, def) - /* If the command is an alias for another - (such as lmenu.el set it up), check if the - original command matches the cached command. */ - && !(SYMBOLP (def) && EQ (tem, XSYMBOL (def)->function)))) - keys = Qnil; - } - - if (NILP (keys)) - keys = Fwhere_is_internal (def, Qnil, Qt, Qnil, Qnil); - - if (!NILP (keys)) - { - tem = Fkey_description (keys, Qnil); - if (CONSP (prefix)) - { - if (STRINGP (XCAR (prefix))) - tem = concat2 (XCAR (prefix), tem); - if (STRINGP (XCDR (prefix))) - tem = concat2 (tem, XCDR (prefix)); - } - tem = concat2 (build_string (" "), tem); - /* tem = concat3 (build_string (" ("), tem, build_string (")")); */ - } - } - - /* If we only want to precompute equivalent key bindings, stop here. */ + /* If we only want to precompute equivalent key bindings (which we + don't even do any more anyway), stop here. */ if (notreal) return 1; - /* If we have an equivalent key binding, use that. */ - ASET (item_properties, ITEM_PROPERTY_KEYEQ, tem); + { /* This is a command. See if there is an equivalent key binding. */ + Lisp_Object keyeq = AREF (item_properties, ITEM_PROPERTY_KEYEQ); + + /* The previous code preferred :key-sequence to :keys, so we + preserve this behavior. */ + if (STRINGP (keyeq) && !CONSP (keyhint)) + keyeq = Fsubstitute_command_keys (keyeq); + else + { + Lisp_Object prefix = keyeq; + Lisp_Object keys = Qnil; + + if (CONSP (prefix)) + { + def = XCAR (prefix); + prefix = XCDR (prefix); + } + else + def = AREF (item_properties, ITEM_PROPERTY_DEF); + + if (CONSP (keyhint) && !NILP (XCAR (keyhint))) + { + keys = XCAR (keyhint); + tem = Fkey_binding (keys, Qnil, Qnil, Qnil); + + /* We have a suggested key. Is it bound to the command? */ + if (NILP (tem) + || (!EQ (tem, def) + /* If the command is an alias for another + (such as lmenu.el set it up), check if the + original command matches the cached command. */ + && !(SYMBOLP (def) && EQ (tem, XSYMBOL (def)->function)))) + keys = Qnil; + } + + if (NILP (keys)) + keys = Fwhere_is_internal (def, Qnil, Qt, Qnil, Qnil); + + if (!NILP (keys)) + { + tem = Fkey_description (keys, Qnil); + if (CONSP (prefix)) + { + if (STRINGP (XCAR (prefix))) + tem = concat2 (XCAR (prefix), tem); + if (STRINGP (XCDR (prefix))) + tem = concat2 (tem, XCDR (prefix)); + } + keyeq = concat2 (build_string (" "), tem); + /* keyeq = concat3(build_string(" ("),tem,build_string(")")); */ + } + else + keyeq = Qnil; + } + + /* If we have an equivalent key binding, use that. */ + ASET (item_properties, ITEM_PROPERTY_KEYEQ, keyeq); + } /* Include this when menu help is implemented. tem = XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP];