aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/keyboard.c113
2 files changed, 64 insertions, 54 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 9fb03a341e0..3b9bef861d6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12009-11-08 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * keyboard.c (parse_menu_item): Handle `notreal' a bit earlier.
4 Use `tem' less. Make sure KEYEQ holds a string or nil (bug#4879).
5
12009-11-08 Chong Yidong <cyd@stupidchicken.com> 62009-11-08 Chong Yidong <cyd@stupidchicken.com>
2 7
3 * xmenu.c (Fx_popup_menu): Extract event timestamp. Pass it to 8 * xmenu.c (Fx_popup_menu): Extract event timestamp. Pass it to
diff --git a/src/keyboard.c b/src/keyboard.c
index a6bfb08e5d8..0117dc346f3 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -8068,65 +8068,70 @@ parse_menu_item (item, notreal, inmenubar)
8068 if (inmenubar > 0) 8068 if (inmenubar > 0)
8069 return 1; 8069 return 1;
8070 8070
8071 /* This is a command. See if there is an equivalent key binding. */ 8071
8072 tem = AREF (item_properties, ITEM_PROPERTY_KEYEQ); 8072 /* If we only want to precompute equivalent key bindings (which we
8073 /* The previous code preferred :key-sequence to :keys, so we 8073 don't even do any more anyway), stop here. */
8074 preserve this behavior. */ 8074 if (notreal)
8075 if (STRINGP (tem) && !CONSP (keyhint)) 8075 return 1;
8076 tem = Fsubstitute_command_keys (tem);
8077 else
8078 {
8079 Lisp_Object prefix = AREF (item_properties, ITEM_PROPERTY_KEYEQ);
8080 Lisp_Object keys = Qnil;
8081 8076
8082 if (CONSP (prefix)) 8077 { /* This is a command. See if there is an equivalent key binding. */
8083 { 8078 Lisp_Object keyeq = AREF (item_properties, ITEM_PROPERTY_KEYEQ);
8084 def = XCAR (prefix);
8085 prefix = XCDR (prefix);
8086 }
8087 else
8088 def = AREF (item_properties, ITEM_PROPERTY_DEF);
8089 8079
8090 if (CONSP (keyhint) && !NILP (XCAR (keyhint))) 8080 /* The previous code preferred :key-sequence to :keys, so we
8091 { 8081 preserve this behavior. */
8092 keys = XCAR (keyhint); 8082 if (STRINGP (keyeq) && !CONSP (keyhint))
8093 tem = Fkey_binding (keys, Qnil, Qnil, Qnil); 8083 keyeq = Fsubstitute_command_keys (keyeq);
8094 8084 else
8095 /* We have a suggested key. Is it bound to the command? */ 8085 {
8096 if (NILP (tem) 8086 Lisp_Object prefix = keyeq;
8097 || (!EQ (tem, def) 8087 Lisp_Object keys = Qnil;
8098 /* If the command is an alias for another 8088
8099 (such as lmenu.el set it up), check if the 8089 if (CONSP (prefix))
8100 original command matches the cached command. */ 8090 {
8101 && !(SYMBOLP (def) && EQ (tem, XSYMBOL (def)->function)))) 8091 def = XCAR (prefix);
8102 keys = Qnil; 8092 prefix = XCDR (prefix);
8103 } 8093 }
8094 else
8095 def = AREF (item_properties, ITEM_PROPERTY_DEF);
8096
8097 if (CONSP (keyhint) && !NILP (XCAR (keyhint)))
8098 {
8099 keys = XCAR (keyhint);
8100 tem = Fkey_binding (keys, Qnil, Qnil, Qnil);
8101
8102 /* We have a suggested key. Is it bound to the command? */
8103 if (NILP (tem)
8104 || (!EQ (tem, def)
8105 /* If the command is an alias for another
8106 (such as lmenu.el set it up), check if the
8107 original command matches the cached command. */
8108 && !(SYMBOLP (def) && EQ (tem, XSYMBOL (def)->function))))
8109 keys = Qnil;
8110 }
8104 8111
8105 if (NILP (keys)) 8112 if (NILP (keys))
8106 keys = Fwhere_is_internal (def, Qnil, Qt, Qnil, Qnil); 8113 keys = Fwhere_is_internal (def, Qnil, Qt, Qnil, Qnil);
8107 8114
8108 if (!NILP (keys)) 8115 if (!NILP (keys))
8109 { 8116 {
8110 tem = Fkey_description (keys, Qnil); 8117 tem = Fkey_description (keys, Qnil);
8111 if (CONSP (prefix)) 8118 if (CONSP (prefix))
8112 { 8119 {
8113 if (STRINGP (XCAR (prefix))) 8120 if (STRINGP (XCAR (prefix)))
8114 tem = concat2 (XCAR (prefix), tem); 8121 tem = concat2 (XCAR (prefix), tem);
8115 if (STRINGP (XCDR (prefix))) 8122 if (STRINGP (XCDR (prefix)))
8116 tem = concat2 (tem, XCDR (prefix)); 8123 tem = concat2 (tem, XCDR (prefix));
8117 } 8124 }
8118 tem = concat2 (build_string (" "), tem); 8125 keyeq = concat2 (build_string (" "), tem);
8119 /* tem = concat3 (build_string (" ("), tem, build_string (")")); */ 8126 /* keyeq = concat3(build_string(" ("),tem,build_string(")")); */
8120 } 8127 }
8121 } 8128 else
8122 8129 keyeq = Qnil;
8123 8130 }
8124 /* If we only want to precompute equivalent key bindings, stop here. */
8125 if (notreal)
8126 return 1;
8127 8131
8128 /* If we have an equivalent key binding, use that. */ 8132 /* If we have an equivalent key binding, use that. */
8129 ASET (item_properties, ITEM_PROPERTY_KEYEQ, tem); 8133 ASET (item_properties, ITEM_PROPERTY_KEYEQ, keyeq);
8134 }
8130 8135
8131 /* Include this when menu help is implemented. 8136 /* Include this when menu help is implemented.
8132 tem = XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]; 8137 tem = XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP];