and loop around to read another event. */
save = Vquit_flag;
Vquit_flag = Qnil;
- tem = access_keymap (get_keymap_1 (Vspecial_event_map, 0, 0), c, 0, 0, 1);
+ tem = access_keymap (get_keymap (Vspecial_event_map, 0, 1), c, 0, 0, 1);
Vquit_flag = save;
if (!NILP (tem))
for (mapno = nmaps - 1; mapno >= 0; mapno--)
if (!NILP (maps[mapno]))
{
- def = access_keymap (maps[mapno], Qmenu_bar, 1, 0, 0);
- tem = Fkeymapp (def);
- if (!NILP (tem))
+ def = get_keymap (access_keymap (maps[mapno], Qmenu_bar, 1, 0, 0),
+ 0, 0);
+ if (CONSP (def))
menu_bar_one_keymap (def);
}
{
Lisp_Object tail, item;
- /* If KEYMAP is a symbol, its function definition is the keymap
- to use. */
- if (SYMBOLP (keymap))
- keymap = indirect_function (keymap);
-
menu_bar_one_keymap_changed_items = Qnil;
/* Loop over all keymap entries that have menu strings. */
/* See if this is a separate pane or a submenu. */
def = AREF (item_properties, ITEM_PROPERTY_DEF);
- tem = get_keymap_1 (def, 0, 1);
+ tem = get_keymap (def, 0, 1);
/* For a subkeymap, just record its details and exit. */
- if (!NILP (tem))
+ if (CONSP (tem))
{
AREF (item_properties, ITEM_PROPERTY_MAP) = tem;
AREF (item_properties, ITEM_PROPERTY_DEF) = tem;
Lisp_Object keymap;
/* Why set the `noinherit' flag ? -sm */
- keymap = access_keymap (maps[i], Qtool_bar, 1, 1, 0);
- if (!NILP (Fkeymapp (keymap)))
+ keymap = get_keymap (access_keymap (maps[i], Qtool_bar, 1, 1, 0), 0, 0);
+ if (CONSP (keymap))
{
Lisp_Object tail;
- /* If KEYMAP is a symbol, its function definition is the
- keymap to use. */
- if (SYMBOLP (keymap))
- keymap = indirect_function (keymap);
-
/* KEYMAP is a list `(keymap (KEY . BINDING) ...)'. */
for (tail = keymap; CONSP (tail); tail = XCDR (tail))
{
PROP (TOOL_BAR_ITEM_BINDING))));
/* See if the binding is a keymap. Give up if it is. */
- if (!NILP (get_keymap_1 (PROP (TOOL_BAR_ITEM_BINDING), 0, 1)))
+ if (CONSP (get_keymap (PROP (TOOL_BAR_ITEM_BINDING), 0, 1)))
return 0;
/* Enable or disable selection of item. */
/* Given the set of bindings we've found, produce the next set of maps. */
if (first_binding < nmaps)
for (i = 0; i < nmaps; i++)
- next[i] = NILP (defs[i]) ? Qnil : get_keymap_1 (defs[i], 0, 1);
+ next[i] = NILP (defs[i]) ? Qnil : get_keymap (defs[i], 0, 1);
return first_binding;
}
keytran_map = Vkey_translation_map;
/* If there is no function-key-map, turn off function key scanning. */
- if (NILP (Fkeymapp (Vfunction_key_map)))
+ if (!KEYMAPP (Vfunction_key_map))
fkey_start = fkey_end = bufsize + 1;
/* If there is no key-translation-map, turn off scanning. */
- if (NILP (Fkeymapp (Vkey_translation_map)))
+ if (!KEYMAPP (Vkey_translation_map))
keytran_start = keytran_end = bufsize + 1;
if (INTERACTIVE)
or an array. */
if (SYMBOLP (fkey_next) && ! NILP (Ffboundp (fkey_next))
&& (!NILP (Farrayp (XSYMBOL (fkey_next)->function))
- || !NILP (Fkeymapp (XSYMBOL (fkey_next)->function))))
+ || KEYMAPP (XSYMBOL (fkey_next)->function)))
fkey_next = XSYMBOL (fkey_next)->function;
#if 0 /* I didn't turn this on, because it might cause trouble
goto replay_sequence;
}
- fkey_map = get_keymap_1 (fkey_next, 0, 1);
+ fkey_map = get_keymap (fkey_next, 0, 1);
/* If we no longer have a bound suffix, try a new positions for
fkey_start. */
- if (NILP (fkey_map))
+ if (!CONSP (fkey_map))
{
fkey_end = ++fkey_start;
fkey_map = Vfunction_key_map;
or an array. */
if (SYMBOLP (keytran_next) && ! NILP (Ffboundp (keytran_next))
&& (!NILP (Farrayp (XSYMBOL (keytran_next)->function))
- || !NILP (Fkeymapp (XSYMBOL (keytran_next)->function))))
+ || KEYMAPP (XSYMBOL (keytran_next)->function)))
keytran_next = XSYMBOL (keytran_next)->function;
/* If the key translation map gives a function, not an
goto replay_sequence;
}
- keytran_map = get_keymap_1 (keytran_next, 0, 1);
+ keytran_map = get_keymap (keytran_next, 0, 1);
/* If we no longer have a bound suffix, try a new positions for
keytran_start. */
- if (NILP (keytran_map))
+ if (!CONSP (keytran_map))
{
keytran_end = ++keytran_start;
keytran_map = Vkey_translation_map;
#include "intervals.h"
#define min(a, b) ((a) < (b) ? (a) : (b))
-#define KEYMAPP(m) (!NILP (Fkeymapp (m)))
/* The number of elements in keymap vectors. */
#define DENSE_TABLE_SIZE (0200)
(object)
Lisp_Object object;
{
- /* FIXME: Maybe this should return t for autoloaded keymaps? -sm */
- return (NILP (get_keymap_1 (object, 0, 0)) ? Qnil : Qt);
+ return (KEYMAPP (object) ? Qt : Qnil);
}
/* Check that OBJECT is a keymap (after dereferencing through any
is an autoload form, do the autoload and try again.
If AUTOLOAD is nonzero, callers must assume GC is possible.
+ If the map needs to be autoloaded, but AUTOLOAD is zero (and ERROR
+ is zero as well), return Qt.
+
ERROR controls how we respond if OBJECT isn't a keymap.
If ERROR is non-zero, signal an error; otherwise, just return Qnil.
do_autoload which can GC. */
Lisp_Object
-get_keymap_1 (object, error, autoload)
+get_keymap (object, error, autoload)
Lisp_Object object;
int error, autoload;
{
goto end;
if (CONSP (object) && EQ (XCAR (object), Qkeymap))
return object;
- else
- {
- tem = indirect_function (object);
- if (CONSP (tem) && EQ (XCAR (tem), Qkeymap))
- return tem;
- }
- /* Should we do an autoload? Autoload forms for keymaps have
- Qkeymap as their fifth element. */
- if (autoload
- && SYMBOLP (object)
- && CONSP (tem)
- && EQ (XCAR (tem), Qautoload))
+ tem = indirect_function (object);
+ if (CONSP (tem))
{
- Lisp_Object tail;
+ if (EQ (XCAR (tem), Qkeymap))
+ return tem;
- tail = Fnth (make_number (4), tem);
- if (EQ (tail, Qkeymap))
+ /* Should we do an autoload? Autoload forms for keymaps have
+ Qkeymap as their fifth element. */
+ if ((autoload || !error) && EQ (XCAR (tem), Qautoload))
{
- struct gcpro gcpro1, gcpro2;
-
- GCPRO2 (tem, object);
- do_autoload (tem, object);
- UNGCPRO;
+ Lisp_Object tail;
- goto autoload_retry;
+ tail = Fnth (make_number (4), tem);
+ if (EQ (tail, Qkeymap))
+ {
+ if (autoload)
+ {
+ struct gcpro gcpro1, gcpro2;
+
+ GCPRO2 (tem, object);
+ do_autoload (tem, object);
+ UNGCPRO;
+
+ goto autoload_retry;
+ }
+ else
+ return Qt;
+ }
}
}
wrong_type_argument (Qkeymapp, object);
return Qnil;
}
-
-
-/* Follow any symbol chaining, and return the keymap denoted by OBJECT.
- If OBJECT doesn't denote a keymap at all, signal an error. */
-Lisp_Object
-get_keymap (object)
- Lisp_Object object;
-{
- return get_keymap_1 (object, 1, 0);
-}
\f
/* Return the parent map of the keymap MAP, or nil if it has none.
We assume that MAP is a valid keymap. */
{
Lisp_Object list;
- keymap = get_keymap_1 (keymap, 1, 1);
+ keymap = get_keymap (keymap, 1, 1);
/* Skip past the initial element `keymap'. */
list = XCDR (keymap);
return list;
}
- return get_keymap_1(list, 0, 1);
+ return get_keymap (list, 0, 1);
}
This is a very minor correctness (rather than safety) issue. */
where_is_cache_keymaps = Qt;
- keymap = get_keymap_1 (keymap, 1, 1);
+ keymap = get_keymap (keymap, 1, 1);
GCPRO1 (keymap);
if (!NILP (parent))
{
- parent = get_keymap_1 (parent, 1, 1);
+ parent = get_keymap (parent, 1, 1);
/* Check for cycles. */
if (keymap_memberp (keymap, parent))
/* SUBMAP is a cons that we found as a key binding.
Discard the other things found in a menu key binding. */
- submap = get_keymap_1 (get_keyelt (submap, 0), 0, 0);
+ submap = get_keymap (get_keyelt (submap, 0), 0, 0);
/* If it isn't a keymap now, there's no work to do. */
- if (NILP (submap))
+ if (!CONSP (submap))
return;
map_parent = Fkeymap_parent (map);
- if (! NILP (map_parent))
+ if (!NILP (map_parent))
parent_entry =
- get_keymap_1 (access_keymap (map_parent, event, 0, 0, 0), 0, 0);
+ get_keymap (access_keymap (map_parent, event, 0, 0, 0), 0, 0);
else
parent_entry = Qnil;
/* If MAP's parent has something other than a keymap,
our own submap shadows it completely. */
- if (NILP (parent_entry))
+ if (!CONSP (parent_entry))
return;
if (! EQ (parent_entry, submap))
/* See if there is a meta-map. If there's none, there is
no binding for IDX, unless a default binding exists in MAP. */
Lisp_Object meta_map =
- get_keymap_1 (access_keymap (map, meta_prefix_char,
- t_ok, noinherit, autoload),
- 0, autoload);
- if (!NILP (meta_map))
+ get_keymap (access_keymap (map, meta_prefix_char,
+ t_ok, noinherit, autoload),
+ 0, autoload);
+ if (CONSP (meta_map))
{
map = meta_map;
idx = make_number (XUINT (idx) & ~meta_modifier);
t_binding = Qnil;
for (tail = XCDR (map);
(CONSP (tail)
- || (tail = get_keymap_1 (tail, 0, autoload),
- CONSP (tail)));
+ || (tail = get_keymap (tail, 0, autoload), CONSP (tail)));
tail = XCDR (tail))
{
Lisp_Object binding;
else
{
Lisp_Object map;
- map = get_keymap_1 (Fcar_safe (object), 0, autoload);
- return (NILP (map) ? object /* Invalid keymap */
+ map = get_keymap (Fcar_safe (object), 0, autoload);
+ return (!CONSP (map) ? object /* Invalid keymap */
: access_keymap (map, Fcdr (object), 0, 0, autoload));
}
}
copy_keymap_1 (chartable, idx, elt)
Lisp_Object chartable, idx, elt;
{
- if (!SYMBOLP (elt) && ! NILP (Fkeymapp (elt)))
+ if (CONSP (elt) && EQ (XCAR (elt), Qkeymap))
Faset (chartable, idx, Fcopy_keymap (elt));
}
{
register Lisp_Object copy, tail;
- copy = Fcopy_alist (get_keymap (keymap));
+ copy = Fcopy_alist (get_keymap (keymap, 1, 0));
for (tail = copy; CONSP (tail); tail = XCDR (tail))
{
XCAR (tail) = elt;
for (i = 0; i < ASIZE (elt); i++)
- if (!SYMBOLP (AREF (elt, i))
- && ! NILP (Fkeymapp (AREF (elt, i))))
+ if (CONSP (AREF (elt, i)) && EQ (XCAR (AREF (elt, i)), Qkeymap))
ASET (elt, i, Fcopy_keymap (AREF (elt, i)));
}
else if (CONSP (elt) && CONSP (XCDR (elt)))
= Fcons (XCAR (tem), XCDR (tem));
elt = XCDR (elt);
tem = XCAR (elt);
- if (!(SYMBOLP (tem) || NILP (Fkeymapp (tem))))
+ if (CONSP (tem) && EQ (XCAR (tem), Qkeymap))
XCAR (elt) = Fcopy_keymap (tem);
tem = XCDR (elt);
if (CONSP (tem) && CONSP (XCAR (tem)))
XCDR (elt) = XCDR (tem);
}
if (CONSP (elt)
- && ! SYMBOLP (XCDR (elt))
- && ! NILP (Fkeymapp (XCDR (elt))))
+ && CONSP (XCDR (elt))
+ && EQ (XCAR (XCDR (elt)), Qkeymap))
XCDR (elt) = Fcopy_keymap (XCDR (elt));
}
int length;
struct gcpro gcpro1, gcpro2, gcpro3;
- keymap = get_keymap_1 (keymap, 1, 1);
+ keymap = get_keymap (keymap, 1, 1);
if (!VECTORP (key) && !STRINGP (key))
key = wrong_type_argument (Qarrayp, key);
if (NILP (cmd))
cmd = define_as_prefix (keymap, c);
- keymap = get_keymap_1 (cmd, 0, 1);
- if (NILP (keymap))
+ keymap = get_keymap (cmd, 0, 1);
+ if (!CONSP (keymap))
/* We must use Fkey_description rather than just passing key to
error; key might be a vector, not a string. */
error ("Key sequence %s uses invalid prefix characters",
int t_ok = ! NILP (accept_default);
struct gcpro gcpro1;
- keymap = get_keymap_1 (keymap, 1, 1);
+ keymap = get_keymap (keymap, 1, 1);
if (!VECTORP (key) && !STRINGP (key))
key = wrong_type_argument (Qarrayp, key);
if (idx == length)
RETURN_UNGCPRO (cmd);
- keymap = get_keymap_1 (cmd, 0, 1);
- if (NILP (keymap))
+ keymap = get_keymap (cmd, 0, 1);
+ if (!CONSP (keymap))
RETURN_UNGCPRO (make_number (idx));
QUIT;
GCPRO2 (key, binding);
for (i = j = 0; i < nmaps; i++)
- if (! NILP (maps[i])
- && ! NILP (binding = Flookup_key (maps[i], key, accept_default))
+ if (!NILP (maps[i])
+ && !NILP (binding = Flookup_key (maps[i], key, accept_default))
&& !INTEGERP (binding))
{
- if (! NILP (get_keymap (binding)))
+ if (KEYMAPP (binding))
maps[j++] = Fcons (modes[i], binding);
else if (j == 0)
RETURN_UNGCPRO (Fcons (Fcons (modes[i], binding), Qnil));
(keymap)
Lisp_Object keymap;
{
- keymap = get_keymap (keymap);
+ keymap = get_keymap (keymap, 1, 1);
current_global_map = keymap;
return Qnil;
Lisp_Object keymap;
{
if (!NILP (keymap))
- keymap = get_keymap (keymap);
+ keymap = get_keymap (keymap, 1, 1);
current_buffer->keymap = keymap;
/* Flookup_key may give us nil, or a number,
if the prefix is not defined in this particular map.
It might even give us a list that isn't a keymap. */
- tem = get_keymap_1 (tem, 0, 0);
- if (!NILP (tem))
+ tem = get_keymap (tem, 0, 0);
+ if (CONSP (tem))
{
/* Convert PREFIX to a vector now, so that later on
we don't have to deal with the possibility of a string. */
}
else
maps = Fcons (Fcons (Fmake_vector (make_number (0), Qnil),
- get_keymap (keymap)),
+ get_keymap (keymap, 1, 0)),
Qnil);
/* For each map in the list maps,
cmd = get_keyelt (AREF (elt, i), 0);
if (NILP (cmd)) continue;
- tem = Fkeymapp (cmd);
- if (!NILP (tem))
+ tem = get_keymap (cmd, 0, 0);
+ if (CONSP (tem))
{
- cmd = get_keymap (cmd);
+ cmd = tem;
/* Ignore keymaps that are already added to maps. */
tem = Frassq (cmd, maps);
if (NILP (tem))
cmd = get_keyelt (XCDR (elt), 0);
/* Ignore definitions that aren't keymaps themselves. */
- tem = Fkeymapp (cmd);
- if (!NILP (tem))
+ tem = get_keymap (cmd, 0, 0);
+ if (CONSP (tem))
{
/* Ignore keymaps that have been seen already. */
- cmd = get_keymap (cmd);
+ cmd = tem;
tem = Frassq (cmd, maps);
if (NILP (tem))
{
tail = XCAR (XCDR (args));
thisseq = XCDR (XCDR (args));
- tem = Fkeymapp (cmd);
- if (!NILP (tem))
+ tem = get_keymap (cmd, 0, 0);
+ if (CONSP (tem))
{
- cmd = get_keymap (cmd);
+ cmd = tem;
/* Ignore keymaps that are already added to maps. */
tem = Frassq (cmd, maps);
if (NILP (tem))
while (CONSP (found))
{
maps =
- nconc2 (maps, Faccessible_keymaps (get_keymap (XCAR (found)), Qnil));
+ nconc2 (maps,
+ Faccessible_keymaps (get_keymap (XCAR (found), 1, 0), Qnil));
found = XCDR (found);
}
/* If shmap is not nil and not a keymap,
it completely shadows this map, so don't
describe this map at all. */
- if (!NILP (shmap) && NILP (Fkeymapp (shmap)))
+ if (!NILP (shmap) && !KEYMAPP (shmap))
goto skip;
if (!NILP (shmap))
}
else if (STRINGP (definition) || VECTORP (definition))
insert_string ("Keyboard Macro\n");
+ else if (KEYMAPP (definition))
+ insert_string ("Prefix Command\n");
else
- {
- tem1 = Fkeymapp (definition);
- if (!NILP (tem1))
- insert_string ("Prefix Command\n");
- else
- insert_string ("??\n");
- }
+ insert_string ("??\n");
}
static void
insert1 (Fkey_description (definition));
insert_string ("\n");
}
+ else if (KEYMAPP (definition))
+ insert_string ("Prefix Command\n");
else
- {
- tem1 = Fkeymapp (definition);
- if (!NILP (tem1))
- insert_string ("Prefix Command\n");
- else
- insert_string ("??\n");
- }
+ insert_string ("??\n");
}
/* Describe the contents of map MAP, assuming that this map itself is