aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2009-09-10 18:19:03 +0000
committerStefan Monnier2009-09-10 18:19:03 +0000
commit50d4ba399303b7365b03cdd3456a28eae3451fa0 (patch)
treec63ce12cfa63ee99c330b5ab7c3cd3d5f3b0f73d /src
parentdeeb21d4d76909c91f4f94f1fa1bbc782fb5f75a (diff)
downloademacs-50d4ba399303b7365b03cdd3456a28eae3451fa0.tar.gz
emacs-50d4ba399303b7365b03cdd3456a28eae3451fa0.zip
* keyboard.c (Qmenu_alias, Vdefine_key_rebound_commands): Remove.
(parse_menu_item): Streamline since bindings are recomputed all the time anyway. Don't bother checking Vdefine_key_rebound_commands any more and don't support lmenu's menu-alias any more either. * subr.el (define-key-rebound-commands): Mark obsolete. * startup.el (precompute-menubar-bindings): Remove. (normal-top-level): Remove obsolete code that tried to precompute menubar bindings. * loadup.el (define-key-rebound-commands): Don't bother fiddling with define-key-rebound-commands and precompute-menubar-bindings.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/keyboard.c145
2 files changed, 40 insertions, 110 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c530325ed69..f21e06a361b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
12009-09-10 Stefan Monnier <monnier@iro.umontreal.ca> 12009-09-10 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * keyboard.c (Qmenu_alias, Vdefine_key_rebound_commands): Remove.
4 (parse_menu_item): Streamline since bindings are recomputed all the
5 time anyway. Don't bother checking Vdefine_key_rebound_commands any
6 more and don't support lmenu's menu-alias any more either.
7
3 * keymap.c (where_is_internal_data): Make noindirect a boolean. 8 * keymap.c (where_is_internal_data): Make noindirect a boolean.
4 (where_is_internal): Strip it down to only traverse the keymaps. 9 (where_is_internal): Strip it down to only traverse the keymaps.
5 Move the cache handling from Fwhere_is_internal to here. 10 Move the cache handling from Fwhere_is_internal to here.
diff --git a/src/keyboard.c b/src/keyboard.c
index 04af3585897..35c338cc74c 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -495,11 +495,9 @@ Lisp_Object Qevent_kind;
495Lisp_Object Qevent_symbol_elements; 495Lisp_Object Qevent_symbol_elements;
496 496
497/* menu item parts */ 497/* menu item parts */
498Lisp_Object Qmenu_alias;
499Lisp_Object Qmenu_enable; 498Lisp_Object Qmenu_enable;
500Lisp_Object QCenable, QCvisible, QChelp, QCfilter, QCkeys, QCkey_sequence; 499Lisp_Object QCenable, QCvisible, QChelp, QCfilter, QCkeys, QCkey_sequence;
501Lisp_Object QCbutton, QCtoggle, QCradio; 500Lisp_Object QCbutton, QCtoggle, QCradio;
502extern Lisp_Object Vdefine_key_rebound_commands;
503extern Lisp_Object Qmenu_item; 501extern Lisp_Object Qmenu_item;
504 502
505/* An event header symbol HEAD may have a property named 503/* An event header symbol HEAD may have a property named
@@ -7883,13 +7881,10 @@ parse_menu_item (item, notreal, inmenubar)
7883 int notreal, inmenubar; 7881 int notreal, inmenubar;
7884{ 7882{
7885 Lisp_Object def, tem, item_string, start; 7883 Lisp_Object def, tem, item_string, start;
7886 Lisp_Object cachelist;
7887 Lisp_Object filter; 7884 Lisp_Object filter;
7888 Lisp_Object keyhint; 7885 Lisp_Object keyhint;
7889 int i; 7886 int i;
7890 int newcache = 0;
7891 7887
7892 cachelist = Qnil;
7893 filter = Qnil; 7888 filter = Qnil;
7894 keyhint = Qnil; 7889 keyhint = Qnil;
7895 7890
@@ -7926,14 +7921,11 @@ parse_menu_item (item, notreal, inmenubar)
7926 item = XCDR (item); 7921 item = XCDR (item);
7927 } 7922 }
7928 7923
7929 /* Maybe key binding cache. */ 7924 /* Maybe an obsolete key binding cache. */
7930 if (CONSP (item) && CONSP (XCAR (item)) 7925 if (CONSP (item) && CONSP (XCAR (item))
7931 && (NILP (XCAR (XCAR (item))) 7926 && (NILP (XCAR (XCAR (item)))
7932 || VECTORP (XCAR (XCAR (item))))) 7927 || VECTORP (XCAR (XCAR (item)))))
7933 { 7928 item = XCDR (item);
7934 cachelist = XCAR (item);
7935 item = XCDR (item);
7936 }
7937 7929
7938 /* This is the real definition--the function to run. */ 7930 /* This is the real definition--the function to run. */
7939 ASET (item_properties, ITEM_PROPERTY_DEF, item); 7931 ASET (item_properties, ITEM_PROPERTY_DEF, item);
@@ -7959,12 +7951,9 @@ parse_menu_item (item, notreal, inmenubar)
7959 ASET (item_properties, ITEM_PROPERTY_DEF, XCAR (start)); 7951 ASET (item_properties, ITEM_PROPERTY_DEF, XCAR (start));
7960 7952
7961 item = XCDR (start); 7953 item = XCDR (start);
7962 /* Is there a cache list with key equivalences. */ 7954 /* Is there an obsolete cache list with key equivalences. */
7963 if (CONSP (item) && CONSP (XCAR (item))) 7955 if (CONSP (item) && CONSP (XCAR (item)))
7964 { 7956 item = XCDR (item);
7965 cachelist = XCAR (item);
7966 item = XCDR (item);
7967 }
7968 7957
7969 /* Parse properties. */ 7958 /* Parse properties. */
7970 while (CONSP (item) && CONSP (XCDR (item))) 7959 while (CONSP (item) && CONSP (XCDR (item)))
@@ -7994,15 +7983,14 @@ parse_menu_item (item, notreal, inmenubar)
7994 else if (EQ (tem, QCkey_sequence)) 7983 else if (EQ (tem, QCkey_sequence))
7995 { 7984 {
7996 tem = XCAR (item); 7985 tem = XCAR (item);
7997 if (NILP (cachelist) 7986 if (SYMBOLP (tem) || STRINGP (tem) || VECTORP (tem))
7998 && (SYMBOLP (tem) || STRINGP (tem) || VECTORP (tem)))
7999 /* Be GC protected. Set keyhint to item instead of tem. */ 7987 /* Be GC protected. Set keyhint to item instead of tem. */
8000 keyhint = item; 7988 keyhint = item;
8001 } 7989 }
8002 else if (EQ (tem, QCkeys)) 7990 else if (EQ (tem, QCkeys))
8003 { 7991 {
8004 tem = XCAR (item); 7992 tem = XCAR (item);
8005 if (CONSP (tem) || (STRINGP (tem) && NILP (cachelist))) 7993 if (CONSP (tem) || STRINGP (tem))
8006 ASET (item_properties, ITEM_PROPERTY_KEYEQ, tem); 7994 ASET (item_properties, ITEM_PROPERTY_KEYEQ, tem);
8007 } 7995 }
8008 else if (EQ (tem, QCbutton) && CONSP (XCAR (item))) 7996 else if (EQ (tem, QCbutton) && CONSP (XCAR (item)))
@@ -8083,40 +8071,16 @@ parse_menu_item (item, notreal, inmenubar)
8083 return 1; 8071 return 1;
8084 8072
8085 /* This is a command. See if there is an equivalent key binding. */ 8073 /* This is a command. See if there is an equivalent key binding. */
8086 if (NILP (cachelist)) 8074 tem = AREF (item_properties, ITEM_PROPERTY_KEYEQ);
8087 { 8075 /* The previous code preferred :key-sequence to :keys, so we
8088 /* We have to create a cachelist. */ 8076 preserve this behavior. */
8089 /* With the introduction of where_is_cache, the computation 8077 if (STRINGP (tem) && !CONSP (keyhint))
8090 of equivalent key bindings is sufficiently fast that we 8078 tem = Fsubstitute_command_keys (tem);
8091 do not need to cache it here any more. */ 8079 else
8092 /* CHECK_IMPURE (start);
8093 XSETCDR (start, Fcons (Fcons (Qnil, Qnil), XCDR (start)));
8094 cachelist = XCAR (XCDR (start)); */
8095 cachelist = Fcons (Qnil, Qnil);
8096 newcache = 1;
8097 tem = AREF (item_properties, ITEM_PROPERTY_KEYEQ);
8098 if (!NILP (keyhint))
8099 {
8100 XSETCAR (cachelist, XCAR (keyhint));
8101 newcache = 0;
8102 }
8103 else if (STRINGP (tem))
8104 {
8105 XSETCDR (cachelist, Fsubstitute_command_keys (tem));
8106 XSETCAR (cachelist, Qt);
8107 }
8108 }
8109
8110 tem = XCAR (cachelist);
8111 if (!EQ (tem, Qt))
8112 { 8080 {
8113 int chkcache = 0; 8081 Lisp_Object prefix = AREF (item_properties, ITEM_PROPERTY_KEYEQ);
8114 Lisp_Object prefix; 8082 Lisp_Object keys = Qnil;
8115
8116 if (!NILP (tem))
8117 tem = Fkey_binding (tem, Qnil, Qnil, Qnil);
8118 8083
8119 prefix = AREF (item_properties, ITEM_PROPERTY_KEYEQ);
8120 if (CONSP (prefix)) 8084 if (CONSP (prefix))
8121 { 8085 {
8122 def = XCAR (prefix); 8086 def = XCAR (prefix);
@@ -8125,58 +8089,27 @@ parse_menu_item (item, notreal, inmenubar)
8125 else 8089 else
8126 def = AREF (item_properties, ITEM_PROPERTY_DEF); 8090 def = AREF (item_properties, ITEM_PROPERTY_DEF);
8127 8091
8128 if (NILP (XCAR (cachelist))) /* Have no saved key. */ 8092 if (CONSP (keyhint) && !NILP (XCAR (keyhint)))
8129 {
8130 if (newcache /* Always check first time. */
8131 /* Should we check everything when precomputing key
8132 bindings? */
8133 /* If something had no key binding before, don't recheck it
8134 because that is too slow--except if we have a list of
8135 rebound commands in Vdefine_key_rebound_commands, do
8136 recheck any command that appears in that list. */
8137 || (CONSP (Vdefine_key_rebound_commands)
8138 && !NILP (Fmemq (def, Vdefine_key_rebound_commands))))
8139 chkcache = 1;
8140 }
8141 /* We had a saved key. Is it still bound to the command? */
8142 else if (NILP (tem)
8143 || (!EQ (tem, def)
8144 /* If the command is an alias for another
8145 (such as lmenu.el set it up), check if the
8146 original command matches the cached command. */
8147 && !(SYMBOLP (def) && EQ (tem, XSYMBOL (def)->function))))
8148 chkcache = 1; /* Need to recompute key binding. */
8149
8150 if (chkcache)
8151 { 8093 {
8152 /* Recompute equivalent key binding. If the command is an alias 8094 keys = XCAR (keyhint);
8153 for another (such as lmenu.el set it up), see if the original 8095 tem = Fkey_binding (keys, Qnil, Qnil, Qnil);
8154 command name has equivalent keys. Otherwise look up the
8155 specified command itself. We don't try both, because that
8156 makes lmenu menus slow. */
8157 if (SYMBOLP (def)
8158 && SYMBOLP (XSYMBOL (def)->function)
8159 && ! NILP (Fget (def, Qmenu_alias)))
8160 def = XSYMBOL (def)->function;
8161 tem = Fwhere_is_internal (def, Qnil, Qt, Qnil, Qnil);
8162
8163 XSETCAR (cachelist, tem);
8164 if (NILP (tem))
8165 {
8166 XSETCDR (cachelist, Qnil);
8167 chkcache = 0;
8168 }
8169 }
8170 else if (!NILP (keyhint) && !NILP (XCAR (cachelist)))
8171 {
8172 tem = XCAR (cachelist);
8173 chkcache = 1;
8174 }
8175 8096
8176 newcache = chkcache; 8097 /* We have a suggested key. Is it bound to the command? */
8177 if (chkcache) 8098 if (NILP (tem)
8099 || (!EQ (tem, def)
8100 /* If the command is an alias for another
8101 (such as lmenu.el set it up), check if the
8102 original command matches the cached command. */
8103 && !(SYMBOLP (def) && EQ (tem, XSYMBOL (def)->function))))
8104 keys = Qnil;
8105 }
8106
8107 if (NILP (keys))
8108 keys = Fwhere_is_internal (def, Qnil, Qt, Qnil, Qnil);
8109
8110 if (!NILP (keys))
8178 { 8111 {
8179 tem = Fkey_description (tem, Qnil); 8112 tem = Fkey_description (keys, Qnil);
8180 if (CONSP (prefix)) 8113 if (CONSP (prefix))
8181 { 8114 {
8182 if (STRINGP (XCAR (prefix))) 8115 if (STRINGP (XCAR (prefix)))
@@ -8184,17 +8117,11 @@ parse_menu_item (item, notreal, inmenubar)
8184 if (STRINGP (XCDR (prefix))) 8117 if (STRINGP (XCDR (prefix)))
8185 tem = concat2 (tem, XCDR (prefix)); 8118 tem = concat2 (tem, XCDR (prefix));
8186 } 8119 }
8187 XSETCDR (cachelist, tem); 8120 tem = concat2 (build_string (" "), tem);
8121 /* tem = concat3 (build_string (" ("), tem, build_string (")")); */
8188 } 8122 }
8189 } 8123 }
8190 8124
8191 tem = XCDR (cachelist);
8192 if (newcache && !NILP (tem))
8193 {
8194 tem = concat2 (build_string (" "), tem);
8195 /* tem = concat3 (build_string (" ("), tem, build_string (")")); */
8196 XSETCDR (cachelist, tem);
8197 }
8198 8125
8199 /* If we only want to precompute equivalent key bindings, stop here. */ 8126 /* If we only want to precompute equivalent key bindings, stop here. */
8200 if (notreal) 8127 if (notreal)
@@ -11870,8 +11797,6 @@ syms_of_keyboard ()
11870 11797
11871 Qmenu_enable = intern ("menu-enable"); 11798 Qmenu_enable = intern ("menu-enable");
11872 staticpro (&Qmenu_enable); 11799 staticpro (&Qmenu_enable);
11873 Qmenu_alias = intern ("menu-alias");
11874 staticpro (&Qmenu_alias);
11875 QCenable = intern (":enable"); 11800 QCenable = intern (":enable");
11876 staticpro (&QCenable); 11801 staticpro (&QCenable);
11877 QCvisible = intern (":visible"); 11802 QCvisible = intern (":visible");