Mercurial > hg > xemacs-beta
comparison src/keymap.c @ 20:859a2309aef8 r19-15b93
Import from CVS: tag r19-15b93
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:50:05 +0200 |
parents | 49a24b4fd526 |
children | 8fc7fe29b841 |
comparison
equal
deleted
inserted
replaced
19:ac1f612d5250 | 20:859a2309aef8 |
---|---|
763 } | 763 } |
764 keymap->name = Qnil; | 764 keymap->name = Qnil; |
765 return (result); | 765 return (result); |
766 } | 766 } |
767 | 767 |
768 DEFUN ("make-keymap", Fmake_keymap, Smake_keymap, 0, 1, 0 /* | 768 DEFUN ("make-keymap", Fmake_keymap, 0, 1, 0, /* |
769 Construct and return a new keymap object. | 769 Construct and return a new keymap object. |
770 All entries in it are nil, meaning \"command undefined\". | 770 All entries in it are nil, meaning \"command undefined\". |
771 | 771 |
772 Optional argument NAME specifies a name to assign to the keymap, | 772 Optional argument NAME specifies a name to assign to the keymap, |
773 as in `set-keymap-name'. This name is only a debugging convenience; | 773 as in `set-keymap-name'. This name is only a debugging convenience; |
774 it is not used except when printing the keymap. | 774 it is not used except when printing the keymap. |
775 */ ) | 775 */ |
776 (name) | 776 (name)) |
777 Lisp_Object name; | |
778 { | 777 { |
779 Lisp_Object keymap = make_keymap (60); | 778 Lisp_Object keymap = make_keymap (60); |
780 if (!NILP (name)) | 779 if (!NILP (name)) |
781 Fset_keymap_name (keymap, name); | 780 Fset_keymap_name (keymap, name); |
782 return keymap; | 781 return keymap; |
783 } | 782 } |
784 | 783 |
785 DEFUN ("make-sparse-keymap", Fmake_sparse_keymap, Smake_sparse_keymap, | 784 DEFUN ("make-sparse-keymap", Fmake_sparse_keymap, 0, 1, 0, /* |
786 0, 1, 0 /* | |
787 Construct and return a new keymap object. | 785 Construct and return a new keymap object. |
788 All entries in it are nil, meaning \"command undefined\". The only | 786 All entries in it are nil, meaning \"command undefined\". The only |
789 difference between this function and make-keymap is that this function | 787 difference between this function and make-keymap is that this function |
790 returns a \"smaller\" keymap (one that is expected to contain fewer | 788 returns a \"smaller\" keymap (one that is expected to contain fewer |
791 entries). As keymaps dynamically resize, the distinction is not great. | 789 entries). As keymaps dynamically resize, the distinction is not great. |
792 | 790 |
793 Optional argument NAME specifies a name to assign to the keymap, | 791 Optional argument NAME specifies a name to assign to the keymap, |
794 as in `set-keymap-name'. This name is only a debugging convenience; | 792 as in `set-keymap-name'. This name is only a debugging convenience; |
795 it is not used except when printing the keymap. | 793 it is not used except when printing the keymap. |
796 */ ) | 794 */ |
797 (name) | 795 (name)) |
798 Lisp_Object name; | |
799 { | 796 { |
800 Lisp_Object keymap = make_keymap (8); | 797 Lisp_Object keymap = make_keymap (8); |
801 if (!NILP (name)) | 798 if (!NILP (name)) |
802 Fset_keymap_name (keymap, name); | 799 Fset_keymap_name (keymap, name); |
803 return keymap; | 800 return keymap; |
804 } | 801 } |
805 | 802 |
806 DEFUN ("keymap-parents", Fkeymap_parents, Skeymap_parents, 1, 1, 0 /* | 803 DEFUN ("keymap-parents", Fkeymap_parents, 1, 1, 0, /* |
807 Return the `parent' keymaps of the given keymap, or nil. | 804 Return the `parent' keymaps of the given keymap, or nil. |
808 The parents of a keymap are searched for keybindings when a key sequence | 805 The parents of a keymap are searched for keybindings when a key sequence |
809 isn't bound in this one. `(current-global-map)' is the default parent | 806 isn't bound in this one. `(current-global-map)' is the default parent |
810 of all keymaps. | 807 of all keymaps. |
811 */ ) | 808 */ |
812 (keymap) | 809 (keymap)) |
813 Lisp_Object keymap; | |
814 { | 810 { |
815 keymap = get_keymap (keymap, 1, 1); | 811 keymap = get_keymap (keymap, 1, 1); |
816 return (Fcopy_sequence (XKEYMAP (keymap)->parents)); | 812 return (Fcopy_sequence (XKEYMAP (keymap)->parents)); |
817 } | 813 } |
818 | 814 |
822 traverse_keymaps_noop (Lisp_Object keymap, void *arg) | 818 traverse_keymaps_noop (Lisp_Object keymap, void *arg) |
823 { | 819 { |
824 return (Qnil); | 820 return (Qnil); |
825 } | 821 } |
826 | 822 |
827 DEFUN ("set-keymap-parents", Fset_keymap_parents, Sset_keymap_parents, 2, 2, 0 /* | 823 DEFUN ("set-keymap-parents", Fset_keymap_parents, 2, 2, 0, /* |
828 Sets the `parent' keymaps of the given keymap. | 824 Sets the `parent' keymaps of the given keymap. |
829 The parents of a keymap are searched for keybindings when a key sequence | 825 The parents of a keymap are searched for keybindings when a key sequence |
830 isn't bound in this one. `(current-global-map)' is the default parent | 826 isn't bound in this one. `(current-global-map)' is the default parent |
831 of all keymaps. | 827 of all keymaps. |
832 */ ) | 828 */ |
833 (keymap, parents) | 829 (keymap, parents)) |
834 Lisp_Object keymap, parents; | |
835 { | 830 { |
836 /* This function can GC */ | 831 /* This function can GC */ |
837 Lisp_Object k; | 832 Lisp_Object k; |
838 struct gcpro gcpro1, gcpro2; | 833 struct gcpro gcpro1, gcpro2; |
839 | 834 |
863 XKEYMAP (keymap)->parents = Fcopy_sequence (parents); | 858 XKEYMAP (keymap)->parents = Fcopy_sequence (parents); |
864 UNGCPRO; | 859 UNGCPRO; |
865 return (parents); | 860 return (parents); |
866 } | 861 } |
867 | 862 |
868 DEFUN ("set-keymap-name", Fset_keymap_name, Sset_keymap_name, 2, 2, 0 /* | 863 DEFUN ("set-keymap-name", Fset_keymap_name, 2, 2, 0, /* |
869 Set the `name' of the KEYMAP to NEW-NAME. | 864 Set the `name' of the KEYMAP to NEW-NAME. |
870 The name is only a debugging convenience; it is not used except | 865 The name is only a debugging convenience; it is not used except |
871 when printing the keymap. | 866 when printing the keymap. |
872 */ ) | 867 */ |
873 (keymap, new_name) | 868 (keymap, new_name)) |
874 Lisp_Object keymap, new_name; | |
875 { | 869 { |
876 keymap = get_keymap (keymap, 1, 1); | 870 keymap = get_keymap (keymap, 1, 1); |
877 | 871 |
878 XKEYMAP (keymap)->name = new_name; | 872 XKEYMAP (keymap)->name = new_name; |
879 return (new_name); | 873 return (new_name); |
880 } | 874 } |
881 | 875 |
882 DEFUN ("keymap-name", Fkeymap_name, Skeymap_name, 1, 1, 0 /* | 876 DEFUN ("keymap-name", Fkeymap_name, 1, 1, 0, /* |
883 Return the `name' of KEYMAP. | 877 Return the `name' of KEYMAP. |
884 The name is only a debugging convenience; it is not used except | 878 The name is only a debugging convenience; it is not used except |
885 when printing the keymap. | 879 when printing the keymap. |
886 */ ) | 880 */ |
887 (keymap) | 881 (keymap)) |
888 Lisp_Object keymap; | |
889 { | 882 { |
890 keymap = get_keymap (keymap, 1, 1); | 883 keymap = get_keymap (keymap, 1, 1); |
891 | 884 |
892 return (XKEYMAP (keymap)->name); | 885 return (XKEYMAP (keymap)->name); |
893 } | 886 } |
894 | 887 |
895 DEFUN ("set-keymap-prompt", Fset_keymap_prompt, Sset_keymap_prompt, 2, 2, 0 /* | 888 DEFUN ("set-keymap-prompt", Fset_keymap_prompt, 2, 2, 0, /* |
896 Sets the `prompt' of KEYMAP to string NEW-PROMPT, or `nil' | 889 Sets the `prompt' of KEYMAP to string NEW-PROMPT, or `nil' |
897 if no prompt is desired. The prompt is shown in the echo-area | 890 if no prompt is desired. The prompt is shown in the echo-area |
898 when reading a key-sequence to be looked-up in this keymap. | 891 when reading a key-sequence to be looked-up in this keymap. |
899 */ ) | 892 */ |
900 (keymap, new_prompt) | 893 (keymap, new_prompt)) |
901 Lisp_Object keymap, new_prompt; | |
902 { | 894 { |
903 keymap = get_keymap (keymap, 1, 1); | 895 keymap = get_keymap (keymap, 1, 1); |
904 | 896 |
905 if (!NILP (new_prompt)) | 897 if (!NILP (new_prompt)) |
906 CHECK_STRING (new_prompt); | 898 CHECK_STRING (new_prompt); |
914 { | 906 { |
915 return (XKEYMAP (keymap)->prompt); | 907 return (XKEYMAP (keymap)->prompt); |
916 } | 908 } |
917 | 909 |
918 | 910 |
919 DEFUN ("keymap-prompt", Fkeymap_prompt, Skeymap_prompt, 1, 2, 0 /* | 911 DEFUN ("keymap-prompt", Fkeymap_prompt, 1, 2, 0, /* |
920 Return the `prompt' of the given keymap. | 912 Return the `prompt' of the given keymap. |
921 If non-nil, the prompt is shown in the echo-area | 913 If non-nil, the prompt is shown in the echo-area |
922 when reading a key-sequence to be looked-up in this keymap. | 914 when reading a key-sequence to be looked-up in this keymap. |
923 */ ) | 915 */ |
924 (keymap, use_inherited) | 916 (keymap, use_inherited)) |
925 Lisp_Object keymap, use_inherited; | |
926 { | 917 { |
927 /* This function can GC */ | 918 /* This function can GC */ |
928 Lisp_Object prompt; | 919 Lisp_Object prompt; |
929 | 920 |
930 keymap = get_keymap (keymap, 1, 1); | 921 keymap = get_keymap (keymap, 1, 1); |
934 else | 925 else |
935 return (traverse_keymaps (keymap, Qnil, | 926 return (traverse_keymaps (keymap, Qnil, |
936 keymap_prompt_mapper, 0)); | 927 keymap_prompt_mapper, 0)); |
937 } | 928 } |
938 | 929 |
939 DEFUN ("set-keymap-default-binding", | 930 DEFUN ("set-keymap-default-binding", Fset_keymap_default_binding, 2, 2, 0, /* |
940 Fset_keymap_default_binding, Sset_keymap_default_binding, 2, 2, 0 /* | |
941 Sets the default binding of KEYMAP to COMMAND, or `nil' | 931 Sets the default binding of KEYMAP to COMMAND, or `nil' |
942 if no default is desired. The default-binding is returned when | 932 if no default is desired. The default-binding is returned when |
943 no other binding for a key-sequence is found in the keymap. | 933 no other binding for a key-sequence is found in the keymap. |
944 If a keymap has a non-nil default-binding, neither the keymap's | 934 If a keymap has a non-nil default-binding, neither the keymap's |
945 parents nor the current global map are searched for key bindings. | 935 parents nor the current global map are searched for key bindings. |
946 */ ) | 936 */ |
947 (keymap, command) | 937 (keymap, command)) |
948 Lisp_Object keymap, command; | |
949 { | 938 { |
950 /* This function can GC */ | 939 /* This function can GC */ |
951 keymap = get_keymap (keymap, 1, 1); | 940 keymap = get_keymap (keymap, 1, 1); |
952 | 941 |
953 XKEYMAP (keymap)->default_binding = command; | 942 XKEYMAP (keymap)->default_binding = command; |
954 return (command); | 943 return (command); |
955 } | 944 } |
956 | 945 |
957 DEFUN ("keymap-default-binding", | 946 DEFUN ("keymap-default-binding", Fkeymap_default_binding, 1, 1, 0, /* |
958 Fkeymap_default_binding, Skeymap_default_binding, 1, 1, 0 /* | |
959 Return the default binding of KEYMAP, or `nil' if it has none. | 947 Return the default binding of KEYMAP, or `nil' if it has none. |
960 The default-binding is returned when no other binding for a key-sequence | 948 The default-binding is returned when no other binding for a key-sequence |
961 is found in the keymap. | 949 is found in the keymap. |
962 If a keymap has a non-nil default-binding, neither the keymap's | 950 If a keymap has a non-nil default-binding, neither the keymap's |
963 parents nor the current global map are searched for key bindings. | 951 parents nor the current global map are searched for key bindings. |
964 */ ) | 952 */ |
965 (keymap) | 953 (keymap)) |
966 Lisp_Object keymap; | |
967 { | 954 { |
968 /* This function can GC */ | 955 /* This function can GC */ |
969 keymap = get_keymap (keymap, 1, 1); | 956 keymap = get_keymap (keymap, 1, 1); |
970 return (XKEYMAP (keymap)->default_binding); | 957 return (XKEYMAP (keymap)->default_binding); |
971 } | 958 } |
972 | 959 |
973 DEFUN ("keymapp", Fkeymapp, Skeymapp, 1, 1, 0 /* | 960 DEFUN ("keymapp", Fkeymapp, 1, 1, 0, /* |
974 Return t if ARG is a keymap object. | 961 Return t if ARG is a keymap object. |
975 The keymap may be autoloaded first if necessary. | 962 The keymap may be autoloaded first if necessary. |
976 */ ) | 963 */ |
977 (object) | 964 (object)) |
978 Lisp_Object object; | |
979 { | 965 { |
980 /* This function can GC */ | 966 /* This function can GC */ |
981 Lisp_Object tem = get_keymap (object, 0, 1); | 967 Lisp_Object tem = get_keymap (object, 0, 1); |
982 return ((KEYMAPP (tem)) ? Qt : Qnil); | 968 return ((KEYMAPP (tem)) ? Qt : Qnil); |
983 } | 969 } |
1193 XKEYMAP (keymap)->table, | 1179 XKEYMAP (keymap)->table, |
1194 ©_keymap_closure); | 1180 ©_keymap_closure); |
1195 return keymap; | 1181 return keymap; |
1196 } | 1182 } |
1197 | 1183 |
1198 DEFUN ("copy-keymap", Fcopy_keymap, Scopy_keymap, 1, 1, 0 /* | 1184 DEFUN ("copy-keymap", Fcopy_keymap, 1, 1, 0, /* |
1199 Return a copy of the keymap KEYMAP. | 1185 Return a copy of the keymap KEYMAP. |
1200 The copy starts out with the same definitions of KEYMAP, | 1186 The copy starts out with the same definitions of KEYMAP, |
1201 but changing either the copy or KEYMAP does not affect the other. | 1187 but changing either the copy or KEYMAP does not affect the other. |
1202 Any key definitions that are subkeymaps are recursively copied. | 1188 Any key definitions that are subkeymaps are recursively copied. |
1203 */ ) | 1189 */ |
1204 (keymap) | 1190 (keymap)) |
1205 Lisp_Object keymap; | |
1206 { | 1191 { |
1207 /* This function can GC */ | 1192 /* This function can GC */ |
1208 keymap = get_keymap (keymap, 1, 1); | 1193 keymap = get_keymap (keymap, 1, 1); |
1209 return copy_keymap (keymap); | 1194 return copy_keymap (keymap); |
1210 } | 1195 } |
1233 } | 1218 } |
1234 UNGCPRO; | 1219 UNGCPRO; |
1235 return (fullness); | 1220 return (fullness); |
1236 } | 1221 } |
1237 | 1222 |
1238 DEFUN ("keymap-fullness", Fkeymap_fullness, Skeymap_fullness, 1, 1, 0 /* | 1223 DEFUN ("keymap-fullness", Fkeymap_fullness, 1, 1, 0, /* |
1239 Return the number of bindings in the keymap. | 1224 Return the number of bindings in the keymap. |
1240 */ ) | 1225 */ |
1241 (keymap) | 1226 (keymap)) |
1242 Lisp_Object keymap; | |
1243 { | 1227 { |
1244 /* This function can GC */ | 1228 /* This function can GC */ |
1245 return (make_int (keymap_fullness | 1229 return (make_int (keymap_fullness |
1246 (get_keymap (keymap, 1, 1)))); | 1230 (get_keymap (keymap, 1, 1)))); |
1247 } | 1231 } |
1591 event.event.key.keysym = key->keysym; | 1575 event.event.key.keysym = key->keysym; |
1592 event.event.key.modifiers = key->modifiers; | 1576 event.event.key.modifiers = key->modifiers; |
1593 return event_matches_key_specifier_p (&event, Vmeta_prefix_char); | 1577 return event_matches_key_specifier_p (&event, Vmeta_prefix_char); |
1594 } | 1578 } |
1595 | 1579 |
1596 DEFUN ("event-matches-key-specifier-p", | 1580 DEFUN ("event-matches-key-specifier-p", Fevent_matches_key_specifier_p, 2, 2, 0, /* |
1597 Fevent_matches_key_specifier_p, | |
1598 Sevent_matches_key_specifier_p, | |
1599 2, 2, 0 /* | |
1600 Return non-nil if EVENT matches KEY-SPECIFIER. | 1581 Return non-nil if EVENT matches KEY-SPECIFIER. |
1601 This can be useful, e.g., to determine if the user pressed `help-char' or | 1582 This can be useful, e.g., to determine if the user pressed `help-char' or |
1602 `quit-char'. | 1583 `quit-char'. |
1603 */ ) | 1584 */ |
1604 (event, key_specifier) | 1585 (event, key_specifier)) |
1605 Lisp_Object event, key_specifier; | |
1606 { | 1586 { |
1607 CHECK_LIVE_EVENT (event); | 1587 CHECK_LIVE_EVENT (event); |
1608 return (event_matches_key_specifier_p (XEVENT (event), key_specifier) | 1588 return (event_matches_key_specifier_p (XEVENT (event), key_specifier) |
1609 ? Qt : Qnil); | 1589 ? Qt : Qnil); |
1610 } | 1590 } |
1716 (Fsingle_key_description | 1696 (Fsingle_key_description |
1717 (Vmeta_prefix_char)))); | 1697 (Vmeta_prefix_char)))); |
1718 signal_simple_error (buf, mpc_binding); | 1698 signal_simple_error (buf, mpc_binding); |
1719 } | 1699 } |
1720 | 1700 |
1721 DEFUN ("define-key", Fdefine_key, Sdefine_key, 3, 3, 0 /* | 1701 DEFUN ("define-key", Fdefine_key, 3, 3, 0, /* |
1722 Define key sequence KEYS, in KEYMAP, as DEF. | 1702 Define key sequence KEYS, in KEYMAP, as DEF. |
1723 KEYMAP is a keymap object. | 1703 KEYMAP is a keymap object. |
1724 KEYS is the sequence of keystrokes to bind, described below. | 1704 KEYS is the sequence of keystrokes to bind, described below. |
1725 DEF is anything that can be a key's definition: | 1705 DEF is anything that can be a key's definition: |
1726 nil (means key is undefined in this keymap); | 1706 nil (means key is undefined in this keymap); |
1816 (define-key global-map [(control x) tab] \'command-3) | 1796 (define-key global-map [(control x) tab] \'command-3) |
1817 | 1797 |
1818 Of course, all of this applies only when running under a window system. If | 1798 Of course, all of this applies only when running under a window system. If |
1819 you're talking to XEmacs through a TTY connection, you don't get any of | 1799 you're talking to XEmacs through a TTY connection, you don't get any of |
1820 these features. | 1800 these features. |
1821 */ ) | 1801 */ |
1822 (keymap, keys, def) | 1802 (keymap, keys, def)) |
1823 Lisp_Object keymap; | |
1824 Lisp_Object keys; | |
1825 Lisp_Object def; | |
1826 { | 1803 { |
1827 /* This function can GC */ | 1804 /* This function can GC */ |
1828 int idx; | 1805 int idx; |
1829 int metized = 0; | 1806 int metized = 0; |
1830 int size; | 1807 int size; |
2175 } | 2152 } |
2176 UNGCPRO; | 2153 UNGCPRO; |
2177 return (tem); | 2154 return (tem); |
2178 } | 2155 } |
2179 | 2156 |
2180 DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 0 /* | 2157 DEFUN ("lookup-key", Flookup_key, 2, 3, 0, /* |
2181 In keymap KEYMAP, look up key-sequence KEYS. Return the definition. | 2158 In keymap KEYMAP, look up key-sequence KEYS. Return the definition. |
2182 Nil is returned if KEYS is unbound. See documentation of `define-key' | 2159 Nil is returned if KEYS is unbound. See documentation of `define-key' |
2183 for valid key definitions and key-sequence specifications. | 2160 for valid key definitions and key-sequence specifications. |
2184 A number is returned if KEYS is \"too long\"; that is, the leading | 2161 A number is returned if KEYS is \"too long\"; that is, the leading |
2185 characters fail to be a valid sequence of prefix characters in KEYMAP. | 2162 characters fail to be a valid sequence of prefix characters in KEYMAP. |
2186 The number is how many characters at the front of KEYS | 2163 The number is how many characters at the front of KEYS |
2187 it takes to reach a non-prefix command. | 2164 it takes to reach a non-prefix command. |
2188 */ ) | 2165 */ |
2189 (keymap, keys, accept_default) | 2166 (keymap, keys, accept_default)) |
2190 Lisp_Object keymap, keys, accept_default; | |
2191 { | 2167 { |
2192 /* This function can GC */ | 2168 /* This function can GC */ |
2193 if (VECTORP (keys)) | 2169 if (VECTORP (keys)) |
2194 { | 2170 { |
2195 return lookup_keys (keymap, | 2171 return lookup_keys (keymap, |
2493 QUIT; | 2469 QUIT; |
2494 } | 2470 } |
2495 } | 2471 } |
2496 | 2472 |
2497 /* #### Would map-current-keymaps be a better thing?? */ | 2473 /* #### Would map-current-keymaps be a better thing?? */ |
2498 DEFUN ("current-keymaps", Fcurrent_keymaps, Scurrent_keymaps, 0, 1, 0 /* | 2474 DEFUN ("current-keymaps", Fcurrent_keymaps, 0, 1, 0, /* |
2499 Return a list of the current keymaps that will be searched for bindings. | 2475 Return a list of the current keymaps that will be searched for bindings. |
2500 This lists keymaps such as the current local map and the minor-mode maps, | 2476 This lists keymaps such as the current local map and the minor-mode maps, |
2501 but does not list the parents of those keymaps. | 2477 but does not list the parents of those keymaps. |
2502 EVENT-OR-KEYS controls which keymaps will be listed. | 2478 EVENT-OR-KEYS controls which keymaps will be listed. |
2503 If EVENT-OR-KEYS is a mouse event (or a vector whose last element is a | 2479 If EVENT-OR-KEYS is a mouse event (or a vector whose last element is a |
2504 mouse event), the keymaps for that mouse event will be listed (see | 2480 mouse event), the keymaps for that mouse event will be listed (see |
2505 `key-binding'). Otherwise, the keymaps for key presses will be listed. | 2481 `key-binding'). Otherwise, the keymaps for key presses will be listed. |
2506 */ ) | 2482 */ |
2507 (event_or_keys) | 2483 (event_or_keys)) |
2508 Lisp_Object event_or_keys; | |
2509 { | 2484 { |
2510 /* This function can GC */ | 2485 /* This function can GC */ |
2511 struct gcpro gcpro1; | 2486 struct gcpro gcpro1; |
2512 Lisp_Object maps[100]; | 2487 Lisp_Object maps[100]; |
2513 Lisp_Object *gubbish = maps; | 2488 Lisp_Object *gubbish = maps; |
2523 } | 2498 } |
2524 UNGCPRO; | 2499 UNGCPRO; |
2525 return (Flist (nmaps, gubbish)); | 2500 return (Flist (nmaps, gubbish)); |
2526 } | 2501 } |
2527 | 2502 |
2528 DEFUN ("key-binding", Fkey_binding, Skey_binding, 1, 2, 0 /* | 2503 DEFUN ("key-binding", Fkey_binding, 1, 2, 0, /* |
2529 Return the binding for command KEYS in current keymaps. | 2504 Return the binding for command KEYS in current keymaps. |
2530 KEYS is a string, a vector of events, or a vector of key-description lists | 2505 KEYS is a string, a vector of events, or a vector of key-description lists |
2531 as described in the documentation for the `define-key' function. | 2506 as described in the documentation for the `define-key' function. |
2532 The binding is probably a symbol with a function definition; see | 2507 The binding is probably a symbol with a function definition; see |
2533 the documentation for `lookup-key' for more information. | 2508 the documentation for `lookup-key' for more information. |
2551 - any applicable minor-mode maps; | 2526 - any applicable minor-mode maps; |
2552 - the current global map. | 2527 - the current global map. |
2553 | 2528 |
2554 Note that if `overriding-local-map' or `overriding-terminal-local-map' | 2529 Note that if `overriding-local-map' or `overriding-terminal-local-map' |
2555 is non-nil, *only* those two maps and the current global map are searched. | 2530 is non-nil, *only* those two maps and the current global map are searched. |
2556 */ ) | 2531 */ |
2557 (keys, accept_default) | 2532 (keys, accept_default)) |
2558 Lisp_Object keys, accept_default; | |
2559 { | 2533 { |
2560 /* This function can GC */ | 2534 /* This function can GC */ |
2561 int i; | 2535 int i; |
2562 Lisp_Object maps[100]; | 2536 Lisp_Object maps[100]; |
2563 int nmaps; | 2537 int nmaps; |
2664 | 2638 |
2665 /************************************************************************/ | 2639 /************************************************************************/ |
2666 /* Setting/querying the global and local maps */ | 2640 /* Setting/querying the global and local maps */ |
2667 /************************************************************************/ | 2641 /************************************************************************/ |
2668 | 2642 |
2669 DEFUN ("use-global-map", Fuse_global_map, Suse_global_map, 1, 1, 0 /* | 2643 DEFUN ("use-global-map", Fuse_global_map, 1, 1, 0, /* |
2670 Select KEYMAP as the global keymap. | 2644 Select KEYMAP as the global keymap. |
2671 */ ) | 2645 */ |
2672 (keymap) | 2646 (keymap)) |
2673 Lisp_Object keymap; | |
2674 { | 2647 { |
2675 /* This function can GC */ | 2648 /* This function can GC */ |
2676 keymap = get_keymap (keymap, 1, 1); | 2649 keymap = get_keymap (keymap, 1, 1); |
2677 Vcurrent_global_map = keymap; | 2650 Vcurrent_global_map = keymap; |
2678 return Qnil; | 2651 return Qnil; |
2679 } | 2652 } |
2680 | 2653 |
2681 DEFUN ("use-local-map", Fuse_local_map, Suse_local_map, 1, 2, 0 /* | 2654 DEFUN ("use-local-map", Fuse_local_map, 1, 2, 0, /* |
2682 Select KEYMAP as the local keymap in BUFFER. | 2655 Select KEYMAP as the local keymap in BUFFER. |
2683 If KEYMAP is nil, that means no local keymap. | 2656 If KEYMAP is nil, that means no local keymap. |
2684 If BUFFER is nil, the current buffer is assumed. | 2657 If BUFFER is nil, the current buffer is assumed. |
2685 */ ) | 2658 */ |
2686 (keymap, buffer) | 2659 (keymap, buffer)) |
2687 Lisp_Object keymap, buffer; | |
2688 { | 2660 { |
2689 /* This function can GC */ | 2661 /* This function can GC */ |
2690 struct buffer *b = decode_buffer (buffer, 0); | 2662 struct buffer *b = decode_buffer (buffer, 0); |
2691 if (!NILP (keymap)) | 2663 if (!NILP (keymap)) |
2692 keymap = get_keymap (keymap, 1, 1); | 2664 keymap = get_keymap (keymap, 1, 1); |
2694 b->keymap = keymap; | 2666 b->keymap = keymap; |
2695 | 2667 |
2696 return Qnil; | 2668 return Qnil; |
2697 } | 2669 } |
2698 | 2670 |
2699 DEFUN ("current-local-map", Fcurrent_local_map, Scurrent_local_map, 0, 1, 0 /* | 2671 DEFUN ("current-local-map", Fcurrent_local_map, 0, 1, 0, /* |
2700 Return BUFFER's local keymap, or nil if it has none. | 2672 Return BUFFER's local keymap, or nil if it has none. |
2701 If BUFFER is nil, the current buffer is assumed. | 2673 If BUFFER is nil, the current buffer is assumed. |
2702 */ ) | 2674 */ |
2703 (buffer) | 2675 (buffer)) |
2704 Lisp_Object buffer; | |
2705 { | 2676 { |
2706 struct buffer *b = decode_buffer (buffer, 0); | 2677 struct buffer *b = decode_buffer (buffer, 0); |
2707 return b->keymap; | 2678 return b->keymap; |
2708 } | 2679 } |
2709 | 2680 |
2710 DEFUN ("current-global-map", Fcurrent_global_map, Scurrent_global_map, 0, 0, 0 /* | 2681 DEFUN ("current-global-map", Fcurrent_global_map, 0, 0, 0, /* |
2711 Return the current global keymap. | 2682 Return the current global keymap. |
2712 */ ) | 2683 */ |
2713 () | 2684 ()) |
2714 { | 2685 { |
2715 return (Vcurrent_global_map); | 2686 return (Vcurrent_global_map); |
2716 } | 2687 } |
2717 | 2688 |
2718 | 2689 |
2949 elisp_maphash (map_keymap_unsorted_mapper, keymap_table, | 2920 elisp_maphash (map_keymap_unsorted_mapper, keymap_table, |
2950 &map_keymap_unsorted_closure); | 2921 &map_keymap_unsorted_closure); |
2951 } | 2922 } |
2952 } | 2923 } |
2953 | 2924 |
2954 DEFUN ("map-keymap", Fmap_keymap, Smap_keymap, 2, 3, 0 /* | 2925 DEFUN ("map-keymap", Fmap_keymap, 2, 3, 0, /* |
2955 Apply FUNCTION to each element of KEYMAP. | 2926 Apply FUNCTION to each element of KEYMAP. |
2956 FUNCTION will be called with two arguments: a key-description list, and | 2927 FUNCTION will be called with two arguments: a key-description list, and |
2957 the binding. The order in which the elements of the keymap are passed to | 2928 the binding. The order in which the elements of the keymap are passed to |
2958 the function is unspecified. If the function inserts new elements into | 2929 the function is unspecified. If the function inserts new elements into |
2959 the keymap, it may or may not be called with them later. No element of | 2930 the keymap, it may or may not be called with them later. No element of |
2967 | 2938 |
2968 If the optional third argument SORT-FIRST is non-nil, then the elements of | 2939 If the optional third argument SORT-FIRST is non-nil, then the elements of |
2969 the keymap will be passed to the mapper function in a canonical order. | 2940 the keymap will be passed to the mapper function in a canonical order. |
2970 Otherwise, they will be passed in hash (that is, random) order, which is | 2941 Otherwise, they will be passed in hash (that is, random) order, which is |
2971 faster. | 2942 faster. |
2972 */ ) | 2943 */ |
2973 (function, keymap, sort_first) | 2944 (function, keymap, sort_first)) |
2974 Lisp_Object function, keymap, sort_first; | |
2975 { | 2945 { |
2976 /* This function can GC */ | 2946 /* This function can GC */ |
2977 struct gcpro gcpro1, gcpro2; | 2947 struct gcpro gcpro1, gcpro2; |
2978 | 2948 |
2979 /* tolerate obviously transposed args */ | 2949 /* tolerate obviously transposed args */ |
3067 } | 3037 } |
3068 return (Qnil); | 3038 return (Qnil); |
3069 } | 3039 } |
3070 | 3040 |
3071 | 3041 |
3072 DEFUN ("accessible-keymaps", Faccessible_keymaps, Saccessible_keymaps, | 3042 DEFUN ("accessible-keymaps", Faccessible_keymaps, 1, 2, 0, /* |
3073 1, 2, 0 /* | |
3074 Find all keymaps accessible via prefix characters from STARTMAP. | 3043 Find all keymaps accessible via prefix characters from STARTMAP. |
3075 Returns a list of elements of the form (KEYS . MAP), where the sequence | 3044 Returns a list of elements of the form (KEYS . MAP), where the sequence |
3076 KEYS starting from STARTMAP gets you to MAP. These elements are ordered | 3045 KEYS starting from STARTMAP gets you to MAP. These elements are ordered |
3077 so that the KEYS increase in length. The first element is ([] . STARTMAP). | 3046 so that the KEYS increase in length. The first element is ([] . STARTMAP). |
3078 An optional argument PREFIX, if non-nil, should be a key sequence; | 3047 An optional argument PREFIX, if non-nil, should be a key sequence; |
3079 then the value includes only maps for prefixes that start with PREFIX. | 3048 then the value includes only maps for prefixes that start with PREFIX. |
3080 */ ) | 3049 */ |
3081 (startmap, prefix) | 3050 (startmap, prefix)) |
3082 Lisp_Object startmap, prefix; | |
3083 { | 3051 { |
3084 /* This function can GC */ | 3052 /* This function can GC */ |
3085 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 3053 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
3086 Lisp_Object accessible_keymaps = Qnil; | 3054 Lisp_Object accessible_keymaps = Qnil; |
3087 struct accessible_keymaps_closure c; | 3055 struct accessible_keymaps_closure c; |
3146 | 3114 |
3147 /************************************************************************/ | 3115 /************************************************************************/ |
3148 /* Pretty descriptions of key sequences */ | 3116 /* Pretty descriptions of key sequences */ |
3149 /************************************************************************/ | 3117 /************************************************************************/ |
3150 | 3118 |
3151 DEFUN ("key-description", Fkey_description, Skey_description, 1, 1, 0 /* | 3119 DEFUN ("key-description", Fkey_description, 1, 1, 0, /* |
3152 Return a pretty description of key-sequence KEYS. | 3120 Return a pretty description of key-sequence KEYS. |
3153 Control characters turn into \"C-foo\" sequences, meta into \"M-foo\" | 3121 Control characters turn into \"C-foo\" sequences, meta into \"M-foo\" |
3154 spaces are put between sequence elements, etc. | 3122 spaces are put between sequence elements, etc. |
3155 */ ) | 3123 */ |
3156 (keys) | 3124 (keys)) |
3157 Lisp_Object keys; | |
3158 { | 3125 { |
3159 if (INTP (keys) || CONSP (keys) || SYMBOLP (keys) || EVENTP (keys)) | 3126 if (INTP (keys) || CONSP (keys) || SYMBOLP (keys) || EVENTP (keys)) |
3160 { | 3127 { |
3161 return Fsingle_key_description (keys); | 3128 return Fsingle_key_description (keys); |
3162 } | 3129 } |
3186 return (string); | 3153 return (string); |
3187 } | 3154 } |
3188 return Fkey_description (wrong_type_argument (Qsequencep, keys)); | 3155 return Fkey_description (wrong_type_argument (Qsequencep, keys)); |
3189 } | 3156 } |
3190 | 3157 |
3191 DEFUN ("single-key-description", Fsingle_key_description, | 3158 DEFUN ("single-key-description", Fsingle_key_description, 1, 1, 0, /* |
3192 Ssingle_key_description, 1, 1, 0 /* | |
3193 Return a pretty description of command character KEY. | 3159 Return a pretty description of command character KEY. |
3194 Control characters turn into C-whatever, etc. | 3160 Control characters turn into C-whatever, etc. |
3195 This differs from `text-char-description' in that it returns a description | 3161 This differs from `text-char-description' in that it returns a description |
3196 of a key read from the user rather than a character from a buffer. | 3162 of a key read from the user rather than a character from a buffer. |
3197 */ ) | 3163 */ |
3198 (key) | 3164 (key)) |
3199 Lisp_Object key; | |
3200 { | 3165 { |
3201 if (SYMBOLP (key)) | 3166 if (SYMBOLP (key)) |
3202 key = Fcons (key, Qnil); /* sleaze sleaze */ | 3167 key = Fcons (key, Qnil); /* sleaze sleaze */ |
3203 | 3168 |
3204 if (EVENTP (key) || CHARP (key)) | 3169 if (EVENTP (key) || CHARP (key)) |
3259 } | 3224 } |
3260 return Fsingle_key_description | 3225 return Fsingle_key_description |
3261 (wrong_type_argument (intern ("char-or-event-p"), key)); | 3226 (wrong_type_argument (intern ("char-or-event-p"), key)); |
3262 } | 3227 } |
3263 | 3228 |
3264 DEFUN ("text-char-description", Ftext_char_description, Stext_char_description, | 3229 DEFUN ("text-char-description", Ftext_char_description, 1, 1, 0, /* |
3265 1, 1, 0 /* | |
3266 Return a pretty description of file-character CHR. | 3230 Return a pretty description of file-character CHR. |
3267 Unprintable characters turn into \"^char\" or \\NNN, depending on the value | 3231 Unprintable characters turn into \"^char\" or \\NNN, depending on the value |
3268 of the `ctl-arrow' variable. | 3232 of the `ctl-arrow' variable. |
3269 This differs from `single-key-description' in that it returns a description | 3233 This differs from `single-key-description' in that it returns a description |
3270 of a character from a buffer rather than a key read from the user. | 3234 of a character from a buffer rather than a key read from the user. |
3271 */ ) | 3235 */ |
3272 (chr) | 3236 (chr)) |
3273 Lisp_Object chr; | |
3274 { | 3237 { |
3275 Bufbyte buf[200]; | 3238 Bufbyte buf[200]; |
3276 Bufbyte *p; | 3239 Bufbyte *p; |
3277 unsigned int c; | 3240 unsigned int c; |
3278 Lisp_Object ctl_arrow = current_buffer->ctl_arrow; | 3241 Lisp_Object ctl_arrow = current_buffer->ctl_arrow; |
3334 | 3297 |
3335 static Lisp_Object | 3298 static Lisp_Object |
3336 where_is_internal (Lisp_Object definition, Lisp_Object *maps, int nmaps, | 3299 where_is_internal (Lisp_Object definition, Lisp_Object *maps, int nmaps, |
3337 Lisp_Object firstonly, char *target_buffer); | 3300 Lisp_Object firstonly, char *target_buffer); |
3338 | 3301 |
3339 DEFUN ("where-is-internal", Fwhere_is_internal, Swhere_is_internal, 1, 5, 0 /* | 3302 DEFUN ("where-is-internal", Fwhere_is_internal, 1, 5, 0, /* |
3340 Return list of keys that invoke DEFINITION in KEYMAPS. | 3303 Return list of keys that invoke DEFINITION in KEYMAPS. |
3341 KEYMAPS can be either a keymap (meaning search in that keymap and the | 3304 KEYMAPS can be either a keymap (meaning search in that keymap and the |
3342 current global keymap) or a list of keymaps (meaning search in exactly | 3305 current global keymap) or a list of keymaps (meaning search in exactly |
3343 those keymaps and no others). If KEYMAPS is nil, search in the currently | 3306 those keymaps and no others). If KEYMAPS is nil, search in the currently |
3344 applicable maps for EVENT-OR-KEYS (this is equivalent to specifying | 3307 applicable maps for EVENT-OR-KEYS (this is equivalent to specifying |
3349 sequences. | 3312 sequences. |
3350 | 3313 |
3351 If optional 4th arg NOINDIRECT is non-nil, don't follow indirections | 3314 If optional 4th arg NOINDIRECT is non-nil, don't follow indirections |
3352 to other keymaps or slots. This makes it possible to search for an | 3315 to other keymaps or slots. This makes it possible to search for an |
3353 indirect definition itself. | 3316 indirect definition itself. |
3354 */ ) | 3317 */ |
3355 (definition, keymaps, firstonly, noindirect, event_or_keys) | 3318 (definition, keymaps, firstonly, noindirect, event_or_keys)) |
3356 Lisp_Object definition, keymaps, firstonly, noindirect, event_or_keys; | |
3357 { | 3319 { |
3358 /* This function can GC */ | 3320 /* This function can GC */ |
3359 Lisp_Object maps[100]; | 3321 Lisp_Object maps[100]; |
3360 Lisp_Object *gubbish = maps; | 3322 Lisp_Object *gubbish = maps; |
3361 int nmaps; | 3323 int nmaps; |
3703 | 3665 |
3704 /************************************************************************/ | 3666 /************************************************************************/ |
3705 /* Describing keymaps */ | 3667 /* Describing keymaps */ |
3706 /************************************************************************/ | 3668 /************************************************************************/ |
3707 | 3669 |
3708 DEFUN ("describe-bindings-internal", | 3670 DEFUN ("describe-bindings-internal", Fdescribe_bindings_internal, 1, 5, 0, /* |
3709 Fdescribe_bindings_internal, Sdescribe_bindings_internal, 1, 5, 0 /* | |
3710 Insert a list of all defined keys and their definitions in MAP. | 3671 Insert a list of all defined keys and their definitions in MAP. |
3711 Optional second argument ALL says whether to include even \"uninteresting\" | 3672 Optional second argument ALL says whether to include even \"uninteresting\" |
3712 definitions (ie symbols with a non-nil `suppress-keymap' property. | 3673 definitions (ie symbols with a non-nil `suppress-keymap' property. |
3713 Third argument SHADOW is a list of keymaps whose bindings shadow those | 3674 Third argument SHADOW is a list of keymaps whose bindings shadow those |
3714 of map; if a binding is present in any shadowing map, it is not printed. | 3675 of map; if a binding is present in any shadowing map, it is not printed. |
3715 Fourth argument PREFIX, if non-nil, should be a key sequence; | 3676 Fourth argument PREFIX, if non-nil, should be a key sequence; |
3716 only bindings which start with that key sequence will be printed. | 3677 only bindings which start with that key sequence will be printed. |
3717 Fifth argument MOUSE-ONLY-P says to only print bindings for mouse clicks. | 3678 Fifth argument MOUSE-ONLY-P says to only print bindings for mouse clicks. |
3718 */ ) | 3679 */ |
3719 (map, all, shadow, prefix, mouse_only_p) | 3680 (map, all, shadow, prefix, mouse_only_p)) |
3720 Lisp_Object map, all, shadow, prefix, mouse_only_p; | |
3721 { | 3681 { |
3722 /* This function can GC */ | 3682 /* This function can GC */ |
3723 describe_map_tree (map, NILP (all), shadow, prefix, | 3683 describe_map_tree (map, NILP (all), shadow, prefix, |
3724 !NILP (mouse_only_p)); | 3684 !NILP (mouse_only_p)); |
3725 return (Qnil); | 3685 return (Qnil); |
4162 defsymbol (&Qsuppress_keymap, "suppress-keymap"); | 4122 defsymbol (&Qsuppress_keymap, "suppress-keymap"); |
4163 | 4123 |
4164 defsymbol (&Qmodeline_map, "modeline-map"); | 4124 defsymbol (&Qmodeline_map, "modeline-map"); |
4165 defsymbol (&Qtoolbar_map, "toolbar-map"); | 4125 defsymbol (&Qtoolbar_map, "toolbar-map"); |
4166 | 4126 |
4167 defsubr (&Skeymap_parents); | 4127 DEFSUBR (Fkeymap_parents); |
4168 defsubr (&Sset_keymap_parents); | 4128 DEFSUBR (Fset_keymap_parents); |
4169 defsubr (&Skeymap_name); | 4129 DEFSUBR (Fkeymap_name); |
4170 defsubr (&Sset_keymap_name); | 4130 DEFSUBR (Fset_keymap_name); |
4171 defsubr (&Skeymap_prompt); | 4131 DEFSUBR (Fkeymap_prompt); |
4172 defsubr (&Sset_keymap_prompt); | 4132 DEFSUBR (Fset_keymap_prompt); |
4173 defsubr (&Skeymap_default_binding); | 4133 DEFSUBR (Fkeymap_default_binding); |
4174 defsubr (&Sset_keymap_default_binding); | 4134 DEFSUBR (Fset_keymap_default_binding); |
4175 | 4135 |
4176 defsubr (&Skeymapp); | 4136 DEFSUBR (Fkeymapp); |
4177 defsubr (&Smake_keymap); | 4137 DEFSUBR (Fmake_keymap); |
4178 defsubr (&Smake_sparse_keymap); | 4138 DEFSUBR (Fmake_sparse_keymap); |
4179 | 4139 |
4180 defsubr (&Scopy_keymap); | 4140 DEFSUBR (Fcopy_keymap); |
4181 defsubr (&Skeymap_fullness); | 4141 DEFSUBR (Fkeymap_fullness); |
4182 defsubr (&Smap_keymap); | 4142 DEFSUBR (Fmap_keymap); |
4183 defsubr (&Sevent_matches_key_specifier_p); | 4143 DEFSUBR (Fevent_matches_key_specifier_p); |
4184 defsubr (&Sdefine_key); | 4144 DEFSUBR (Fdefine_key); |
4185 defsubr (&Slookup_key); | 4145 DEFSUBR (Flookup_key); |
4186 defsubr (&Skey_binding); | 4146 DEFSUBR (Fkey_binding); |
4187 defsubr (&Suse_global_map); | 4147 DEFSUBR (Fuse_global_map); |
4188 defsubr (&Suse_local_map); | 4148 DEFSUBR (Fuse_local_map); |
4189 defsubr (&Scurrent_local_map); | 4149 DEFSUBR (Fcurrent_local_map); |
4190 defsubr (&Scurrent_global_map); | 4150 DEFSUBR (Fcurrent_global_map); |
4191 defsubr (&Scurrent_keymaps); | 4151 DEFSUBR (Fcurrent_keymaps); |
4192 defsubr (&Saccessible_keymaps); | 4152 DEFSUBR (Faccessible_keymaps); |
4193 defsubr (&Skey_description); | 4153 DEFSUBR (Fkey_description); |
4194 defsubr (&Ssingle_key_description); | 4154 DEFSUBR (Fsingle_key_description); |
4195 defsubr (&Swhere_is_internal); | 4155 DEFSUBR (Fwhere_is_internal); |
4196 defsubr (&Sdescribe_bindings_internal); | 4156 DEFSUBR (Fdescribe_bindings_internal); |
4197 | 4157 |
4198 defsubr (&Stext_char_description); | 4158 DEFSUBR (Ftext_char_description); |
4199 | 4159 |
4200 defsymbol (&Qcontrol, "control"); | 4160 defsymbol (&Qcontrol, "control"); |
4201 defsymbol (&Qctrl, "ctrl"); | 4161 defsymbol (&Qctrl, "ctrl"); |
4202 defsymbol (&Qmeta, "meta"); | 4162 defsymbol (&Qmeta, "meta"); |
4203 defsymbol (&Qsuper, "super"); | 4163 defsymbol (&Qsuper, "super"); |