Mercurial > hg > xemacs-beta
comparison src/keymap.c @ 398:74fd4e045ea6 r21-2-29
Import from CVS: tag r21-2-29
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:13:30 +0200 |
parents | 8626e4521993 |
children | a86b2b5e0111 |
comparison
equal
deleted
inserted
replaced
397:f4aeb21a5bad | 398:74fd4e045ea6 |
---|---|
139 compatibility. | 139 compatibility. |
140 | 140 |
141 Since keymaps are opaque, the only way to extract information from them | 141 Since keymaps are opaque, the only way to extract information from them |
142 is with the functions lookup-key, key-binding, local-key-binding, and | 142 is with the functions lookup-key, key-binding, local-key-binding, and |
143 global-key-binding, which work just as before, and the new function | 143 global-key-binding, which work just as before, and the new function |
144 map-keymap, which is roughly analagous to maphash. | 144 map-keymap, which is roughly analogous to maphash. |
145 | 145 |
146 Note that map-keymap perpetuates the illusion that the "bucky" submaps | 146 Note that map-keymap perpetuates the illusion that the "bucky" submaps |
147 don't exist: if you map over a keymap with bucky submaps, it will also | 147 don't exist: if you map over a keymap with bucky submaps, it will also |
148 map over those submaps. It does not, however, map over other random | 148 map over those submaps. It does not, however, map over other random |
149 submaps of the keymap, just the bucky ones. | 149 submaps of the keymap, just the bucky ones. |
154 distinction between ESC and "meta" even more. "M-x" is no more a two- | 154 distinction between ESC and "meta" even more. "M-x" is no more a two- |
155 key sequence than "C-x" is. | 155 key sequence than "C-x" is. |
156 | 156 |
157 */ | 157 */ |
158 | 158 |
159 typedef struct Lisp_Keymap | 159 struct Lisp_Keymap |
160 { | 160 { |
161 struct lcrecord_header header; | 161 struct lcrecord_header header; |
162 Lisp_Object parents; /* Keymaps to be searched after this one | 162 Lisp_Object parents; /* Keymaps to be searched after this one. |
163 * An ordered list */ | 163 An ordered list */ |
164 Lisp_Object prompt; /* Qnil or a string to print in the minibuffer | 164 Lisp_Object prompt; /* Qnil or a string to print in the minibuffer |
165 * when reading from this keymap */ | 165 when reading from this keymap */ |
166 | |
167 Lisp_Object table; /* The contents of this keymap */ | 166 Lisp_Object table; /* The contents of this keymap */ |
168 Lisp_Object inverse_table; /* The inverse mapping of the above */ | 167 Lisp_Object inverse_table; /* The inverse mapping of the above */ |
169 | |
170 Lisp_Object default_binding; /* Use this if no other binding is found | 168 Lisp_Object default_binding; /* Use this if no other binding is found |
171 * (this overrides parent maps and the | 169 (this overrides parent maps and the |
172 * normal global-map lookup). */ | 170 normal global-map lookup). */ |
173 | |
174 | |
175 Lisp_Object sub_maps_cache; /* Cache of directly inferior keymaps; | 171 Lisp_Object sub_maps_cache; /* Cache of directly inferior keymaps; |
176 This holds an alist, of the key and the | 172 This holds an alist, of the key and the |
177 maps, or the modifier bit and the map. | 173 maps, or the modifier bit and the map. |
178 If this is the symbol t, then the cache | 174 If this is the symbol t, then the cache |
179 needs to be recomputed. | 175 needs to be recomputed. */ |
180 */ | |
181 int fullness; /* How many entries there are in this table. | |
182 This should be the same as the fullness | |
183 of the `table', but hash.c is broken. */ | |
184 Lisp_Object name; /* Just for debugging convenience */ | 176 Lisp_Object name; /* Just for debugging convenience */ |
185 } Lisp_Keymap; | 177 }; |
186 | 178 |
187 #define MAKE_MODIFIER_HASH_KEY(modifier) make_int (modifier) | 179 #define MAKE_MODIFIER_HASH_KEY(modifier) make_int (modifier) |
188 #define MODIFIER_HASH_KEY_BITS(x) (INTP (x) ? XINT (x) : 0) | 180 #define MODIFIER_HASH_KEY_BITS(x) (INTP (x) ? XINT (x) : 0) |
189 | 181 |
190 | 182 |
191 | 183 |
192 /* Actually allocate storage for these variables */ | 184 /* Actually allocate storage for these variables */ |
193 | 185 |
194 static Lisp_Object Vcurrent_global_map; /* Always a keymap */ | 186 Lisp_Object Vcurrent_global_map; /* Always a keymap */ |
195 | 187 |
196 static Lisp_Object Vmouse_grabbed_buffer; | 188 static Lisp_Object Vmouse_grabbed_buffer; |
197 | 189 |
198 /* Alist of minor mode variables and keymaps. */ | 190 /* Alist of minor mode variables and keymaps. */ |
199 static Lisp_Object Qminor_mode_map_alist; | 191 static Lisp_Object Qminor_mode_map_alist; |
228 void (*elt_describer) (Lisp_Object, Lisp_Object), | 220 void (*elt_describer) (Lisp_Object, Lisp_Object), |
229 int partial, | 221 int partial, |
230 Lisp_Object shadow, | 222 Lisp_Object shadow, |
231 int mice_only_p, | 223 int mice_only_p, |
232 Lisp_Object buffer); | 224 Lisp_Object buffer); |
225 static Lisp_Object keymap_submaps (Lisp_Object keymap); | |
233 | 226 |
234 Lisp_Object Qcontrol, Qctrl, Qmeta, Qsuper, Qhyper, Qalt, Qshift; | 227 Lisp_Object Qcontrol, Qctrl, Qmeta, Qsuper, Qhyper, Qalt, Qshift; |
235 Lisp_Object Qbutton0, Qbutton1, Qbutton2, Qbutton3; | 228 Lisp_Object Qbutton0, Qbutton1, Qbutton2, Qbutton3; |
236 Lisp_Object Qbutton4, Qbutton5, Qbutton6, Qbutton7; | 229 Lisp_Object Qbutton4, Qbutton5, Qbutton6, Qbutton7; |
237 Lisp_Object Qbutton0up, Qbutton1up, Qbutton2up, Qbutton3up; | 230 Lisp_Object Qbutton0up, Qbutton1up, Qbutton2up, Qbutton3up; |
250 /************************************************************************/ | 243 /************************************************************************/ |
251 /* The keymap Lisp object */ | 244 /* The keymap Lisp object */ |
252 /************************************************************************/ | 245 /************************************************************************/ |
253 | 246 |
254 static Lisp_Object | 247 static Lisp_Object |
255 mark_keymap (Lisp_Object obj, void (*markobj) (Lisp_Object)) | 248 mark_keymap (Lisp_Object obj) |
256 { | 249 { |
257 Lisp_Keymap *keymap = XKEYMAP (obj); | 250 Lisp_Keymap *keymap = XKEYMAP (obj); |
258 markobj (keymap->parents); | 251 mark_object (keymap->parents); |
259 markobj (keymap->prompt); | 252 mark_object (keymap->prompt); |
260 markobj (keymap->inverse_table); | 253 mark_object (keymap->inverse_table); |
261 markobj (keymap->sub_maps_cache); | 254 mark_object (keymap->sub_maps_cache); |
262 markobj (keymap->default_binding); | 255 mark_object (keymap->default_binding); |
263 markobj (keymap->name); | 256 mark_object (keymap->name); |
264 return keymap->table; | 257 return keymap->table; |
265 } | 258 } |
266 | 259 |
267 static void | 260 static void |
268 print_keymap (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) | 261 print_keymap (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) |
269 { | 262 { |
270 /* This function can GC */ | 263 /* This function can GC */ |
271 Lisp_Keymap *keymap = XKEYMAP (obj); | 264 Lisp_Keymap *keymap = XKEYMAP (obj); |
272 char buf[200]; | 265 char buf[200]; |
273 int size = XINT (Fkeymap_fullness (obj)); | |
274 if (print_readably) | 266 if (print_readably) |
275 error ("printing unreadable object #<keymap 0x%x>", keymap->header.uid); | 267 error ("printing unreadable object #<keymap 0x%x>", keymap->header.uid); |
276 write_c_string ("#<keymap ", printcharfun); | 268 write_c_string ("#<keymap ", printcharfun); |
277 if (!NILP (keymap->name)) | 269 if (!NILP (keymap->name)) |
278 print_internal (keymap->name, printcharfun, 1); | 270 { |
279 /* #### Yuck! This is no way to form plural! --hniksic */ | 271 print_internal (keymap->name, printcharfun, 1); |
280 sprintf (buf, "%s%d entr%s 0x%x>", | 272 write_c_string (" ", printcharfun); |
281 ((NILP (keymap->name)) ? "" : " "), | 273 } |
282 size, | 274 sprintf (buf, "size %ld 0x%x>", |
283 ((size == 1) ? "y" : "ies"), | 275 (long) XINT (Fkeymap_fullness (obj)), keymap->header.uid); |
284 keymap->header.uid); | |
285 write_c_string (buf, printcharfun); | 276 write_c_string (buf, printcharfun); |
286 } | 277 } |
278 | |
279 static const struct lrecord_description keymap_description[] = { | |
280 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, parents) }, | |
281 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, prompt) }, | |
282 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, table) }, | |
283 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, inverse_table) }, | |
284 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, default_binding) }, | |
285 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, sub_maps_cache) }, | |
286 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, name) }, | |
287 { XD_END } | |
288 }; | |
287 | 289 |
288 /* No need for keymap_equal #### Why not? */ | 290 /* No need for keymap_equal #### Why not? */ |
289 DEFINE_LRECORD_IMPLEMENTATION ("keymap", keymap, | 291 DEFINE_LRECORD_IMPLEMENTATION ("keymap", keymap, |
290 mark_keymap, print_keymap, 0, 0, 0, | 292 mark_keymap, print_keymap, 0, 0, 0, |
293 keymap_description, | |
291 Lisp_Keymap); | 294 Lisp_Keymap); |
292 | 295 |
293 /************************************************************************/ | 296 /************************************************************************/ |
294 /* Traversing keymaps and their parents */ | 297 /* Traversing keymaps and their parents */ |
295 /************************************************************************/ | 298 /************************************************************************/ |
310 gcpro1.nvars = 0; | 313 gcpro1.nvars = 0; |
311 | 314 |
312 start_keymap = get_keymap (start_keymap, 1, 1); | 315 start_keymap = get_keymap (start_keymap, 1, 1); |
313 keymap = start_keymap; | 316 keymap = start_keymap; |
314 /* Hack special-case parents at top-level */ | 317 /* Hack special-case parents at top-level */ |
315 tail = ((!NILP (tail)) ? tail : XKEYMAP (keymap)->parents); | 318 tail = !NILP (tail) ? tail : XKEYMAP (keymap)->parents; |
316 | 319 |
317 for (;;) | 320 for (;;) |
318 { | 321 { |
319 Lisp_Object result; | 322 Lisp_Object result; |
320 | 323 |
321 QUIT; | 324 QUIT; |
322 result = ((mapper) (keymap, mapper_arg)); | 325 result = mapper (keymap, mapper_arg); |
323 if (!NILP (result)) | 326 if (!NILP (result)) |
324 { | 327 { |
325 while (CONSP (malloc_bites)) | 328 while (CONSP (malloc_bites)) |
326 { | 329 { |
327 struct Lisp_Cons *victim = XCONS (malloc_bites); | 330 Lisp_Cons *victim = XCONS (malloc_bites); |
328 malloc_bites = victim->cdr; | 331 malloc_bites = victim->cdr; |
329 free_cons (victim); | 332 free_cons (victim); |
330 } | 333 } |
331 UNGCPRO; | 334 UNGCPRO; |
332 return result; | 335 return result; |
339 return Qnil; /* Nothing found */ | 342 return Qnil; /* Nothing found */ |
340 } | 343 } |
341 stack_depth--; | 344 stack_depth--; |
342 if (CONSP (malloc_bites)) | 345 if (CONSP (malloc_bites)) |
343 { | 346 { |
344 struct Lisp_Cons *victim = XCONS (malloc_bites); | 347 Lisp_Cons *victim = XCONS (malloc_bites); |
345 tail = victim->car; | 348 tail = victim->car; |
346 malloc_bites = victim->cdr; | 349 malloc_bites = victim->cdr; |
347 free_cons (victim); | 350 free_cons (victim); |
348 } | 351 } |
349 else | 352 else |
431 if (modifiers & MOD_META) frob = Fcons (Qmeta, frob); | 434 if (modifiers & MOD_META) frob = Fcons (Qmeta, frob); |
432 return frob; | 435 return frob; |
433 } | 436 } |
434 | 437 |
435 static Lisp_Object | 438 static Lisp_Object |
436 make_key_description (CONST struct key_data *key, int prettify) | 439 make_key_description (const struct key_data *key, int prettify) |
437 { | 440 { |
438 Lisp_Object keysym = key->keysym; | 441 Lisp_Object keysym = key->keysym; |
439 unsigned int modifiers = key->modifiers; | 442 unsigned int modifiers = key->modifiers; |
440 | 443 |
441 if (prettify && CHARP (keysym)) | 444 if (prettify && CHARP (keysym)) |
459 /* Low-level keymap-store functions */ | 462 /* Low-level keymap-store functions */ |
460 /************************************************************************/ | 463 /************************************************************************/ |
461 | 464 |
462 static Lisp_Object | 465 static Lisp_Object |
463 raw_lookup_key (Lisp_Object keymap, | 466 raw_lookup_key (Lisp_Object keymap, |
464 CONST struct key_data *raw_keys, int raw_keys_count, | 467 const struct key_data *raw_keys, int raw_keys_count, |
465 int keys_so_far, int accept_default); | 468 int keys_so_far, int accept_default); |
466 | 469 |
467 /* Relies on caller to gc-protect args */ | 470 /* Relies on caller to gc-protect args */ |
468 static Lisp_Object | 471 static Lisp_Object |
469 keymap_lookup_directly (Lisp_Object keymap, | 472 keymap_lookup_directly (Lisp_Object keymap, |
574 /* else the list's tail has been modified, so we don't need to | 577 /* else the list's tail has been modified, so we don't need to |
575 touch the hash table again (the pointer in there is ok). | 578 touch the hash table again (the pointer in there is ok). |
576 */ | 579 */ |
577 } | 580 } |
578 | 581 |
582 /* Prevent luser from shooting herself in the foot using something like | |
583 (define-key ctl-x-4-map "p" global-map) */ | |
584 static void | |
585 check_keymap_definition_loop (Lisp_Object def, Lisp_Keymap *to_keymap) | |
586 { | |
587 def = get_keymap (def, 0, 0); | |
588 | |
589 if (KEYMAPP (def)) | |
590 { | |
591 Lisp_Object maps; | |
592 | |
593 if (XKEYMAP (def) == to_keymap) | |
594 signal_simple_error ("Cyclic keymap definition", def); | |
595 | |
596 for (maps = keymap_submaps (def); | |
597 CONSP (maps); | |
598 maps = XCDR (maps)) | |
599 check_keymap_definition_loop (XCDR (XCAR (maps)), to_keymap); | |
600 } | |
601 } | |
579 | 602 |
580 static void | 603 static void |
581 keymap_store_internal (Lisp_Object keysym, Lisp_Keymap *keymap, | 604 keymap_store_internal (Lisp_Object keysym, Lisp_Keymap *keymap, |
582 Lisp_Object value) | 605 Lisp_Object def) |
583 { | 606 { |
584 Lisp_Object prev_value = Fgethash (keysym, keymap->table, Qnil); | 607 Lisp_Object prev_def = Fgethash (keysym, keymap->table, Qnil); |
585 | 608 |
586 if (EQ (prev_value, value)) | 609 if (EQ (prev_def, def)) |
587 return; | 610 return; |
588 if (!NILP (prev_value)) | 611 |
612 check_keymap_definition_loop (def, keymap); | |
613 | |
614 if (!NILP (prev_def)) | |
589 keymap_delete_inverse_internal (keymap->inverse_table, | 615 keymap_delete_inverse_internal (keymap->inverse_table, |
590 keysym, prev_value); | 616 keysym, prev_def); |
591 if (NILP (value)) | 617 if (NILP (def)) |
592 { | 618 { |
593 keymap->fullness--; | |
594 if (keymap->fullness < 0) abort (); | |
595 Fremhash (keysym, keymap->table); | 619 Fremhash (keysym, keymap->table); |
596 } | 620 } |
597 else | 621 else |
598 { | 622 { |
599 if (NILP (prev_value)) | 623 Fputhash (keysym, def, keymap->table); |
600 keymap->fullness++; | |
601 Fputhash (keysym, value, keymap->table); | |
602 keymap_store_inverse_internal (keymap->inverse_table, | 624 keymap_store_inverse_internal (keymap->inverse_table, |
603 keysym, value); | 625 keysym, def); |
604 } | 626 } |
605 keymap_tick++; | 627 keymap_tick++; |
606 } | 628 } |
607 | 629 |
608 | 630 |
621 } | 643 } |
622 | 644 |
623 | 645 |
624 /* Relies on caller to gc-protect keymap, keysym, value */ | 646 /* Relies on caller to gc-protect keymap, keysym, value */ |
625 static void | 647 static void |
626 keymap_store (Lisp_Object keymap, CONST struct key_data *key, | 648 keymap_store (Lisp_Object keymap, const struct key_data *key, |
627 Lisp_Object value) | 649 Lisp_Object value) |
628 { | 650 { |
629 Lisp_Object keysym = key->keysym; | 651 Lisp_Object keysym = key->keysym; |
630 unsigned int modifiers = key->modifiers; | 652 unsigned int modifiers = key->modifiers; |
631 Lisp_Keymap *k; | 653 Lisp_Keymap *k = XKEYMAP (keymap); |
632 | 654 |
633 if ((modifiers & ~(MOD_CONTROL | MOD_META | MOD_SUPER | MOD_HYPER | 655 assert ((modifiers & ~(MOD_CONTROL | MOD_META | MOD_SUPER | MOD_HYPER |
634 | MOD_ALT | MOD_SHIFT)) != 0) | 656 | MOD_ALT | MOD_SHIFT)) == 0); |
635 abort (); | |
636 | |
637 k = XKEYMAP (keymap); | |
638 | 657 |
639 /* If the keysym is a one-character symbol, use the char code instead. */ | 658 /* If the keysym is a one-character symbol, use the char code instead. */ |
640 if (SYMBOLP (keysym) && string_char_length (XSYMBOL (keysym)->name) == 1) | 659 if (SYMBOLP (keysym) && string_char_length (XSYMBOL (keysym)->name) == 1) |
641 { | 660 keysym = make_char (string_char (XSYMBOL (keysym)->name, 0)); |
642 Lisp_Object run_the_gcc_developers_over_with_a_steamroller = | |
643 make_char (string_char (XSYMBOL (keysym)->name, 0)); | |
644 keysym = run_the_gcc_developers_over_with_a_steamroller; | |
645 } | |
646 | 661 |
647 if (modifiers & MOD_META) /* Utterly hateful ESC lossage */ | 662 if (modifiers & MOD_META) /* Utterly hateful ESC lossage */ |
648 { | 663 { |
649 Lisp_Object submap = Fgethash (MAKE_MODIFIER_HASH_KEY (MOD_META), | 664 Lisp_Object submap = Fgethash (MAKE_MODIFIER_HASH_KEY (MOD_META), |
650 k->table, Qnil); | 665 k->table, Qnil); |
740 | 755 |
741 static Lisp_Object | 756 static Lisp_Object |
742 make_keymap (size_t size) | 757 make_keymap (size_t size) |
743 { | 758 { |
744 Lisp_Object result; | 759 Lisp_Object result; |
745 Lisp_Keymap *keymap = alloc_lcrecord_type (Lisp_Keymap, lrecord_keymap); | 760 Lisp_Keymap *keymap = alloc_lcrecord_type (Lisp_Keymap, &lrecord_keymap); |
746 | 761 |
747 XSETKEYMAP (result, keymap); | 762 XSETKEYMAP (result, keymap); |
748 | 763 |
749 keymap->parents = Qnil; | 764 keymap->parents = Qnil; |
750 keymap->prompt = Qnil; | 765 keymap->prompt = Qnil; |
751 keymap->table = Qnil; | 766 keymap->table = Qnil; |
752 keymap->inverse_table = Qnil; | 767 keymap->inverse_table = Qnil; |
753 keymap->default_binding = Qnil; | 768 keymap->default_binding = Qnil; |
754 keymap->sub_maps_cache = Qnil; /* No possible submaps */ | 769 keymap->sub_maps_cache = Qnil; /* No possible submaps */ |
755 keymap->fullness = 0; | |
756 keymap->name = Qnil; | 770 keymap->name = Qnil; |
757 | 771 |
758 if (size != 0) /* hack for copy-keymap */ | 772 if (size != 0) /* hack for copy-keymap */ |
759 { | 773 { |
760 keymap->table = | 774 keymap->table = |
1042 { | 1056 { |
1043 Lisp_Object idx = Fcdr (object); | 1057 Lisp_Object idx = Fcdr (object); |
1044 struct key_data indirection; | 1058 struct key_data indirection; |
1045 if (CHARP (idx)) | 1059 if (CHARP (idx)) |
1046 { | 1060 { |
1047 struct Lisp_Event event; | 1061 Lisp_Event event; |
1048 event.event_type = empty_event; | 1062 event.event_type = empty_event; |
1049 character_to_event (XCHAR (idx), &event, | 1063 character_to_event (XCHAR (idx), &event, |
1050 XCONSOLE (Vselected_console), 0, 0); | 1064 XCONSOLE (Vselected_console), 0, 0); |
1051 indirection = event.event.key; | 1065 indirection = event.event.key; |
1052 } | 1066 } |
1084 return object; | 1098 return object; |
1085 } | 1099 } |
1086 } | 1100 } |
1087 | 1101 |
1088 static Lisp_Object | 1102 static Lisp_Object |
1089 keymap_lookup_1 (Lisp_Object keymap, CONST struct key_data *key, | 1103 keymap_lookup_1 (Lisp_Object keymap, const struct key_data *key, |
1090 int accept_default) | 1104 int accept_default) |
1091 { | 1105 { |
1092 /* This function can GC */ | 1106 /* This function can GC */ |
1093 return get_keyelt (keymap_lookup_directly (keymap, | 1107 return get_keyelt (keymap_lookup_directly (keymap, |
1094 key->keysym, key->modifiers), | 1108 key->keysym, key->modifiers), |
1128 Lisp_Keymap *new_keymap = XKEYMAP (nkm); | 1142 Lisp_Keymap *new_keymap = XKEYMAP (nkm); |
1129 struct copy_keymap_inverse_closure copy_keymap_inverse_closure; | 1143 struct copy_keymap_inverse_closure copy_keymap_inverse_closure; |
1130 copy_keymap_inverse_closure.inverse_table = keymap->inverse_table; | 1144 copy_keymap_inverse_closure.inverse_table = keymap->inverse_table; |
1131 | 1145 |
1132 new_keymap->parents = Fcopy_sequence (keymap->parents); | 1146 new_keymap->parents = Fcopy_sequence (keymap->parents); |
1133 new_keymap->fullness = keymap->fullness; | |
1134 new_keymap->sub_maps_cache = Qnil; /* No submaps */ | 1147 new_keymap->sub_maps_cache = Qnil; /* No submaps */ |
1135 new_keymap->table = Fcopy_hash_table (keymap->table); | 1148 new_keymap->table = Fcopy_hash_table (keymap->table); |
1136 new_keymap->inverse_table = Fcopy_hash_table (keymap->inverse_table); | 1149 new_keymap->inverse_table = Fcopy_hash_table (keymap->inverse_table); |
1150 new_keymap->default_binding = keymap->default_binding; | |
1137 /* After copying the inverse map, we need to copy the conses which | 1151 /* After copying the inverse map, we need to copy the conses which |
1138 are its values, lest they be shared by the copy, and mangled. | 1152 are its values, lest they be shared by the copy, and mangled. |
1139 */ | 1153 */ |
1140 elisp_maphash (copy_keymap_inverse_mapper, keymap->inverse_table, | 1154 elisp_maphash (copy_keymap_inverse_mapper, keymap->inverse_table, |
1141 ©_keymap_inverse_closure); | 1155 ©_keymap_inverse_closure); |
1205 int fullness; | 1219 int fullness; |
1206 Lisp_Object sub_maps; | 1220 Lisp_Object sub_maps; |
1207 struct gcpro gcpro1, gcpro2; | 1221 struct gcpro gcpro1, gcpro2; |
1208 | 1222 |
1209 keymap = get_keymap (keymap, 1, 1); | 1223 keymap = get_keymap (keymap, 1, 1); |
1210 fullness = XKEYMAP (keymap)->fullness; | 1224 fullness = XINT (Fhash_table_count (XKEYMAP (keymap)->table)); |
1211 sub_maps = keymap_submaps (keymap); | |
1212 GCPRO2 (keymap, sub_maps); | 1225 GCPRO2 (keymap, sub_maps); |
1213 for (; !NILP (sub_maps); sub_maps = XCDR (sub_maps)) | 1226 for (sub_maps = keymap_submaps (keymap); |
1227 !NILP (sub_maps); | |
1228 sub_maps = XCDR (sub_maps)) | |
1214 { | 1229 { |
1215 if (MODIFIER_HASH_KEY_BITS (XCAR (XCAR (sub_maps))) != 0) | 1230 if (MODIFIER_HASH_KEY_BITS (XCAR (XCAR (sub_maps))) != 0) |
1216 { | 1231 { |
1217 Lisp_Object sub_map = XCDR (XCAR (sub_maps)); | 1232 Lisp_Object bucky_map = XCDR (XCAR (sub_maps)); |
1218 fullness--; /* don't count bucky maps */ | 1233 fullness--; /* don't count bucky maps themselves. */ |
1219 fullness += keymap_fullness (sub_map); | 1234 fullness += keymap_fullness (bucky_map); |
1220 } | 1235 } |
1221 } | 1236 } |
1222 UNGCPRO; | 1237 UNGCPRO; |
1223 return fullness; | 1238 return fullness; |
1224 } | 1239 } |
1271 ("The `shift' modifier may not be applied to ASCII keysyms", | 1286 ("The `shift' modifier may not be applied to ASCII keysyms", |
1272 spec); | 1287 spec); |
1273 } | 1288 } |
1274 else | 1289 else |
1275 { | 1290 { |
1276 signal_simple_error ("Unknown keysym specifier", | 1291 signal_simple_error ("Unknown keysym specifier", *keysym); |
1277 *keysym); | |
1278 } | 1292 } |
1279 | 1293 |
1280 if (SYMBOLP (*keysym)) | 1294 if (SYMBOLP (*keysym)) |
1281 { | 1295 { |
1282 char *name = (char *) | 1296 char *name = (char *) string_data (XSYMBOL (*keysym)->name); |
1283 string_data (XSYMBOL (*keysym)->name); | |
1284 | 1297 |
1285 /* FSFmacs uses symbols with the printed representation of keysyms in | 1298 /* FSFmacs uses symbols with the printed representation of keysyms in |
1286 their names, like 'M-x, and we use the syntax '(meta x). So, to avoid | 1299 their names, like 'M-x, and we use the syntax '(meta x). So, to avoid |
1287 confusion, notice the M-x syntax and signal an error - because | 1300 confusion, notice the M-x syntax and signal an error - because |
1288 otherwise it would be interpreted as a regular keysym, and would even | 1301 otherwise it would be interpreted as a regular keysym, and would even |
1341 *keysym = QKreturn; | 1354 *keysym = QKreturn; |
1342 else if (EQ (*keysym, QESC)) | 1355 else if (EQ (*keysym, QESC)) |
1343 *keysym = QKescape; | 1356 *keysym = QKescape; |
1344 else if (EQ (*keysym, QDEL)) | 1357 else if (EQ (*keysym, QDEL)) |
1345 *keysym = QKdelete; | 1358 *keysym = QKdelete; |
1359 else if (EQ (*keysym, QSPC)) | |
1360 *keysym = QKspace; | |
1346 else if (EQ (*keysym, QBS)) | 1361 else if (EQ (*keysym, QBS)) |
1347 *keysym = QKbackspace; | 1362 *keysym = QKbackspace; |
1348 /* Emacs compatibility */ | 1363 /* Emacs compatibility */ |
1349 else if (EQ(*keysym, Qdown_mouse_1)) | 1364 else if (EQ(*keysym, Qdown_mouse_1)) |
1350 *keysym = Qbutton1; | 1365 *keysym = Qbutton1; |
1380 static void | 1395 static void |
1381 define_key_parser (Lisp_Object spec, struct key_data *returned_value) | 1396 define_key_parser (Lisp_Object spec, struct key_data *returned_value) |
1382 { | 1397 { |
1383 if (CHAR_OR_CHAR_INTP (spec)) | 1398 if (CHAR_OR_CHAR_INTP (spec)) |
1384 { | 1399 { |
1385 struct Lisp_Event event; | 1400 Lisp_Event event; |
1386 event.event_type = empty_event; | 1401 event.event_type = empty_event; |
1387 character_to_event (XCHAR_OR_CHAR_INT (spec), &event, | 1402 character_to_event (XCHAR_OR_CHAR_INT (spec), &event, |
1388 XCONSOLE (Vselected_console), 0, 0); | 1403 XCONSOLE (Vselected_console), 0, 0); |
1389 returned_value->keysym = event.event.key.keysym; | 1404 returned_value->keysym = event.event.key.keysym; |
1390 returned_value->modifiers = event.event.key.modifiers; | 1405 returned_value->modifiers = event.event.key.modifiers; |
1528 XEVENT (event)->event.key.modifiers = raw_key.modifiers; | 1543 XEVENT (event)->event.key.modifiers = raw_key.modifiers; |
1529 } | 1544 } |
1530 | 1545 |
1531 | 1546 |
1532 int | 1547 int |
1533 event_matches_key_specifier_p (struct Lisp_Event *event, | 1548 event_matches_key_specifier_p (Lisp_Event *event, Lisp_Object key_specifier) |
1534 Lisp_Object key_specifier) | |
1535 { | 1549 { |
1536 Lisp_Object event2; | 1550 Lisp_Object event2; |
1537 int retval; | 1551 int retval; |
1538 struct gcpro gcpro1; | 1552 struct gcpro gcpro1; |
1539 | 1553 |
1580 UNGCPRO; | 1594 UNGCPRO; |
1581 return retval; | 1595 return retval; |
1582 } | 1596 } |
1583 | 1597 |
1584 static int | 1598 static int |
1585 meta_prefix_char_p (CONST struct key_data *key) | 1599 meta_prefix_char_p (const struct key_data *key) |
1586 { | 1600 { |
1587 struct Lisp_Event event; | 1601 Lisp_Event event; |
1588 | 1602 |
1589 event.event_type = key_press_event; | 1603 event.event_type = key_press_event; |
1590 event.channel = Vselected_console; | 1604 event.channel = Vselected_console; |
1591 event.event.key.keysym = key->keysym; | 1605 event.event.key.keysym = key->keysym; |
1592 event.event.key.modifiers = key->modifiers; | 1606 event.event.key.modifiers = key->modifiers; |
1888 (define-key my-map "\M-a" 'my-command) | 1902 (define-key my-map "\M-a" 'my-command) |
1889 and then perhaps | 1903 and then perhaps |
1890 (defvar my-escape-map (lookup-key my-map "\e")) | 1904 (defvar my-escape-map (lookup-key my-map "\e")) |
1891 if the luser really wants the map in a variable. | 1905 if the luser really wants the map in a variable. |
1892 */ | 1906 */ |
1893 Lisp_Object mmap; | 1907 Lisp_Object meta_map; |
1894 struct gcpro ngcpro1; | 1908 struct gcpro ngcpro1; |
1895 | 1909 |
1896 NGCPRO1 (c); | 1910 NGCPRO1 (c); |
1897 mmap = Fgethash (MAKE_MODIFIER_HASH_KEY (MOD_META), | 1911 meta_map = Fgethash (MAKE_MODIFIER_HASH_KEY (MOD_META), |
1898 XKEYMAP (keymap)->table, Qnil); | 1912 XKEYMAP (keymap)->table, Qnil); |
1899 if (!NILP (mmap) | 1913 if (!NILP (meta_map) |
1900 && keymap_fullness (mmap) != 0) | 1914 && keymap_fullness (meta_map) != 0) |
1901 { | 1915 signal_simple_error_2 |
1902 Lisp_Object desc | 1916 ("Map contains meta-bindings, can't bind", |
1903 = Fsingle_key_description (Vmeta_prefix_char); | 1917 Fsingle_key_description (Vmeta_prefix_char), keymap); |
1904 signal_simple_error_2 | |
1905 ("Map contains meta-bindings, can't bind", desc, keymap); | |
1906 } | |
1907 NUNGCPRO; | 1918 NUNGCPRO; |
1908 } | 1919 } |
1909 else | 1920 else |
1910 { | 1921 { |
1911 metized = 1; | 1922 metized = 1; |
1922 raw_key2.modifiers = 0; | 1933 raw_key2.modifiers = 0; |
1923 } | 1934 } |
1924 | 1935 |
1925 if (metized) | 1936 if (metized) |
1926 { | 1937 { |
1927 raw_key1.modifiers |= MOD_META; | 1938 raw_key1.modifiers |= MOD_META; |
1928 raw_key2.modifiers |= MOD_META; | 1939 raw_key2.modifiers |= MOD_META; |
1929 metized = 0; | 1940 metized = 0; |
1930 } | 1941 } |
1931 | 1942 |
1932 /* This crap is to make sure that someone doesn't bind something like | 1943 /* This crap is to make sure that someone doesn't bind something like |
1979 to make where-is-internal really fly. */ | 1990 to make where-is-internal really fly. */ |
1980 | 1991 |
1981 struct raw_lookup_key_mapper_closure | 1992 struct raw_lookup_key_mapper_closure |
1982 { | 1993 { |
1983 int remaining; | 1994 int remaining; |
1984 CONST struct key_data *raw_keys; | 1995 const struct key_data *raw_keys; |
1985 int raw_keys_count; | 1996 int raw_keys_count; |
1986 int keys_so_far; | 1997 int keys_so_far; |
1987 int accept_default; | 1998 int accept_default; |
1988 }; | 1999 }; |
1989 | 2000 |
1990 static Lisp_Object raw_lookup_key_mapper (Lisp_Object k, void *); | 2001 static Lisp_Object raw_lookup_key_mapper (Lisp_Object k, void *); |
1991 | 2002 |
1992 /* Caller should gc-protect args (keymaps may autoload) */ | 2003 /* Caller should gc-protect args (keymaps may autoload) */ |
1993 static Lisp_Object | 2004 static Lisp_Object |
1994 raw_lookup_key (Lisp_Object keymap, | 2005 raw_lookup_key (Lisp_Object keymap, |
1995 CONST struct key_data *raw_keys, int raw_keys_count, | 2006 const struct key_data *raw_keys, int raw_keys_count, |
1996 int keys_so_far, int accept_default) | 2007 int keys_so_far, int accept_default) |
1997 { | 2008 { |
1998 /* This function can GC */ | 2009 /* This function can GC */ |
1999 struct raw_lookup_key_mapper_closure c; | 2010 struct raw_lookup_key_mapper_closure c; |
2000 c.remaining = raw_keys_count - 1; | 2011 c.remaining = raw_keys_count - 1; |
2013 struct raw_lookup_key_mapper_closure *c = | 2024 struct raw_lookup_key_mapper_closure *c = |
2014 (struct raw_lookup_key_mapper_closure *) arg; | 2025 (struct raw_lookup_key_mapper_closure *) arg; |
2015 int accept_default = c->accept_default; | 2026 int accept_default = c->accept_default; |
2016 int remaining = c->remaining; | 2027 int remaining = c->remaining; |
2017 int keys_so_far = c->keys_so_far; | 2028 int keys_so_far = c->keys_so_far; |
2018 CONST struct key_data *raw_keys = c->raw_keys; | 2029 const struct key_data *raw_keys = c->raw_keys; |
2019 Lisp_Object cmd; | 2030 Lisp_Object cmd; |
2020 | 2031 |
2021 if (! meta_prefix_char_p (&(raw_keys[0]))) | 2032 if (! meta_prefix_char_p (&(raw_keys[0]))) |
2022 { | 2033 { |
2023 /* Normal case: every case except the meta-hack (see below). */ | 2034 /* Normal case: every case except the meta-hack (see below). */ |
2104 int i; | 2115 int i; |
2105 | 2116 |
2106 if (nkeys == 0) | 2117 if (nkeys == 0) |
2107 return Qnil; | 2118 return Qnil; |
2108 | 2119 |
2109 if (nkeys < (countof (kkk))) | 2120 if (nkeys < countof (kkk)) |
2110 raw_keys = kkk; | 2121 raw_keys = kkk; |
2111 else | 2122 else |
2112 raw_keys = alloca_array (struct key_data, nkeys); | 2123 raw_keys = alloca_array (struct key_data, nkeys); |
2113 | 2124 |
2114 for (i = 0; i < nkeys; i++) | 2125 for (i = 0; i < nkeys; i++) |
2134 | 2145 |
2135 CHECK_LIVE_EVENT (event_head); | 2146 CHECK_LIVE_EVENT (event_head); |
2136 | 2147 |
2137 nkeys = event_chain_count (event_head); | 2148 nkeys = event_chain_count (event_head); |
2138 | 2149 |
2139 if (nkeys < (countof (kkk))) | 2150 if (nkeys < countof (kkk)) |
2140 raw_keys = kkk; | 2151 raw_keys = kkk; |
2141 else | 2152 else |
2142 raw_keys = alloca_array (struct key_data, nkeys); | 2153 raw_keys = alloca_array (struct key_data, nkeys); |
2143 | 2154 |
2144 nkeys = 0; | 2155 nkeys = 0; |
2360 buffer); | 2371 buffer); |
2361 | 2372 |
2362 get_relevant_extent_keymaps | 2373 get_relevant_extent_keymaps |
2363 (Fevent_modeline_position (terminal), | 2374 (Fevent_modeline_position (terminal), |
2364 XBUFFER (buffer)->generated_modeline_string, | 2375 XBUFFER (buffer)->generated_modeline_string, |
2365 /* #### third arg should maybe be a glyph. */ | 2376 Fevent_glyph_extent (terminal), &closure); |
2366 Qnil, &closure); | |
2367 | 2377 |
2368 if (!UNBOUNDP (map) && !NILP (map)) | 2378 if (!UNBOUNDP (map) && !NILP (map)) |
2369 relevant_map_push (get_keymap (map, 1, 1), &closure); | 2379 relevant_map_push (get_keymap (map, 1, 1), &closure); |
2370 } | 2380 } |
2371 else | 2381 else |
2729 outside of this file doesn't need to know about. | 2739 outside of this file doesn't need to know about. |
2730 */ | 2740 */ |
2731 | 2741 |
2732 struct map_keymap_unsorted_closure | 2742 struct map_keymap_unsorted_closure |
2733 { | 2743 { |
2734 void (*fn) (CONST struct key_data *, Lisp_Object binding, void *arg); | 2744 void (*fn) (const struct key_data *, Lisp_Object binding, void *arg); |
2735 void *arg; | 2745 void *arg; |
2736 unsigned int modifiers; | 2746 unsigned int modifiers; |
2737 }; | 2747 }; |
2738 | 2748 |
2739 /* used by map_keymap() */ | 2749 /* used by map_keymap() */ |
2868 | 2878 |
2869 /* used by map_keymap() */ | 2879 /* used by map_keymap() */ |
2870 static void | 2880 static void |
2871 map_keymap_sorted (Lisp_Object keymap_table, | 2881 map_keymap_sorted (Lisp_Object keymap_table, |
2872 unsigned int modifiers, | 2882 unsigned int modifiers, |
2873 void (*function) (CONST struct key_data *key, | 2883 void (*function) (const struct key_data *key, |
2874 Lisp_Object binding, | 2884 Lisp_Object binding, |
2875 void *map_keymap_sorted_closure), | 2885 void *map_keymap_sorted_closure), |
2876 void *map_keymap_sorted_closure) | 2886 void *map_keymap_sorted_closure) |
2877 { | 2887 { |
2878 /* This function can GC */ | 2888 /* This function can GC */ |
2913 } | 2923 } |
2914 | 2924 |
2915 | 2925 |
2916 /* used by Fmap_keymap() */ | 2926 /* used by Fmap_keymap() */ |
2917 static void | 2927 static void |
2918 map_keymap_mapper (CONST struct key_data *key, | 2928 map_keymap_mapper (const struct key_data *key, |
2919 Lisp_Object binding, | 2929 Lisp_Object binding, |
2920 void *function) | 2930 void *function) |
2921 { | 2931 { |
2922 /* This function can GC */ | 2932 /* This function can GC */ |
2923 Lisp_Object fn; | 2933 Lisp_Object fn; |
2926 } | 2936 } |
2927 | 2937 |
2928 | 2938 |
2929 static void | 2939 static void |
2930 map_keymap (Lisp_Object keymap_table, int sort_first, | 2940 map_keymap (Lisp_Object keymap_table, int sort_first, |
2931 void (*function) (CONST struct key_data *key, | 2941 void (*function) (const struct key_data *key, |
2932 Lisp_Object binding, | 2942 Lisp_Object binding, |
2933 void *fn_arg), | 2943 void *fn_arg), |
2934 void *fn_arg) | 2944 void *fn_arg) |
2935 { | 2945 { |
2936 /* This function can GC */ | 2946 /* This function can GC */ |
3082 Lisp_Object accessible_keymaps = Qnil; | 3092 Lisp_Object accessible_keymaps = Qnil; |
3083 struct accessible_keymaps_closure c; | 3093 struct accessible_keymaps_closure c; |
3084 c.tail = Qnil; | 3094 c.tail = Qnil; |
3085 GCPRO4 (accessible_keymaps, c.tail, prefix, keymap); | 3095 GCPRO4 (accessible_keymaps, c.tail, prefix, keymap); |
3086 | 3096 |
3097 keymap = get_keymap (keymap, 1, 1); | |
3098 | |
3087 retry: | 3099 retry: |
3088 keymap = get_keymap (keymap, 1, 1); | |
3089 if (NILP (prefix)) | 3100 if (NILP (prefix)) |
3090 prefix = make_vector (0, Qnil); | 3101 { |
3091 else if (!VECTORP (prefix) || STRINGP (prefix)) | 3102 prefix = make_vector (0, Qnil); |
3092 { | 3103 } |
3093 prefix = wrong_type_argument (Qarrayp, prefix); | 3104 else if (VECTORP (prefix) || STRINGP (prefix)) |
3094 goto retry; | |
3095 } | |
3096 else | |
3097 { | 3105 { |
3098 int len = XINT (Flength (prefix)); | 3106 int len = XINT (Flength (prefix)); |
3099 Lisp_Object def = Flookup_key (keymap, prefix, Qnil); | 3107 Lisp_Object def; |
3100 Lisp_Object p; | 3108 Lisp_Object p; |
3101 int iii; | 3109 int iii; |
3102 struct gcpro ngcpro1; | 3110 struct gcpro ngcpro1; |
3103 | 3111 |
3112 if (len == 0) | |
3113 { | |
3114 prefix = Qnil; | |
3115 goto retry; | |
3116 } | |
3117 | |
3118 def = Flookup_key (keymap, prefix, Qnil); | |
3104 def = get_keymap (def, 0, 1); | 3119 def = get_keymap (def, 0, 1); |
3105 if (!KEYMAPP (def)) | 3120 if (!KEYMAPP (def)) |
3106 goto RETURN; | 3121 goto RETURN; |
3107 | 3122 |
3108 keymap = def; | 3123 keymap = def; |
3115 XVECTOR_DATA (p)[iii] = make_key_description (&key, 1); | 3130 XVECTOR_DATA (p)[iii] = make_key_description (&key, 1); |
3116 } | 3131 } |
3117 NUNGCPRO; | 3132 NUNGCPRO; |
3118 prefix = p; | 3133 prefix = p; |
3119 } | 3134 } |
3135 else | |
3136 { | |
3137 prefix = wrong_type_argument (Qarrayp, prefix); | |
3138 goto retry; | |
3139 } | |
3120 | 3140 |
3121 accessible_keymaps = list1 (Fcons (prefix, keymap)); | 3141 accessible_keymaps = list1 (Fcons (prefix, keymap)); |
3122 | 3142 |
3123 /* For each map in the list maps, | 3143 /* For each map in the list maps, look at any other maps it points |
3124 look at any other maps it points to | 3144 to and stick them at the end if they are not already in the list */ |
3125 and stick them at the end if they are not already in the list */ | |
3126 | 3145 |
3127 for (c.tail = accessible_keymaps; | 3146 for (c.tail = accessible_keymaps; |
3128 !NILP (c.tail); | 3147 !NILP (c.tail); |
3129 c.tail = XCDR (c.tail)) | 3148 c.tail = XCDR (c.tail)) |
3130 { | 3149 { |
3165 int i; | 3184 int i; |
3166 | 3185 |
3167 for (i = 0; i < size; i++) | 3186 for (i = 0; i < size; i++) |
3168 { | 3187 { |
3169 Lisp_Object s2 = Fsingle_key_description | 3188 Lisp_Object s2 = Fsingle_key_description |
3170 (((STRINGP (keys)) | 3189 (STRINGP (keys) |
3171 ? make_char (string_char (XSTRING (keys), i)) | 3190 ? make_char (string_char (XSTRING (keys), i)) |
3172 : XVECTOR_DATA (keys)[i])); | 3191 : XVECTOR_DATA (keys)[i]); |
3173 | 3192 |
3174 if (i == 0) | 3193 if (i == 0) |
3175 string = s2; | 3194 string = s2; |
3176 else | 3195 else |
3177 { | 3196 { |
3198 if (EVENTP (key) || CHAR_OR_CHAR_INTP (key)) | 3217 if (EVENTP (key) || CHAR_OR_CHAR_INTP (key)) |
3199 { | 3218 { |
3200 char buf [255]; | 3219 char buf [255]; |
3201 if (!EVENTP (key)) | 3220 if (!EVENTP (key)) |
3202 { | 3221 { |
3203 struct Lisp_Event event; | 3222 Lisp_Event event; |
3204 event.event_type = empty_event; | 3223 event.event_type = empty_event; |
3205 CHECK_CHAR_COERCE_INT (key); | 3224 CHECK_CHAR_COERCE_INT (key); |
3206 character_to_event (XCHAR (key), &event, | 3225 character_to_event (XCHAR (key), &event, |
3207 XCONSOLE (Vselected_console), 0, 1); | 3226 XCONSOLE (Vselected_console), 0, 1); |
3208 format_event_object (buf, &event, 1); | 3227 format_event_object (buf, &event, 1); |
3447 | 3466 |
3448 static void | 3467 static void |
3449 format_raw_keys (struct key_data *keys, int count, char *buf) | 3468 format_raw_keys (struct key_data *keys, int count, char *buf) |
3450 { | 3469 { |
3451 int i; | 3470 int i; |
3452 struct Lisp_Event event; | 3471 Lisp_Event event; |
3453 event.event_type = key_press_event; | 3472 event.event_type = key_press_event; |
3454 event.channel = Vselected_console; | 3473 event.channel = Vselected_console; |
3455 for (i = 0; i < count; i++) | 3474 for (i = 0; i < count; i++) |
3456 { | 3475 { |
3457 event.event.key.keysym = keys[i].keysym; | 3476 event.event.key.keysym = keys[i].keysym; |
3504 where_is_recursive_mapper (Lisp_Object map, void *arg) | 3523 where_is_recursive_mapper (Lisp_Object map, void *arg) |
3505 { | 3524 { |
3506 /* This function can GC */ | 3525 /* This function can GC */ |
3507 struct where_is_closure *c = (struct where_is_closure *) arg; | 3526 struct where_is_closure *c = (struct where_is_closure *) arg; |
3508 Lisp_Object definition = c->definition; | 3527 Lisp_Object definition = c->definition; |
3509 CONST int firstonly = c->firstonly; | 3528 const int firstonly = c->firstonly; |
3510 CONST unsigned int keys_count = c->keys_count; | 3529 const unsigned int keys_count = c->keys_count; |
3511 CONST unsigned int modifiers_so_far = c->modifiers_so_far; | 3530 const unsigned int modifiers_so_far = c->modifiers_so_far; |
3512 char *target_buffer = c->target_buffer; | 3531 char *target_buffer = c->target_buffer; |
3513 Lisp_Object keys = Fgethash (definition, | 3532 Lisp_Object keys = Fgethash (definition, |
3514 XKEYMAP (map)->inverse_table, | 3533 XKEYMAP (map)->inverse_table, |
3515 Qnil); | 3534 Qnil); |
3516 Lisp_Object submaps; | 3535 Lisp_Object submaps; |
3524 raw_lookup_key() means undefined. */ | 3543 raw_lookup_key() means undefined. */ |
3525 struct key_data *so_far = c->keys_so_far; | 3544 struct key_data *so_far = c->keys_so_far; |
3526 | 3545 |
3527 for (;;) /* loop over all keys that match */ | 3546 for (;;) /* loop over all keys that match */ |
3528 { | 3547 { |
3529 Lisp_Object k = ((CONSP (keys)) ? XCAR (keys) : keys); | 3548 Lisp_Object k = CONSP (keys) ? XCAR (keys) : keys; |
3530 int i; | 3549 int i; |
3531 | 3550 |
3532 so_far [keys_count].keysym = k; | 3551 so_far [keys_count].keysym = k; |
3533 so_far [keys_count].modifiers = modifiers_so_far; | 3552 so_far [keys_count].modifiers = modifiers_so_far; |
3534 | 3553 |
3622 { | 3641 { |
3623 int size = lower_keys_count + 50; | 3642 int size = lower_keys_count + 50; |
3624 if (! c->keys_so_far_malloced) | 3643 if (! c->keys_so_far_malloced) |
3625 { | 3644 { |
3626 struct key_data *new = xnew_array (struct key_data, size); | 3645 struct key_data *new = xnew_array (struct key_data, size); |
3627 memcpy ((void *)new, (CONST void *)c->keys_so_far, | 3646 memcpy ((void *)new, (const void *)c->keys_so_far, |
3628 c->keys_so_far_total_size * sizeof (struct key_data)); | 3647 c->keys_so_far_total_size * sizeof (struct key_data)); |
3629 } | 3648 } |
3630 else | 3649 else |
3631 XREALLOC_ARRAY (c->keys_so_far, struct key_data, size); | 3650 XREALLOC_ARRAY (c->keys_so_far, struct key_data, size); |
3632 | 3651 |
3875 int mice_only_p; /* whether we are to display only button bindings */ | 3894 int mice_only_p; /* whether we are to display only button bindings */ |
3876 }; | 3895 }; |
3877 | 3896 |
3878 struct describe_map_shadow_closure | 3897 struct describe_map_shadow_closure |
3879 { | 3898 { |
3880 CONST struct key_data *raw_key; | 3899 const struct key_data *raw_key; |
3881 Lisp_Object self; | 3900 Lisp_Object self; |
3882 }; | 3901 }; |
3883 | 3902 |
3884 static Lisp_Object | 3903 static Lisp_Object |
3885 describe_map_mapper_shadow_search (Lisp_Object map, void *arg) | 3904 describe_map_mapper_shadow_search (Lisp_Object map, void *arg) |
3904 return keymap_lookup_directly (km, k->keysym, k->modifiers); | 3923 return keymap_lookup_directly (km, k->keysym, k->modifiers); |
3905 } | 3924 } |
3906 | 3925 |
3907 | 3926 |
3908 static void | 3927 static void |
3909 describe_map_mapper (CONST struct key_data *key, | 3928 describe_map_mapper (const struct key_data *key, |
3910 Lisp_Object binding, | 3929 Lisp_Object binding, |
3911 void *describe_map_closure) | 3930 void *describe_map_closure) |
3912 { | 3931 { |
3913 /* This function can GC */ | 3932 /* This function can GC */ |
3914 struct describe_map_closure *closure = | 3933 struct describe_map_closure *closure = |
4264 defsymbol (&QLFD, "LFD"); | 4283 defsymbol (&QLFD, "LFD"); |
4265 defsymbol (&QTAB, "TAB"); | 4284 defsymbol (&QTAB, "TAB"); |
4266 defsymbol (&QRET, "RET"); | 4285 defsymbol (&QRET, "RET"); |
4267 defsymbol (&QESC, "ESC"); | 4286 defsymbol (&QESC, "ESC"); |
4268 defsymbol (&QDEL, "DEL"); | 4287 defsymbol (&QDEL, "DEL"); |
4288 defsymbol (&QSPC, "SPC"); | |
4269 defsymbol (&QBS, "BS"); | 4289 defsymbol (&QBS, "BS"); |
4270 } | 4290 } |
4271 | 4291 |
4272 void | 4292 void |
4273 vars_of_keymap (void) | 4293 vars_of_keymap (void) |
4317 */ ); | 4337 */ ); |
4318 keymap_tick = 0; | 4338 keymap_tick = 0; |
4319 | 4339 |
4320 staticpro (&Vcurrent_global_map); | 4340 staticpro (&Vcurrent_global_map); |
4321 | 4341 |
4322 Vsingle_space_string = make_pure_string ((CONST Bufbyte *) " ", 1, Qnil, 1); | 4342 Vsingle_space_string = make_string ((const Bufbyte *) " ", 1); |
4323 staticpro (&Vsingle_space_string); | 4343 staticpro (&Vsingle_space_string); |
4324 } | 4344 } |
4325 | 4345 |
4326 void | 4346 void |
4327 complex_vars_of_keymap (void) | 4347 complex_vars_of_keymap (void) |