diff options
| author | Jim Blandy | 1992-10-11 06:43:30 +0000 |
|---|---|---|
| committer | Jim Blandy | 1992-10-11 06:43:30 +0000 |
| commit | e25c4e44b8a2ca70856ec5c0ebf1151f49871de3 (patch) | |
| tree | 045683367bd709e2f831069ad931d979a1d40a0a /src | |
| parent | 6084b314a58f8279db2b77ecd0b3f8d07570054c (diff) | |
| download | emacs-e25c4e44b8a2ca70856ec5c0ebf1151f49871de3.tar.gz emacs-e25c4e44b8a2ca70856ec5c0ebf1151f49871de3.zip | |
* 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keymap.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/keymap.c b/src/keymap.c index 069d6460c1c..b2ca9e11e94 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -128,13 +128,7 @@ in case you use it as a menu with `x-popup-menu'.") | |||
| 128 | 128 | ||
| 129 | For example: | 129 | For example: |
| 130 | 130 | ||
| 131 | initial_define_key (control_x_map, Ctl('X'), "exchange-point-and-mark"); | 131 | initial_define_key (control_x_map, Ctl('X'), "exchange-point-and-mark"); */ |
| 132 | |||
| 133 | I haven't extended these to allow the initializing code to bind | ||
| 134 | function keys and mouse events; since they are called by many files, | ||
| 135 | I'd have to fix lots of callers, and nobody right now would be using | ||
| 136 | the new functionality, so it seems like a waste of time. But there's | ||
| 137 | no technical reason not to. -JimB */ | ||
| 138 | 132 | ||
| 139 | void | 133 | void |
| 140 | initial_define_key (keymap, key, defname) | 134 | initial_define_key (keymap, key, defname) |
| @@ -145,6 +139,15 @@ initial_define_key (keymap, key, defname) | |||
| 145 | store_in_keymap (keymap, make_number (key), intern (defname)); | 139 | store_in_keymap (keymap, make_number (key), intern (defname)); |
| 146 | } | 140 | } |
| 147 | 141 | ||
| 142 | void | ||
| 143 | initial_define_lispy_key (keymap, keyname, defname) | ||
| 144 | Lisp_Object keymap; | ||
| 145 | char *keyname; | ||
| 146 | char *defname; | ||
| 147 | { | ||
| 148 | store_in_keymap (keymap, intern (keyname), intern (defname)); | ||
| 149 | } | ||
| 150 | |||
| 148 | /* Define character fromchar in map frommap as an alias for character | 151 | /* Define character fromchar in map frommap as an alias for character |
| 149 | tochar in map tomap. Subsequent redefinitions of the latter WILL | 152 | tochar in map tomap. Subsequent redefinitions of the latter WILL |
| 150 | affect the former. */ | 153 | affect the former. */ |
| @@ -205,12 +208,19 @@ get_keymap (object) | |||
| 205 | 208 | ||
| 206 | /* Look up IDX in MAP. IDX may be any sort of event. | 209 | /* Look up IDX in MAP. IDX may be any sort of event. |
| 207 | Note that this does only one level of lookup; IDX must be a single | 210 | Note that this does only one level of lookup; IDX must be a single |
| 208 | event, not a sequence. */ | 211 | event, not a sequence. |
| 212 | |||
| 213 | If T_OK is non-zero, bindings for Qt are treated as default | ||
| 214 | bindings; any key left unmentioned by other tables and bindings is | ||
| 215 | given the binding of Qt. | ||
| 216 | |||
| 217 | If T_OK is zero, bindings for Qt are not treated specially. */ | ||
| 209 | 218 | ||
| 210 | Lisp_Object | 219 | Lisp_Object |
| 211 | access_keymap (map, idx) | 220 | access_keymap (map, idx, t_ok) |
| 212 | Lisp_Object map; | 221 | Lisp_Object map; |
| 213 | Lisp_Object idx; | 222 | Lisp_Object idx; |
| 223 | int t_ok; | ||
| 214 | { | 224 | { |
| 215 | /* If idx is a list (some sort of mouse click, perhaps?), | 225 | /* If idx is a list (some sort of mouse click, perhaps?), |
| 216 | the index we want to use is the car of the list, which | 226 | the index we want to use is the car of the list, which |
| @@ -219,7 +229,7 @@ access_keymap (map, idx) | |||
| 219 | 229 | ||
| 220 | if (XTYPE (idx) == Lisp_Int | 230 | if (XTYPE (idx) == Lisp_Int |
| 221 | && (XINT (idx) < 0 || XINT (idx) >= DENSE_TABLE_SIZE)) | 231 | && (XINT (idx) < 0 || XINT (idx) >= DENSE_TABLE_SIZE)) |
| 222 | error ("only ASCII characters may used as keymap indices"); | 232 | error ("only ASCII characters may be looked up in keymaps"); |
| 223 | 233 | ||
| 224 | /* If idx is a symbol, it might have modifiers, which need to | 234 | /* If idx is a symbol, it might have modifiers, which need to |
| 225 | be put in the canonical order. */ | 235 | be put in the canonical order. */ |
| @@ -228,6 +238,7 @@ access_keymap (map, idx) | |||
| 228 | 238 | ||
| 229 | { | 239 | { |
| 230 | Lisp_Object tail; | 240 | Lisp_Object tail; |
| 241 | Lisp_Object t_binding = Qnil; | ||
| 231 | 242 | ||
| 232 | for (tail = map; CONSP (tail); tail = XCONS (tail)->cdr) | 243 | for (tail = map; CONSP (tail); tail = XCONS (tail)->cdr) |
| 233 | { | 244 | { |
| @@ -238,6 +249,8 @@ access_keymap (map, idx) | |||
| 238 | case Lisp_Cons: | 249 | case Lisp_Cons: |
| 239 | if (EQ (XCONS (binding)->car, idx)) | 250 | if (EQ (XCONS (binding)->car, idx)) |
| 240 | return XCONS (binding)->cdr; | 251 | return XCONS (binding)->cdr; |
| 252 | if (t_ok && EQ (XCONS (binding)->car, Qt)) | ||
| 253 | t_binding = XCONS (binding)->cdr; | ||
| 241 | break; | 254 | break; |
| 242 | 255 | ||
| 243 | case Lisp_Vector: | 256 | case Lisp_Vector: |
| @@ -249,9 +262,9 @@ access_keymap (map, idx) | |||
| 249 | 262 | ||
| 250 | QUIT; | 263 | QUIT; |
| 251 | } | 264 | } |
| 252 | } | ||
| 253 | 265 | ||
| 254 | return Qnil; | 266 | return t_binding; |
| 267 | } | ||
| 255 | } | 268 | } |
| 256 | 269 | ||
| 257 | /* Given OBJECT which was found in a slot in a keymap, | 270 | /* Given OBJECT which was found in a slot in a keymap, |
| @@ -275,7 +288,7 @@ get_keyelt (object) | |||
| 275 | map = get_keymap_1 (Fcar_safe (object), 0); | 288 | map = get_keymap_1 (Fcar_safe (object), 0); |
| 276 | tem = Fkeymapp (map); | 289 | tem = Fkeymapp (map); |
| 277 | if (!NILP (tem)) | 290 | if (!NILP (tem)) |
| 278 | object = access_keymap (map, Fcdr (object)); | 291 | object = access_keymap (map, Fcdr (object), 0); |
| 279 | 292 | ||
| 280 | /* If the keymap contents looks like (STRING . DEFN), | 293 | /* If the keymap contents looks like (STRING . DEFN), |
| 281 | use DEFN. | 294 | use DEFN. |
| @@ -487,7 +500,7 @@ the front of KEYMAP.") | |||
| 487 | if (idx == length) | 500 | if (idx == length) |
| 488 | return store_in_keymap (keymap, c, def); | 501 | return store_in_keymap (keymap, c, def); |
| 489 | 502 | ||
| 490 | cmd = get_keyelt (access_keymap (keymap, c)); | 503 | cmd = get_keyelt (access_keymap (keymap, c, 0)); |
| 491 | 504 | ||
| 492 | if (NILP (cmd)) | 505 | if (NILP (cmd)) |
| 493 | { | 506 | { |
| @@ -556,7 +569,7 @@ it takes to reach a non-prefix command.") | |||
| 556 | idx++; | 569 | idx++; |
| 557 | } | 570 | } |
| 558 | 571 | ||
| 559 | cmd = get_keyelt (access_keymap (keymap, c)); | 572 | cmd = get_keyelt (access_keymap (keymap, c, 0)); |
| 560 | if (idx == length) | 573 | if (idx == length) |
| 561 | return cmd; | 574 | return cmd; |
| 562 | 575 | ||