Commit 224a16e8 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(get_keymap): Pass 1 as ERROR to get_keymap_1.

(get_keyelt): New arg AUTOLOAD means load keymaps indirected thru.
All callers changed; most pass 0.
(Fdefine_key, Flookup_key): Load all the keymaps we look in.
parent 61df1a5e
...@@ -246,7 +246,7 @@ Lisp_Object ...@@ -246,7 +246,7 @@ Lisp_Object
get_keymap (object) get_keymap (object)
Lisp_Object object; Lisp_Object object;
{ {
return get_keymap_1 (object, 0, 0); return get_keymap_1 (object, 1, 0);
} }
...@@ -344,18 +344,22 @@ access_keymap (map, idx, t_ok, noinherit) ...@@ -344,18 +344,22 @@ access_keymap (map, idx, t_ok, noinherit)
and INDEX is the object to look up in KEYMAP to yield the definition. and INDEX is the object to look up in KEYMAP to yield the definition.
Also if OBJECT has a menu string as the first element, Also if OBJECT has a menu string as the first element,
remove that. Also remove a menu help string as second element. */ remove that. Also remove a menu help string as second element.
If AUTOLOAD is nonzero, load autoloadable keymaps
that are referred to with indirection. */
Lisp_Object Lisp_Object
get_keyelt (object) get_keyelt (object, autoload)
register Lisp_Object object; register Lisp_Object object;
int autoload;
{ {
while (1) while (1)
{ {
register Lisp_Object map, tem; register Lisp_Object map, tem;
/* If the contents are (KEYMAP . ELEMENT), go indirect. */ /* If the contents are (KEYMAP . ELEMENT), go indirect. */
map = get_keymap_1 (Fcar_safe (object), 0, 0); map = get_keymap_1 (Fcar_safe (object), 0, autoload);
tem = Fkeymapp (map); tem = Fkeymapp (map);
if (!NILP (tem)) if (!NILP (tem))
object = access_keymap (map, Fcdr (object), 0, 0); object = access_keymap (map, Fcdr (object), 0, 0);
...@@ -583,7 +587,7 @@ the front of KEYMAP.") ...@@ -583,7 +587,7 @@ the front of KEYMAP.")
int length; int length;
struct gcpro gcpro1, gcpro2, gcpro3; struct gcpro gcpro1, gcpro2, gcpro3;
keymap = get_keymap (keymap); keymap = get_keymap_1 (keymap, 1, 1);
if (XTYPE (key) != Lisp_Vector if (XTYPE (key) != Lisp_Vector
&& XTYPE (key) != Lisp_String) && XTYPE (key) != Lisp_String)
...@@ -627,7 +631,7 @@ the front of KEYMAP.") ...@@ -627,7 +631,7 @@ the front of KEYMAP.")
if (idx == length) if (idx == length)
RETURN_UNGCPRO (store_in_keymap (keymap, c, def)); RETURN_UNGCPRO (store_in_keymap (keymap, c, def));
cmd = get_keyelt (access_keymap (keymap, c, 0, 1)); cmd = get_keyelt (access_keymap (keymap, c, 0, 1), 1);
/* If this key is undefined, make it a prefix. */ /* If this key is undefined, make it a prefix. */
if (NILP (cmd)) if (NILP (cmd))
...@@ -673,7 +677,7 @@ recognize the default bindings, just as `read-key-sequence' does.") ...@@ -673,7 +677,7 @@ recognize the default bindings, just as `read-key-sequence' does.")
int t_ok = ! NILP (accept_default); int t_ok = ! NILP (accept_default);
int meta_bit; int meta_bit;
keymap = get_keymap (keymap); keymap = get_keymap_1 (keymap, 1, 1);
if (XTYPE (key) != Lisp_Vector if (XTYPE (key) != Lisp_Vector
&& XTYPE (key) != Lisp_String) && XTYPE (key) != Lisp_String)
...@@ -709,11 +713,11 @@ recognize the default bindings, just as `read-key-sequence' does.") ...@@ -709,11 +713,11 @@ recognize the default bindings, just as `read-key-sequence' does.")
idx++; idx++;
} }
cmd = get_keyelt (access_keymap (keymap, c, t_ok, 0)); cmd = get_keyelt (access_keymap (keymap, c, t_ok, 0), 1);
if (idx == length) if (idx == length)
return cmd; return cmd;
keymap = get_keymap_1 (cmd, 0, 0); keymap = get_keymap_1 (cmd, 0, 1);
if (NILP (keymap)) if (NILP (keymap))
return make_number (idx); return make_number (idx);
...@@ -1170,7 +1174,7 @@ then the value includes only maps for prefixes that start with PREFIX.") ...@@ -1170,7 +1174,7 @@ then the value includes only maps for prefixes that start with PREFIX.")
register Lisp_Object tem; register Lisp_Object tem;
register Lisp_Object cmd; register Lisp_Object cmd;
cmd = get_keyelt (XVECTOR (elt)->contents[i]); cmd = get_keyelt (XVECTOR (elt)->contents[i], 0);
if (NILP (cmd)) continue; if (NILP (cmd)) continue;
tem = Fkeymapp (cmd); tem = Fkeymapp (cmd);
if (!NILP (tem)) if (!NILP (tem))
...@@ -1211,7 +1215,7 @@ then the value includes only maps for prefixes that start with PREFIX.") ...@@ -1211,7 +1215,7 @@ then the value includes only maps for prefixes that start with PREFIX.")
{ {
register Lisp_Object cmd, tem, filter; register Lisp_Object cmd, tem, filter;
cmd = get_keyelt (XCONS (elt)->cdr); cmd = get_keyelt (XCONS (elt)->cdr, 0);
/* Ignore definitions that aren't keymaps themselves. */ /* Ignore definitions that aren't keymaps themselves. */
tem = Fkeymapp (cmd); tem = Fkeymapp (cmd);
if (!NILP (tem)) if (!NILP (tem))
...@@ -1635,7 +1639,7 @@ indirect definition itself.") ...@@ -1635,7 +1639,7 @@ indirect definition itself.")
/* Search through indirections unless that's not wanted. */ /* Search through indirections unless that's not wanted. */
if (NILP (noindirect)) if (NILP (noindirect))
binding = get_keyelt (binding); binding = get_keyelt (binding, 0);
/* End this iteration if this element does not match /* End this iteration if this element does not match
the target. */ the target. */
...@@ -2082,7 +2086,7 @@ describe_map_2 (keymap, elt_prefix, elt_describer, partial, shadow) ...@@ -2082,7 +2086,7 @@ describe_map_2 (keymap, elt_prefix, elt_describer, partial, shadow)
else else
{ {
event = Fcar_safe (Fcar (tail)); event = Fcar_safe (Fcar (tail));
definition = get_keyelt (Fcdr_safe (Fcar (tail))); definition = get_keyelt (Fcdr_safe (Fcar (tail)), 0);
/* Don't show undefined commands or suppressed commands. */ /* Don't show undefined commands or suppressed commands. */
if (NILP (definition)) continue; if (NILP (definition)) continue;
...@@ -2182,7 +2186,7 @@ describe_vector (vector, elt_prefix, elt_describer, partial, shadow) ...@@ -2182,7 +2186,7 @@ describe_vector (vector, elt_prefix, elt_describer, partial, shadow)
for (i = 0; i < XVECTOR (vector)->size; i++) for (i = 0; i < XVECTOR (vector)->size; i++)
{ {
QUIT; QUIT;
tem1 = get_keyelt (XVECTOR (vector)->contents[i]); tem1 = get_keyelt (XVECTOR (vector)->contents[i], 0);
if (NILP (tem1)) continue; if (NILP (tem1)) continue;
...@@ -2225,7 +2229,7 @@ describe_vector (vector, elt_prefix, elt_describer, partial, shadow) ...@@ -2225,7 +2229,7 @@ describe_vector (vector, elt_prefix, elt_describer, partial, shadow)
/* Find all consecutive characters that have the same definition. */ /* Find all consecutive characters that have the same definition. */
while (i + 1 < XVECTOR (vector)->size while (i + 1 < XVECTOR (vector)->size
&& (tem2 = get_keyelt (XVECTOR (vector)->contents[i+1]), && (tem2 = get_keyelt (XVECTOR (vector)->contents[i+1], 0),
EQ (tem2, tem1))) EQ (tem2, tem1)))
i++; i++;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment