Commit e25c4e44 authored by Jim Blandy's avatar Jim Blandy

* keymap.c (initial_define_lispy_key): New function, for defining

	non-ascii keys.

	* keymap.c (access_keymap): Treat bindings for Qt as default
	bindings, when new argument T_OK is non-zero.
	(get_keyelt, Fdefine_key, Flookup_key): Call access_keymap with
	T_OK false.
parent 6084b314
...@@ -128,13 +128,7 @@ in case you use it as a menu with `x-popup-menu'.") ...@@ -128,13 +128,7 @@ in case you use it as a menu with `x-popup-menu'.")
For example: For example:
initial_define_key (control_x_map, Ctl('X'), "exchange-point-and-mark"); initial_define_key (control_x_map, Ctl('X'), "exchange-point-and-mark"); */
I haven't extended these to allow the initializing code to bind
function keys and mouse events; since they are called by many files,
I'd have to fix lots of callers, and nobody right now would be using
the new functionality, so it seems like a waste of time. But there's
no technical reason not to. -JimB */
void void
initial_define_key (keymap, key, defname) initial_define_key (keymap, key, defname)
...@@ -145,6 +139,15 @@ initial_define_key (keymap, key, defname) ...@@ -145,6 +139,15 @@ initial_define_key (keymap, key, defname)
store_in_keymap (keymap, make_number (key), intern (defname)); store_in_keymap (keymap, make_number (key), intern (defname));
} }
void
initial_define_lispy_key (keymap, keyname, defname)
Lisp_Object keymap;
char *keyname;
char *defname;
{
store_in_keymap (keymap, intern (keyname), intern (defname));
}
/* Define character fromchar in map frommap as an alias for character /* Define character fromchar in map frommap as an alias for character
tochar in map tomap. Subsequent redefinitions of the latter WILL tochar in map tomap. Subsequent redefinitions of the latter WILL
affect the former. */ affect the former. */
...@@ -205,12 +208,19 @@ get_keymap (object) ...@@ -205,12 +208,19 @@ get_keymap (object)
/* Look up IDX in MAP. IDX may be any sort of event. /* Look up IDX in MAP. IDX may be any sort of event.
Note that this does only one level of lookup; IDX must be a single Note that this does only one level of lookup; IDX must be a single
event, not a sequence. */ event, not a sequence.
If T_OK is non-zero, bindings for Qt are treated as default
bindings; any key left unmentioned by other tables and bindings is
given the binding of Qt.
If T_OK is zero, bindings for Qt are not treated specially. */
Lisp_Object Lisp_Object
access_keymap (map, idx) access_keymap (map, idx, t_ok)
Lisp_Object map; Lisp_Object map;
Lisp_Object idx; Lisp_Object idx;
int t_ok;
{ {
/* If idx is a list (some sort of mouse click, perhaps?), /* If idx is a list (some sort of mouse click, perhaps?),
the index we want to use is the car of the list, which the index we want to use is the car of the list, which
...@@ -219,7 +229,7 @@ access_keymap (map, idx) ...@@ -219,7 +229,7 @@ access_keymap (map, idx)
if (XTYPE (idx) == Lisp_Int if (XTYPE (idx) == Lisp_Int
&& (XINT (idx) < 0 || XINT (idx) >= DENSE_TABLE_SIZE)) && (XINT (idx) < 0 || XINT (idx) >= DENSE_TABLE_SIZE))
error ("only ASCII characters may used as keymap indices"); error ("only ASCII characters may be looked up in keymaps");
/* If idx is a symbol, it might have modifiers, which need to /* If idx is a symbol, it might have modifiers, which need to
be put in the canonical order. */ be put in the canonical order. */
...@@ -228,6 +238,7 @@ access_keymap (map, idx) ...@@ -228,6 +238,7 @@ access_keymap (map, idx)
{ {
Lisp_Object tail; Lisp_Object tail;
Lisp_Object t_binding = Qnil;
for (tail = map; CONSP (tail); tail = XCONS (tail)->cdr) for (tail = map; CONSP (tail); tail = XCONS (tail)->cdr)
{ {
...@@ -238,6 +249,8 @@ access_keymap (map, idx) ...@@ -238,6 +249,8 @@ access_keymap (map, idx)
case Lisp_Cons: case Lisp_Cons:
if (EQ (XCONS (binding)->car, idx)) if (EQ (XCONS (binding)->car, idx))
return XCONS (binding)->cdr; return XCONS (binding)->cdr;
if (t_ok && EQ (XCONS (binding)->car, Qt))
t_binding = XCONS (binding)->cdr;
break; break;
case Lisp_Vector: case Lisp_Vector:
...@@ -249,9 +262,9 @@ access_keymap (map, idx) ...@@ -249,9 +262,9 @@ access_keymap (map, idx)
QUIT; QUIT;
} }
}
return Qnil; return t_binding;
}
} }
/* Given OBJECT which was found in a slot in a keymap, /* Given OBJECT which was found in a slot in a keymap,
...@@ -275,7 +288,7 @@ get_keyelt (object) ...@@ -275,7 +288,7 @@ get_keyelt (object)
map = get_keymap_1 (Fcar_safe (object), 0); map = get_keymap_1 (Fcar_safe (object), 0);
tem = Fkeymapp (map); tem = Fkeymapp (map);
if (!NILP (tem)) if (!NILP (tem))
object = access_keymap (map, Fcdr (object)); object = access_keymap (map, Fcdr (object), 0);
/* If the keymap contents looks like (STRING . DEFN), /* If the keymap contents looks like (STRING . DEFN),
use DEFN. use DEFN.
...@@ -487,7 +500,7 @@ the front of KEYMAP.") ...@@ -487,7 +500,7 @@ the front of KEYMAP.")
if (idx == length) if (idx == length)
return store_in_keymap (keymap, c, def); return store_in_keymap (keymap, c, def);
cmd = get_keyelt (access_keymap (keymap, c)); cmd = get_keyelt (access_keymap (keymap, c, 0));
if (NILP (cmd)) if (NILP (cmd))
{ {
...@@ -556,7 +569,7 @@ it takes to reach a non-prefix command.") ...@@ -556,7 +569,7 @@ it takes to reach a non-prefix command.")
idx++; idx++;
} }
cmd = get_keyelt (access_keymap (keymap, c)); cmd = get_keyelt (access_keymap (keymap, c, 0));
if (idx == length) if (idx == length)
return cmd; return cmd;
......
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