Mercurial > emacs
comparison src/keymap.c @ 32988:c3435dc00ed7
* lisp.h (KEYMAPP): New macro.
(get_keymap): Remove.
(get_keymap_1): Rename get_keymap.
* keyboard.h (get_keymap_1, Fkeymapp): Remove prototype.
* xterm.c (note_mode_line_highlight): Use KEYMAPP.
* xmenu.c (single_submenu): Use KEYMAPP.
(Fx_popup_menu): Fetch keymaps rather than checking Fkeymapp.
Use KEYMAPP rather than Fkeymapp.
* w32term.c (note_mode_line_highlight): Use KEYMAPP.
* w32menu.c (True, False): Remove (use TRUE and FALSE instead).
(Fx_popup_menu): Fetch keymaps rather than checking Fkeymapp.
Use KEYMAPP rather than Fkeymapp.
(single_submenu): Use KEYMAPP.
(w32_menu_show, w32_dialog_show): Use TRUE.
* minibuf.c (Fread_from_minibuffer): Update call to get_keymap.
* keymap.c (KEYMAPP): Remove (moved to lisp.h).
(Fkeymapp): Use KEYMAPP.
(get_keymap): Rename from get_keymap_1. Remove old def.
Return t when autoload=0 and error=0 and the keymap needs autoloading.
(Fcopy_keymap): Check (eq (car x) 'keymap) rather than using Fkeymapp.
(Fminor_mode_key_binding): Don't raise an error if the binding
is not a keymap.
(Fuse_global_map, Fuse_local_map): Allow autoloading.
(Faccessible_keymaps): Fetch keymaps rather than checking Fkeymapp.
* keyboard.c (read_char): get_keymap_1 -> get_keymap.
Allow Vspecial_event_map to be autoloaded.
(menu_bar_items): Fetch the keymap rather than using keymapp.
(menu_bar_one_keymap): No need to follow func-indirect any more.
(parse_menu_item): get_keymap_1 -> get_keymap.
(tool_bar_items): Fetch the keymap rather than using keymapp.
(read_key_sequence): Use KEYMAPP.
* intervals.c (get_local_map): Use get_keymap rather than following
function-indirections explicitly.
* doc.c (Fsubstitute_command_keys): get_keymap_1 -> get_keymap.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 27 Oct 2000 22:20:19 +0000 |
parents | 673e3ef1f7f6 |
children | 8d46095169e8 |
comparison
equal
deleted
inserted
replaced
32987:a2813d16337d | 32988:c3435dc00ed7 |
---|---|
31 #include "blockinput.h" | 31 #include "blockinput.h" |
32 #include "puresize.h" | 32 #include "puresize.h" |
33 #include "intervals.h" | 33 #include "intervals.h" |
34 | 34 |
35 #define min(a, b) ((a) < (b) ? (a) : (b)) | 35 #define min(a, b) ((a) < (b) ? (a) : (b)) |
36 #define KEYMAPP(m) (!NILP (Fkeymapp (m))) | |
37 | 36 |
38 /* The number of elements in keymap vectors. */ | 37 /* The number of elements in keymap vectors. */ |
39 #define DENSE_TABLE_SIZE (0200) | 38 #define DENSE_TABLE_SIZE (0200) |
40 | 39 |
41 /* Actually allocate storage for these variables */ | 40 /* Actually allocate storage for these variables */ |
188 a vector of densely packed bindings for small character codes\n\ | 187 a vector of densely packed bindings for small character codes\n\ |
189 is also allowed as an element.") | 188 is also allowed as an element.") |
190 (object) | 189 (object) |
191 Lisp_Object object; | 190 Lisp_Object object; |
192 { | 191 { |
193 /* FIXME: Maybe this should return t for autoloaded keymaps? -sm */ | 192 return (KEYMAPP (object) ? Qt : Qnil); |
194 return (NILP (get_keymap_1 (object, 0, 0)) ? Qnil : Qt); | |
195 } | 193 } |
196 | 194 |
197 /* Check that OBJECT is a keymap (after dereferencing through any | 195 /* Check that OBJECT is a keymap (after dereferencing through any |
198 symbols). If it is, return it. | 196 symbols). If it is, return it. |
199 | 197 |
200 If AUTOLOAD is non-zero and OBJECT is a symbol whose function value | 198 If AUTOLOAD is non-zero and OBJECT is a symbol whose function value |
201 is an autoload form, do the autoload and try again. | 199 is an autoload form, do the autoload and try again. |
202 If AUTOLOAD is nonzero, callers must assume GC is possible. | 200 If AUTOLOAD is nonzero, callers must assume GC is possible. |
201 | |
202 If the map needs to be autoloaded, but AUTOLOAD is zero (and ERROR | |
203 is zero as well), return Qt. | |
203 | 204 |
204 ERROR controls how we respond if OBJECT isn't a keymap. | 205 ERROR controls how we respond if OBJECT isn't a keymap. |
205 If ERROR is non-zero, signal an error; otherwise, just return Qnil. | 206 If ERROR is non-zero, signal an error; otherwise, just return Qnil. |
206 | 207 |
207 Note that most of the time, we don't want to pursue autoloads. | 208 Note that most of the time, we don't want to pursue autoloads. |
212 | 213 |
213 This function can GC when AUTOLOAD is non-zero, because it calls | 214 This function can GC when AUTOLOAD is non-zero, because it calls |
214 do_autoload which can GC. */ | 215 do_autoload which can GC. */ |
215 | 216 |
216 Lisp_Object | 217 Lisp_Object |
217 get_keymap_1 (object, error, autoload) | 218 get_keymap (object, error, autoload) |
218 Lisp_Object object; | 219 Lisp_Object object; |
219 int error, autoload; | 220 int error, autoload; |
220 { | 221 { |
221 Lisp_Object tem; | 222 Lisp_Object tem; |
222 | 223 |
223 autoload_retry: | 224 autoload_retry: |
224 if (NILP (object)) | 225 if (NILP (object)) |
225 goto end; | 226 goto end; |
226 if (CONSP (object) && EQ (XCAR (object), Qkeymap)) | 227 if (CONSP (object) && EQ (XCAR (object), Qkeymap)) |
227 return object; | 228 return object; |
228 else | 229 |
229 { | 230 tem = indirect_function (object); |
230 tem = indirect_function (object); | 231 if (CONSP (tem)) |
231 if (CONSP (tem) && EQ (XCAR (tem), Qkeymap)) | 232 { |
233 if (EQ (XCAR (tem), Qkeymap)) | |
232 return tem; | 234 return tem; |
233 } | 235 |
234 | 236 /* Should we do an autoload? Autoload forms for keymaps have |
235 /* Should we do an autoload? Autoload forms for keymaps have | 237 Qkeymap as their fifth element. */ |
236 Qkeymap as their fifth element. */ | 238 if ((autoload || !error) && EQ (XCAR (tem), Qautoload)) |
237 if (autoload | 239 { |
238 && SYMBOLP (object) | 240 Lisp_Object tail; |
239 && CONSP (tem) | 241 |
240 && EQ (XCAR (tem), Qautoload)) | 242 tail = Fnth (make_number (4), tem); |
241 { | 243 if (EQ (tail, Qkeymap)) |
242 Lisp_Object tail; | 244 { |
243 | 245 if (autoload) |
244 tail = Fnth (make_number (4), tem); | 246 { |
245 if (EQ (tail, Qkeymap)) | 247 struct gcpro gcpro1, gcpro2; |
246 { | 248 |
247 struct gcpro gcpro1, gcpro2; | 249 GCPRO2 (tem, object); |
248 | 250 do_autoload (tem, object); |
249 GCPRO2 (tem, object); | 251 UNGCPRO; |
250 do_autoload (tem, object); | 252 |
251 UNGCPRO; | 253 goto autoload_retry; |
252 | 254 } |
253 goto autoload_retry; | 255 else |
256 return Qt; | |
257 } | |
254 } | 258 } |
255 } | 259 } |
256 | 260 |
257 end: | 261 end: |
258 if (error) | 262 if (error) |
259 wrong_type_argument (Qkeymapp, object); | 263 wrong_type_argument (Qkeymapp, object); |
260 return Qnil; | 264 return Qnil; |
261 } | 265 } |
262 | |
263 | |
264 /* Follow any symbol chaining, and return the keymap denoted by OBJECT. | |
265 If OBJECT doesn't denote a keymap at all, signal an error. */ | |
266 Lisp_Object | |
267 get_keymap (object) | |
268 Lisp_Object object; | |
269 { | |
270 return get_keymap_1 (object, 1, 0); | |
271 } | |
272 | 266 |
273 /* Return the parent map of the keymap MAP, or nil if it has none. | 267 /* Return the parent map of the keymap MAP, or nil if it has none. |
274 We assume that MAP is a valid keymap. */ | 268 We assume that MAP is a valid keymap. */ |
275 | 269 |
276 DEFUN ("keymap-parent", Fkeymap_parent, Skeymap_parent, 1, 1, 0, | 270 DEFUN ("keymap-parent", Fkeymap_parent, Skeymap_parent, 1, 1, 0, |
278 (keymap) | 272 (keymap) |
279 Lisp_Object keymap; | 273 Lisp_Object keymap; |
280 { | 274 { |
281 Lisp_Object list; | 275 Lisp_Object list; |
282 | 276 |
283 keymap = get_keymap_1 (keymap, 1, 1); | 277 keymap = get_keymap (keymap, 1, 1); |
284 | 278 |
285 /* Skip past the initial element `keymap'. */ | 279 /* Skip past the initial element `keymap'. */ |
286 list = XCDR (keymap); | 280 list = XCDR (keymap); |
287 for (; CONSP (list); list = XCDR (list)) | 281 for (; CONSP (list); list = XCDR (list)) |
288 { | 282 { |
289 /* See if there is another `keymap'. */ | 283 /* See if there is another `keymap'. */ |
290 if (KEYMAPP (list)) | 284 if (KEYMAPP (list)) |
291 return list; | 285 return list; |
292 } | 286 } |
293 | 287 |
294 return get_keymap_1(list, 0, 1); | 288 return get_keymap (list, 0, 1); |
295 } | 289 } |
296 | 290 |
297 | 291 |
298 /* Check whether MAP is one of MAPS parents. */ | 292 /* Check whether MAP is one of MAPS parents. */ |
299 int | 293 int |
325 the very beginning of where-is and can thus be changed here without any | 319 the very beginning of where-is and can thus be changed here without any |
326 adverse effect. | 320 adverse effect. |
327 This is a very minor correctness (rather than safety) issue. */ | 321 This is a very minor correctness (rather than safety) issue. */ |
328 where_is_cache_keymaps = Qt; | 322 where_is_cache_keymaps = Qt; |
329 | 323 |
330 keymap = get_keymap_1 (keymap, 1, 1); | 324 keymap = get_keymap (keymap, 1, 1); |
331 GCPRO1 (keymap); | 325 GCPRO1 (keymap); |
332 | 326 |
333 if (!NILP (parent)) | 327 if (!NILP (parent)) |
334 { | 328 { |
335 parent = get_keymap_1 (parent, 1, 1); | 329 parent = get_keymap (parent, 1, 1); |
336 | 330 |
337 /* Check for cycles. */ | 331 /* Check for cycles. */ |
338 if (keymap_memberp (keymap, parent)) | 332 if (keymap_memberp (keymap, parent)) |
339 error ("Cyclic keymap inheritance"); | 333 error ("Cyclic keymap inheritance"); |
340 } | 334 } |
402 Lisp_Object map_parent, parent_entry; | 396 Lisp_Object map_parent, parent_entry; |
403 | 397 |
404 /* SUBMAP is a cons that we found as a key binding. | 398 /* SUBMAP is a cons that we found as a key binding. |
405 Discard the other things found in a menu key binding. */ | 399 Discard the other things found in a menu key binding. */ |
406 | 400 |
407 submap = get_keymap_1 (get_keyelt (submap, 0), 0, 0); | 401 submap = get_keymap (get_keyelt (submap, 0), 0, 0); |
408 | 402 |
409 /* If it isn't a keymap now, there's no work to do. */ | 403 /* If it isn't a keymap now, there's no work to do. */ |
410 if (NILP (submap)) | 404 if (!CONSP (submap)) |
411 return; | 405 return; |
412 | 406 |
413 map_parent = Fkeymap_parent (map); | 407 map_parent = Fkeymap_parent (map); |
414 if (! NILP (map_parent)) | 408 if (!NILP (map_parent)) |
415 parent_entry = | 409 parent_entry = |
416 get_keymap_1 (access_keymap (map_parent, event, 0, 0, 0), 0, 0); | 410 get_keymap (access_keymap (map_parent, event, 0, 0, 0), 0, 0); |
417 else | 411 else |
418 parent_entry = Qnil; | 412 parent_entry = Qnil; |
419 | 413 |
420 /* If MAP's parent has something other than a keymap, | 414 /* If MAP's parent has something other than a keymap, |
421 our own submap shadows it completely. */ | 415 our own submap shadows it completely. */ |
422 if (NILP (parent_entry)) | 416 if (!CONSP (parent_entry)) |
423 return; | 417 return; |
424 | 418 |
425 if (! EQ (parent_entry, submap)) | 419 if (! EQ (parent_entry, submap)) |
426 { | 420 { |
427 Lisp_Object submap_parent; | 421 Lisp_Object submap_parent; |
487 if (INTEGERP (idx) && XUINT (idx) & meta_modifier) | 481 if (INTEGERP (idx) && XUINT (idx) & meta_modifier) |
488 { | 482 { |
489 /* See if there is a meta-map. If there's none, there is | 483 /* See if there is a meta-map. If there's none, there is |
490 no binding for IDX, unless a default binding exists in MAP. */ | 484 no binding for IDX, unless a default binding exists in MAP. */ |
491 Lisp_Object meta_map = | 485 Lisp_Object meta_map = |
492 get_keymap_1 (access_keymap (map, meta_prefix_char, | 486 get_keymap (access_keymap (map, meta_prefix_char, |
493 t_ok, noinherit, autoload), | 487 t_ok, noinherit, autoload), |
494 0, autoload); | 488 0, autoload); |
495 if (!NILP (meta_map)) | 489 if (CONSP (meta_map)) |
496 { | 490 { |
497 map = meta_map; | 491 map = meta_map; |
498 idx = make_number (XUINT (idx) & ~meta_modifier); | 492 idx = make_number (XUINT (idx) & ~meta_modifier); |
499 } | 493 } |
500 else if (t_ok) | 494 else if (t_ok) |
510 Lisp_Object t_binding; | 504 Lisp_Object t_binding; |
511 | 505 |
512 t_binding = Qnil; | 506 t_binding = Qnil; |
513 for (tail = XCDR (map); | 507 for (tail = XCDR (map); |
514 (CONSP (tail) | 508 (CONSP (tail) |
515 || (tail = get_keymap_1 (tail, 0, autoload), | 509 || (tail = get_keymap (tail, 0, autoload), CONSP (tail))); |
516 CONSP (tail))); | |
517 tail = XCDR (tail)) | 510 tail = XCDR (tail)) |
518 { | 511 { |
519 Lisp_Object binding; | 512 Lisp_Object binding; |
520 | 513 |
521 binding = XCAR (tail); | 514 binding = XCAR (tail); |
664 | 657 |
665 /* If the contents are (KEYMAP . ELEMENT), go indirect. */ | 658 /* If the contents are (KEYMAP . ELEMENT), go indirect. */ |
666 else | 659 else |
667 { | 660 { |
668 Lisp_Object map; | 661 Lisp_Object map; |
669 map = get_keymap_1 (Fcar_safe (object), 0, autoload); | 662 map = get_keymap (Fcar_safe (object), 0, autoload); |
670 return (NILP (map) ? object /* Invalid keymap */ | 663 return (!CONSP (map) ? object /* Invalid keymap */ |
671 : access_keymap (map, Fcdr (object), 0, 0, autoload)); | 664 : access_keymap (map, Fcdr (object), 0, 0, autoload)); |
672 } | 665 } |
673 } | 666 } |
674 } | 667 } |
675 | 668 |
778 | 771 |
779 void | 772 void |
780 copy_keymap_1 (chartable, idx, elt) | 773 copy_keymap_1 (chartable, idx, elt) |
781 Lisp_Object chartable, idx, elt; | 774 Lisp_Object chartable, idx, elt; |
782 { | 775 { |
783 if (!SYMBOLP (elt) && ! NILP (Fkeymapp (elt))) | 776 if (CONSP (elt) && EQ (XCAR (elt), Qkeymap)) |
784 Faset (chartable, idx, Fcopy_keymap (elt)); | 777 Faset (chartable, idx, Fcopy_keymap (elt)); |
785 } | 778 } |
786 | 779 |
787 DEFUN ("copy-keymap", Fcopy_keymap, Scopy_keymap, 1, 1, 0, | 780 DEFUN ("copy-keymap", Fcopy_keymap, Scopy_keymap, 1, 1, 0, |
788 "Return a copy of the keymap KEYMAP.\n\ | 781 "Return a copy of the keymap KEYMAP.\n\ |
794 (keymap) | 787 (keymap) |
795 Lisp_Object keymap; | 788 Lisp_Object keymap; |
796 { | 789 { |
797 register Lisp_Object copy, tail; | 790 register Lisp_Object copy, tail; |
798 | 791 |
799 copy = Fcopy_alist (get_keymap (keymap)); | 792 copy = Fcopy_alist (get_keymap (keymap, 1, 0)); |
800 | 793 |
801 for (tail = copy; CONSP (tail); tail = XCDR (tail)) | 794 for (tail = copy; CONSP (tail); tail = XCDR (tail)) |
802 { | 795 { |
803 Lisp_Object elt; | 796 Lisp_Object elt; |
804 | 797 |
818 | 811 |
819 elt = Fcopy_sequence (elt); | 812 elt = Fcopy_sequence (elt); |
820 XCAR (tail) = elt; | 813 XCAR (tail) = elt; |
821 | 814 |
822 for (i = 0; i < ASIZE (elt); i++) | 815 for (i = 0; i < ASIZE (elt); i++) |
823 if (!SYMBOLP (AREF (elt, i)) | 816 if (CONSP (AREF (elt, i)) && EQ (XCAR (AREF (elt, i)), Qkeymap)) |
824 && ! NILP (Fkeymapp (AREF (elt, i)))) | |
825 ASET (elt, i, Fcopy_keymap (AREF (elt, i))); | 817 ASET (elt, i, Fcopy_keymap (AREF (elt, i))); |
826 } | 818 } |
827 else if (CONSP (elt) && CONSP (XCDR (elt))) | 819 else if (CONSP (elt) && CONSP (XCDR (elt))) |
828 { | 820 { |
829 Lisp_Object tem; | 821 Lisp_Object tem; |
851 copy that. */ | 843 copy that. */ |
852 XCDR (elt) | 844 XCDR (elt) |
853 = Fcons (XCAR (tem), XCDR (tem)); | 845 = Fcons (XCAR (tem), XCDR (tem)); |
854 elt = XCDR (elt); | 846 elt = XCDR (elt); |
855 tem = XCAR (elt); | 847 tem = XCAR (elt); |
856 if (!(SYMBOLP (tem) || NILP (Fkeymapp (tem)))) | 848 if (CONSP (tem) && EQ (XCAR (tem), Qkeymap)) |
857 XCAR (elt) = Fcopy_keymap (tem); | 849 XCAR (elt) = Fcopy_keymap (tem); |
858 tem = XCDR (elt); | 850 tem = XCDR (elt); |
859 if (CONSP (tem) && CONSP (XCAR (tem))) | 851 if (CONSP (tem) && CONSP (XCAR (tem))) |
860 /* Delete cache for key equivalences. */ | 852 /* Delete cache for key equivalences. */ |
861 XCDR (elt) = XCDR (tem); | 853 XCDR (elt) = XCDR (tem); |
888 && (NILP (XCAR (XCAR (tem))) | 880 && (NILP (XCAR (XCAR (tem))) |
889 || VECTORP (XCAR (XCAR (tem))))) | 881 || VECTORP (XCAR (XCAR (tem))))) |
890 XCDR (elt) = XCDR (tem); | 882 XCDR (elt) = XCDR (tem); |
891 } | 883 } |
892 if (CONSP (elt) | 884 if (CONSP (elt) |
893 && ! SYMBOLP (XCDR (elt)) | 885 && CONSP (XCDR (elt)) |
894 && ! NILP (Fkeymapp (XCDR (elt)))) | 886 && EQ (XCAR (XCDR (elt)), Qkeymap)) |
895 XCDR (elt) = Fcopy_keymap (XCDR (elt)); | 887 XCDR (elt) = Fcopy_keymap (XCDR (elt)); |
896 } | 888 } |
897 | 889 |
898 } | 890 } |
899 } | 891 } |
936 int metized = 0; | 928 int metized = 0; |
937 int meta_bit; | 929 int meta_bit; |
938 int length; | 930 int length; |
939 struct gcpro gcpro1, gcpro2, gcpro3; | 931 struct gcpro gcpro1, gcpro2, gcpro3; |
940 | 932 |
941 keymap = get_keymap_1 (keymap, 1, 1); | 933 keymap = get_keymap (keymap, 1, 1); |
942 | 934 |
943 if (!VECTORP (key) && !STRINGP (key)) | 935 if (!VECTORP (key) && !STRINGP (key)) |
944 key = wrong_type_argument (Qarrayp, key); | 936 key = wrong_type_argument (Qarrayp, key); |
945 | 937 |
946 length = XFASTINT (Flength (key)); | 938 length = XFASTINT (Flength (key)); |
991 | 983 |
992 /* If this key is undefined, make it a prefix. */ | 984 /* If this key is undefined, make it a prefix. */ |
993 if (NILP (cmd)) | 985 if (NILP (cmd)) |
994 cmd = define_as_prefix (keymap, c); | 986 cmd = define_as_prefix (keymap, c); |
995 | 987 |
996 keymap = get_keymap_1 (cmd, 0, 1); | 988 keymap = get_keymap (cmd, 0, 1); |
997 if (NILP (keymap)) | 989 if (!CONSP (keymap)) |
998 /* We must use Fkey_description rather than just passing key to | 990 /* We must use Fkey_description rather than just passing key to |
999 error; key might be a vector, not a string. */ | 991 error; key might be a vector, not a string. */ |
1000 error ("Key sequence %s uses invalid prefix characters", | 992 error ("Key sequence %s uses invalid prefix characters", |
1001 XSTRING (Fkey_description (key))->data); | 993 XSTRING (Fkey_description (key))->data); |
1002 } | 994 } |
1030 register Lisp_Object c; | 1022 register Lisp_Object c; |
1031 int length; | 1023 int length; |
1032 int t_ok = ! NILP (accept_default); | 1024 int t_ok = ! NILP (accept_default); |
1033 struct gcpro gcpro1; | 1025 struct gcpro gcpro1; |
1034 | 1026 |
1035 keymap = get_keymap_1 (keymap, 1, 1); | 1027 keymap = get_keymap (keymap, 1, 1); |
1036 | 1028 |
1037 if (!VECTORP (key) && !STRINGP (key)) | 1029 if (!VECTORP (key) && !STRINGP (key)) |
1038 key = wrong_type_argument (Qarrayp, key); | 1030 key = wrong_type_argument (Qarrayp, key); |
1039 | 1031 |
1040 length = XFASTINT (Flength (key)); | 1032 length = XFASTINT (Flength (key)); |
1057 | 1049 |
1058 cmd = access_keymap (keymap, c, t_ok, 0, 1); | 1050 cmd = access_keymap (keymap, c, t_ok, 0, 1); |
1059 if (idx == length) | 1051 if (idx == length) |
1060 RETURN_UNGCPRO (cmd); | 1052 RETURN_UNGCPRO (cmd); |
1061 | 1053 |
1062 keymap = get_keymap_1 (cmd, 0, 1); | 1054 keymap = get_keymap (cmd, 0, 1); |
1063 if (NILP (keymap)) | 1055 if (!CONSP (keymap)) |
1064 RETURN_UNGCPRO (make_number (idx)); | 1056 RETURN_UNGCPRO (make_number (idx)); |
1065 | 1057 |
1066 QUIT; | 1058 QUIT; |
1067 } | 1059 } |
1068 } | 1060 } |
1360 | 1352 |
1361 binding = Qnil; | 1353 binding = Qnil; |
1362 GCPRO2 (key, binding); | 1354 GCPRO2 (key, binding); |
1363 | 1355 |
1364 for (i = j = 0; i < nmaps; i++) | 1356 for (i = j = 0; i < nmaps; i++) |
1365 if (! NILP (maps[i]) | 1357 if (!NILP (maps[i]) |
1366 && ! NILP (binding = Flookup_key (maps[i], key, accept_default)) | 1358 && !NILP (binding = Flookup_key (maps[i], key, accept_default)) |
1367 && !INTEGERP (binding)) | 1359 && !INTEGERP (binding)) |
1368 { | 1360 { |
1369 if (! NILP (get_keymap (binding))) | 1361 if (KEYMAPP (binding)) |
1370 maps[j++] = Fcons (modes[i], binding); | 1362 maps[j++] = Fcons (modes[i], binding); |
1371 else if (j == 0) | 1363 else if (j == 0) |
1372 RETURN_UNGCPRO (Fcons (Fcons (modes[i], binding), Qnil)); | 1364 RETURN_UNGCPRO (Fcons (Fcons (modes[i], binding), Qnil)); |
1373 } | 1365 } |
1374 | 1366 |
1400 DEFUN ("use-global-map", Fuse_global_map, Suse_global_map, 1, 1, 0, | 1392 DEFUN ("use-global-map", Fuse_global_map, Suse_global_map, 1, 1, 0, |
1401 "Select KEYMAP as the global keymap.") | 1393 "Select KEYMAP as the global keymap.") |
1402 (keymap) | 1394 (keymap) |
1403 Lisp_Object keymap; | 1395 Lisp_Object keymap; |
1404 { | 1396 { |
1405 keymap = get_keymap (keymap); | 1397 keymap = get_keymap (keymap, 1, 1); |
1406 current_global_map = keymap; | 1398 current_global_map = keymap; |
1407 | 1399 |
1408 return Qnil; | 1400 return Qnil; |
1409 } | 1401 } |
1410 | 1402 |
1413 If KEYMAP is nil, that means no local keymap.") | 1405 If KEYMAP is nil, that means no local keymap.") |
1414 (keymap) | 1406 (keymap) |
1415 Lisp_Object keymap; | 1407 Lisp_Object keymap; |
1416 { | 1408 { |
1417 if (!NILP (keymap)) | 1409 if (!NILP (keymap)) |
1418 keymap = get_keymap (keymap); | 1410 keymap = get_keymap (keymap, 1, 1); |
1419 | 1411 |
1420 current_buffer->keymap = keymap; | 1412 current_buffer->keymap = keymap; |
1421 | 1413 |
1422 return Qnil; | 1414 return Qnil; |
1423 } | 1415 } |
1478 Lisp_Object tem; | 1470 Lisp_Object tem; |
1479 tem = Flookup_key (keymap, prefix, Qt); | 1471 tem = Flookup_key (keymap, prefix, Qt); |
1480 /* Flookup_key may give us nil, or a number, | 1472 /* Flookup_key may give us nil, or a number, |
1481 if the prefix is not defined in this particular map. | 1473 if the prefix is not defined in this particular map. |
1482 It might even give us a list that isn't a keymap. */ | 1474 It might even give us a list that isn't a keymap. */ |
1483 tem = get_keymap_1 (tem, 0, 0); | 1475 tem = get_keymap (tem, 0, 0); |
1484 if (!NILP (tem)) | 1476 if (CONSP (tem)) |
1485 { | 1477 { |
1486 /* Convert PREFIX to a vector now, so that later on | 1478 /* Convert PREFIX to a vector now, so that later on |
1487 we don't have to deal with the possibility of a string. */ | 1479 we don't have to deal with the possibility of a string. */ |
1488 if (STRINGP (prefix)) | 1480 if (STRINGP (prefix)) |
1489 { | 1481 { |
1507 else | 1499 else |
1508 return Qnil; | 1500 return Qnil; |
1509 } | 1501 } |
1510 else | 1502 else |
1511 maps = Fcons (Fcons (Fmake_vector (make_number (0), Qnil), | 1503 maps = Fcons (Fcons (Fmake_vector (make_number (0), Qnil), |
1512 get_keymap (keymap)), | 1504 get_keymap (keymap, 1, 0)), |
1513 Qnil); | 1505 Qnil); |
1514 | 1506 |
1515 /* For each map in the list maps, | 1507 /* For each map in the list maps, |
1516 look at any other maps it points to, | 1508 look at any other maps it points to, |
1517 and stick them at the end if they are not already in the list. | 1509 and stick them at the end if they are not already in the list. |
1560 register Lisp_Object tem; | 1552 register Lisp_Object tem; |
1561 register Lisp_Object cmd; | 1553 register Lisp_Object cmd; |
1562 | 1554 |
1563 cmd = get_keyelt (AREF (elt, i), 0); | 1555 cmd = get_keyelt (AREF (elt, i), 0); |
1564 if (NILP (cmd)) continue; | 1556 if (NILP (cmd)) continue; |
1565 tem = Fkeymapp (cmd); | 1557 tem = get_keymap (cmd, 0, 0); |
1566 if (!NILP (tem)) | 1558 if (CONSP (tem)) |
1567 { | 1559 { |
1568 cmd = get_keymap (cmd); | 1560 cmd = tem; |
1569 /* Ignore keymaps that are already added to maps. */ | 1561 /* Ignore keymaps that are already added to maps. */ |
1570 tem = Frassq (cmd, maps); | 1562 tem = Frassq (cmd, maps); |
1571 if (NILP (tem)) | 1563 if (NILP (tem)) |
1572 { | 1564 { |
1573 /* If the last key in thisseq is meta-prefix-char, | 1565 /* If the last key in thisseq is meta-prefix-char, |
1601 { | 1593 { |
1602 register Lisp_Object cmd, tem; | 1594 register Lisp_Object cmd, tem; |
1603 | 1595 |
1604 cmd = get_keyelt (XCDR (elt), 0); | 1596 cmd = get_keyelt (XCDR (elt), 0); |
1605 /* Ignore definitions that aren't keymaps themselves. */ | 1597 /* Ignore definitions that aren't keymaps themselves. */ |
1606 tem = Fkeymapp (cmd); | 1598 tem = get_keymap (cmd, 0, 0); |
1607 if (!NILP (tem)) | 1599 if (CONSP (tem)) |
1608 { | 1600 { |
1609 /* Ignore keymaps that have been seen already. */ | 1601 /* Ignore keymaps that have been seen already. */ |
1610 cmd = get_keymap (cmd); | 1602 cmd = tem; |
1611 tem = Frassq (cmd, maps); | 1603 tem = Frassq (cmd, maps); |
1612 if (NILP (tem)) | 1604 if (NILP (tem)) |
1613 { | 1605 { |
1614 /* Let elt be the event defined by this map entry. */ | 1606 /* Let elt be the event defined by this map entry. */ |
1615 elt = XCAR (elt); | 1607 elt = XCAR (elt); |
1685 | 1677 |
1686 maps = XCAR (args); | 1678 maps = XCAR (args); |
1687 tail = XCAR (XCDR (args)); | 1679 tail = XCAR (XCDR (args)); |
1688 thisseq = XCDR (XCDR (args)); | 1680 thisseq = XCDR (XCDR (args)); |
1689 | 1681 |
1690 tem = Fkeymapp (cmd); | 1682 tem = get_keymap (cmd, 0, 0); |
1691 if (!NILP (tem)) | 1683 if (CONSP (tem)) |
1692 { | 1684 { |
1693 cmd = get_keymap (cmd); | 1685 cmd = tem; |
1694 /* Ignore keymaps that are already added to maps. */ | 1686 /* Ignore keymaps that are already added to maps. */ |
1695 tem = Frassq (cmd, maps); | 1687 tem = Frassq (cmd, maps); |
1696 if (NILP (tem)) | 1688 if (NILP (tem)) |
1697 { | 1689 { |
1698 tem = append_key (thisseq, index); | 1690 tem = append_key (thisseq, index); |
2085 | 2077 |
2086 found = keymaps; | 2078 found = keymaps; |
2087 while (CONSP (found)) | 2079 while (CONSP (found)) |
2088 { | 2080 { |
2089 maps = | 2081 maps = |
2090 nconc2 (maps, Faccessible_keymaps (get_keymap (XCAR (found)), Qnil)); | 2082 nconc2 (maps, |
2083 Faccessible_keymaps (get_keymap (XCAR (found), 1, 0), Qnil)); | |
2091 found = XCDR (found); | 2084 found = XCDR (found); |
2092 } | 2085 } |
2093 | 2086 |
2094 GCPRO5 (definition, keymaps, maps, found, sequences); | 2087 GCPRO5 (definition, keymaps, maps, found, sequences); |
2095 found = Qnil; | 2088 found = Qnil; |
2665 } | 2658 } |
2666 | 2659 |
2667 /* If shmap is not nil and not a keymap, | 2660 /* If shmap is not nil and not a keymap, |
2668 it completely shadows this map, so don't | 2661 it completely shadows this map, so don't |
2669 describe this map at all. */ | 2662 describe this map at all. */ |
2670 if (!NILP (shmap) && NILP (Fkeymapp (shmap))) | 2663 if (!NILP (shmap) && !KEYMAPP (shmap)) |
2671 goto skip; | 2664 goto skip; |
2672 | 2665 |
2673 if (!NILP (shmap)) | 2666 if (!NILP (shmap)) |
2674 sub_shadows = Fcons (shmap, sub_shadows); | 2667 sub_shadows = Fcons (shmap, sub_shadows); |
2675 } | 2668 } |
2727 insert1 (tem1); | 2720 insert1 (tem1); |
2728 insert_string ("\n"); | 2721 insert_string ("\n"); |
2729 } | 2722 } |
2730 else if (STRINGP (definition) || VECTORP (definition)) | 2723 else if (STRINGP (definition) || VECTORP (definition)) |
2731 insert_string ("Keyboard Macro\n"); | 2724 insert_string ("Keyboard Macro\n"); |
2725 else if (KEYMAPP (definition)) | |
2726 insert_string ("Prefix Command\n"); | |
2732 else | 2727 else |
2733 { | 2728 insert_string ("??\n"); |
2734 tem1 = Fkeymapp (definition); | |
2735 if (!NILP (tem1)) | |
2736 insert_string ("Prefix Command\n"); | |
2737 else | |
2738 insert_string ("??\n"); | |
2739 } | |
2740 } | 2729 } |
2741 | 2730 |
2742 static void | 2731 static void |
2743 describe_translation (definition) | 2732 describe_translation (definition) |
2744 Lisp_Object definition; | 2733 Lisp_Object definition; |
2756 else if (STRINGP (definition) || VECTORP (definition)) | 2745 else if (STRINGP (definition) || VECTORP (definition)) |
2757 { | 2746 { |
2758 insert1 (Fkey_description (definition)); | 2747 insert1 (Fkey_description (definition)); |
2759 insert_string ("\n"); | 2748 insert_string ("\n"); |
2760 } | 2749 } |
2750 else if (KEYMAPP (definition)) | |
2751 insert_string ("Prefix Command\n"); | |
2761 else | 2752 else |
2762 { | 2753 insert_string ("??\n"); |
2763 tem1 = Fkeymapp (definition); | |
2764 if (!NILP (tem1)) | |
2765 insert_string ("Prefix Command\n"); | |
2766 else | |
2767 insert_string ("??\n"); | |
2768 } | |
2769 } | 2754 } |
2770 | 2755 |
2771 /* Describe the contents of map MAP, assuming that this map itself is | 2756 /* Describe the contents of map MAP, assuming that this map itself is |
2772 reached by the sequence of prefix keys KEYS (a string or vector). | 2757 reached by the sequence of prefix keys KEYS (a string or vector). |
2773 PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */ | 2758 PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */ |