aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c93
1 files changed, 16 insertions, 77 deletions
diff --git a/src/keymap.c b/src/keymap.c
index 1eeea81f627..1197f6fd4a5 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -59,22 +59,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
59 59
60Lisp_Object current_global_map; /* Current global keymap. */ 60Lisp_Object current_global_map; /* Current global keymap. */
61 61
62Lisp_Object global_map; /* Default global key bindings. */
63
64Lisp_Object meta_map; /* The keymap used for globally bound
65 ESC-prefixed default commands. */
66
67Lisp_Object control_x_map; /* The keymap used for globally bound
68 C-x-prefixed default commands. */
69
70 /* The keymap used by the minibuf for local
71 bindings when spaces are allowed in the
72 minibuf. */
73
74 /* The keymap used by the minibuf for local
75 bindings when spaces are not encouraged
76 in the minibuf. */
77
78/* Alist of elements like (DEL . "\d"). */ 62/* Alist of elements like (DEL . "\d"). */
79static Lisp_Object exclude_keys; 63static Lisp_Object exclude_keys;
80 64
@@ -140,19 +124,6 @@ in case you use it as a menu with `x-popup-menu'. */)
140 return list1 (Qkeymap); 124 return list1 (Qkeymap);
141} 125}
142 126
143/* This function is used for installing the standard key bindings
144 at initialization time.
145
146 For example:
147
148 initial_define_key (control_x_map, Ctl('X'), "exchange-point-and-mark"); */
149
150void
151initial_define_key (Lisp_Object keymap, int key, const char *defname)
152{
153 store_in_keymap (keymap, make_fixnum (key), intern_c_string (defname));
154}
155
156void 127void
157initial_define_lispy_key (Lisp_Object keymap, const char *keyname, const char *defname) 128initial_define_lispy_key (Lisp_Object keymap, const char *keyname, const char *defname)
158{ 129{
@@ -1741,28 +1712,6 @@ bindings; see the description of `lookup-key' for more details about this. */)
1741 return Flist (j, maps); 1712 return Flist (j, maps);
1742} 1713}
1743 1714
1744DEFUN ("define-prefix-command", Fdefine_prefix_command, Sdefine_prefix_command, 1, 3, 0,
1745 doc: /* Define COMMAND as a prefix command. COMMAND should be a symbol.
1746A new sparse keymap is stored as COMMAND's function definition and its
1747value.
1748This prepares COMMAND for use as a prefix key's binding.
1749If a second optional argument MAPVAR is given, it should be a symbol.
1750The map is then stored as MAPVAR's value instead of as COMMAND's
1751value; but COMMAND is still defined as a function.
1752The third optional argument NAME, if given, supplies a menu name
1753string for the map. This is required to use the keymap as a menu.
1754This function returns COMMAND. */)
1755 (Lisp_Object command, Lisp_Object mapvar, Lisp_Object name)
1756{
1757 Lisp_Object map = Fmake_sparse_keymap (name);
1758 Ffset (command, map);
1759 if (!NILP (mapvar))
1760 Fset (mapvar, map);
1761 else
1762 Fset (command, map);
1763 return command;
1764}
1765
1766DEFUN ("use-global-map", Fuse_global_map, Suse_global_map, 1, 1, 0, 1715DEFUN ("use-global-map", Fuse_global_map, Suse_global_map, 1, 1, 0,
1767 doc: /* Select KEYMAP as the global keymap. */) 1716 doc: /* Select KEYMAP as the global keymap. */)
1768 (Lisp_Object keymap) 1717 (Lisp_Object keymap)
@@ -2217,11 +2166,21 @@ See `text-char-description' for describing character codes. */)
2217 { 2166 {
2218 if (NILP (no_angles)) 2167 if (NILP (no_angles))
2219 { 2168 {
2220 Lisp_Object result; 2169 Lisp_Object namestr = SYMBOL_NAME (key);
2221 char *buffer = SAFE_ALLOCA (sizeof "<>" 2170 const char *sym = SSDATA (namestr);
2222 + SBYTES (SYMBOL_NAME (key))); 2171 ptrdiff_t len = SBYTES (namestr);
2223 esprintf (buffer, "<%s>", SDATA (SYMBOL_NAME (key))); 2172 /* Find the extent of the modifier prefix, like "C-M-". */
2224 result = build_string (buffer); 2173 int i = 0;
2174 while (i < len - 3 && sym[i + 1] == '-' && strchr ("CMSsHA", sym[i]))
2175 i += 2;
2176 /* First I bytes of SYM are modifiers; put <> around the rest. */
2177 char *buffer = SAFE_ALLOCA (len + 3);
2178 memcpy (buffer, sym, i);
2179 buffer[i] = '<';
2180 memcpy (buffer + i + 1, sym + i, len - i);
2181 buffer [len + 1] = '>';
2182 buffer [len + 2] = '\0';
2183 Lisp_Object result = build_string (buffer);
2225 SAFE_FREE (); 2184 SAFE_FREE ();
2226 return result; 2185 return result;
2227 } 2186 }
@@ -3195,21 +3154,9 @@ syms_of_keymap (void)
3195 Each one is the value of a Lisp variable, and is also 3154 Each one is the value of a Lisp variable, and is also
3196 pointed to by a C variable */ 3155 pointed to by a C variable */
3197 3156
3198 global_map = Fmake_keymap (Qnil); 3157 current_global_map = Qnil;
3199 Fset (intern_c_string ("global-map"), global_map);
3200
3201 current_global_map = global_map;
3202 staticpro (&global_map);
3203 staticpro (&current_global_map); 3158 staticpro (&current_global_map);
3204 3159
3205 meta_map = Fmake_keymap (Qnil);
3206 Fset (intern_c_string ("esc-map"), meta_map);
3207 Ffset (intern_c_string ("ESC-prefix"), meta_map);
3208
3209 control_x_map = Fmake_keymap (Qnil);
3210 Fset (intern_c_string ("ctl-x-map"), control_x_map);
3211 Ffset (intern_c_string ("Control-X-prefix"), control_x_map);
3212
3213 exclude_keys = pure_list 3160 exclude_keys = pure_list
3214 (pure_cons (build_pure_c_string ("DEL"), build_pure_c_string ("\\d")), 3161 (pure_cons (build_pure_c_string ("DEL"), build_pure_c_string ("\\d")),
3215 pure_cons (build_pure_c_string ("TAB"), build_pure_c_string ("\\t")), 3162 pure_cons (build_pure_c_string ("TAB"), build_pure_c_string ("\\t")),
@@ -3311,7 +3258,6 @@ be preferred. */);
3311 defsubr (&Sminor_mode_key_binding); 3258 defsubr (&Sminor_mode_key_binding);
3312 defsubr (&Sdefine_key); 3259 defsubr (&Sdefine_key);
3313 defsubr (&Slookup_key); 3260 defsubr (&Slookup_key);
3314 defsubr (&Sdefine_prefix_command);
3315 defsubr (&Suse_global_map); 3261 defsubr (&Suse_global_map);
3316 defsubr (&Suse_local_map); 3262 defsubr (&Suse_local_map);
3317 defsubr (&Scurrent_local_map); 3263 defsubr (&Scurrent_local_map);
@@ -3328,10 +3274,3 @@ be preferred. */);
3328 defsubr (&Swhere_is_internal); 3274 defsubr (&Swhere_is_internal);
3329 defsubr (&Sdescribe_buffer_bindings); 3275 defsubr (&Sdescribe_buffer_bindings);
3330} 3276}
3331
3332void
3333keys_of_keymap (void)
3334{
3335 initial_define_key (global_map, 033, "ESC-prefix");
3336 initial_define_key (global_map, Ctl ('X'), "Control-X-prefix");
3337}