aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2021-01-04 22:57:21 -0500
committerStefan Monnier2021-01-04 23:41:19 -0500
commitd6f30e5632b1c9cf43ebfbdbf164d5c54be33475 (patch)
treed358a335c8404ba9233379b5baf8bf158da90487
parent898a94a9be06a3ab51116778f6b4a263f832759d (diff)
downloademacs-d6f30e5632b1c9cf43ebfbdbf164d5c54be33475.tar.gz
emacs-d6f30e5632b1c9cf43ebfbdbf164d5c54be33475.zip
* lisp/subr.el (global-map): Initialize inside declaration.
* src/commands.h (global_map): * src/keymap.c (global_map): Delete variable. (syms_of_keymap): Don't initialize global_map here. (keys_of_keymap): Delete function. * src/lisp.h (keys_of_cmds): * src/cmds.c (keys_of_cmds): Delete function. * src/emacs.c (main): Don't call them. * src/window.c (keys_of_window): Don't initialize global_map here. * src/keyboard.c (keys_of_keyboard): Don't initialize global_map here.
-rw-r--r--lisp/subr.el36
-rw-r--r--src/cmds.c21
-rw-r--r--src/commands.h1
-rw-r--r--src/emacs.c2
-rw-r--r--src/keyboard.c2
-rw-r--r--src/keymap.c15
-rw-r--r--src/keymap.h1
-rw-r--r--src/lisp.h1
-rw-r--r--src/window.c1
9 files changed, 32 insertions, 48 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 1acc3c3250b..6187f7ad3c4 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1242,11 +1242,6 @@ in a cleaner way with command remapping, like this:
1242;; global-map, esc-map, and ctl-x-map have their values set up in 1242;; global-map, esc-map, and ctl-x-map have their values set up in
1243;; keymap.c; we just give them docstrings here. 1243;; keymap.c; we just give them docstrings here.
1244 1244
1245(defvar global-map nil
1246 "Default global keymap mapping Emacs keyboard input into commands.
1247The value is a keymap that is usually (but not necessarily) Emacs's
1248global map.")
1249
1250(defvar esc-map nil 1245(defvar esc-map nil
1251 "Default keymap for ESC (meta) commands. 1246 "Default keymap for ESC (meta) commands.
1252The normal global definition of the character ESC indirects to this keymap.") 1247The normal global definition of the character ESC indirects to this keymap.")
@@ -1269,6 +1264,37 @@ The normal global definition of the character C-x indirects to this keymap.")
1269 "Keymap for tab-bar related commands.") 1264 "Keymap for tab-bar related commands.")
1270(define-key ctl-x-map "t" tab-prefix-map) 1265(define-key ctl-x-map "t" tab-prefix-map)
1271 1266
1267(defvar global-map
1268 (let ((map (make-keymap)))
1269 (define-key map "\C-[" 'ESC-prefix)
1270 (define-key map "\C-x" 'Control-X-prefix)
1271
1272 (define-key map "\C-i" #'self-insert-command)
1273 (let* ((vec1 (make-vector 1 nil))
1274 (f (lambda (from to)
1275 (while (< from to)
1276 (aset vec1 0 from)
1277 (define-key map vec1 #'self-insert-command)
1278 (setq from (1+ from))))))
1279 (funcall f #o040 #o0177)
1280 (when (eq system-type 'ms-dos) ;FIXME: Why?
1281 (funcall f #o0200 #o0240))
1282 (funcall f #o0240 #o0400))
1283
1284 (define-key map "\C-a" #'beginning-of-line)
1285 (define-key map "\C-b" #'backward-char)
1286 (define-key map "\C-e" #'end-of-line)
1287 (define-key map "\C-f" #'forward-char)
1288 (define-key map "\C-z" #'suspend-emacs) ;FIXME: Re-bound later!
1289
1290 (define-key map "\C-v" #'scroll-up-command)
1291 (define-key map "\C-]" #'abort-recursive-edit)
1292 map)
1293 "Default global keymap mapping Emacs keyboard input into commands.
1294The value is a keymap that is usually (but not necessarily) Emacs's
1295global map.")
1296(use-global-map global-map)
1297
1272 1298
1273;;;; Event manipulation functions. 1299;;;; Event manipulation functions.
1274 1300
diff --git a/src/cmds.c b/src/cmds.c
index 798fd68a920..1547db80e88 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -529,24 +529,3 @@ This is run after inserting the character. */);
529 defsubr (&Sdelete_char); 529 defsubr (&Sdelete_char);
530 defsubr (&Sself_insert_command); 530 defsubr (&Sself_insert_command);
531} 531}
532
533void
534keys_of_cmds (void)
535{
536 int n;
537
538 initial_define_key (global_map, Ctl ('I'), "self-insert-command");
539 for (n = 040; n < 0177; n++)
540 initial_define_key (global_map, n, "self-insert-command");
541#ifdef MSDOS
542 for (n = 0200; n < 0240; n++)
543 initial_define_key (global_map, n, "self-insert-command");
544#endif
545 for (n = 0240; n < 0400; n++)
546 initial_define_key (global_map, n, "self-insert-command");
547
548 initial_define_key (global_map, Ctl ('A'), "beginning-of-line");
549 initial_define_key (global_map, Ctl ('B'), "backward-char");
550 initial_define_key (global_map, Ctl ('E'), "end-of-line");
551 initial_define_key (global_map, Ctl ('F'), "forward-char");
552}
diff --git a/src/commands.h b/src/commands.h
index a09858d050d..be6f5823bcc 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -27,7 +27,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
27 calls to initial_define_key. These should *not* be used after 27 calls to initial_define_key. These should *not* be used after
28 initialization; use-global-map doesn't affect these; it sets 28 initialization; use-global-map doesn't affect these; it sets
29 current_global_map instead. */ 29 current_global_map instead. */
30extern Lisp_Object global_map;
31extern Lisp_Object meta_map; 30extern Lisp_Object meta_map;
32extern Lisp_Object control_x_map; 31extern Lisp_Object control_x_map;
33 32
diff --git a/src/emacs.c b/src/emacs.c
index fe8dcb1c476..3c293d85edd 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1957,10 +1957,8 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1957#endif 1957#endif
1958 1958
1959 keys_of_casefiddle (); 1959 keys_of_casefiddle ();
1960 keys_of_cmds ();
1961 keys_of_buffer (); 1960 keys_of_buffer ();
1962 keys_of_keyboard (); 1961 keys_of_keyboard ();
1963 keys_of_keymap ();
1964 keys_of_window (); 1962 keys_of_window ();
1965 } 1963 }
1966 else 1964 else
diff --git a/src/keyboard.c b/src/keyboard.c
index cf15cd73572..52d913c537d 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -12388,10 +12388,8 @@ syms_of_keyboard_for_pdumper (void)
12388void 12388void
12389keys_of_keyboard (void) 12389keys_of_keyboard (void)
12390{ 12390{
12391 initial_define_key (global_map, Ctl ('Z'), "suspend-emacs");
12392 initial_define_key (control_x_map, Ctl ('Z'), "suspend-emacs"); 12391 initial_define_key (control_x_map, Ctl ('Z'), "suspend-emacs");
12393 initial_define_key (meta_map, Ctl ('C'), "exit-recursive-edit"); 12392 initial_define_key (meta_map, Ctl ('C'), "exit-recursive-edit");
12394 initial_define_key (global_map, Ctl (']'), "abort-recursive-edit");
12395 initial_define_key (meta_map, 'x', "execute-extended-command"); 12393 initial_define_key (meta_map, 'x', "execute-extended-command");
12396 12394
12397 initial_define_lispy_key (Vspecial_event_map, "delete-frame", 12395 initial_define_lispy_key (Vspecial_event_map, "delete-frame",
diff --git a/src/keymap.c b/src/keymap.c
index 1eeea81f627..772ced42ccd 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -59,8 +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 62Lisp_Object meta_map; /* The keymap used for globally bound
65 ESC-prefixed default commands. */ 63 ESC-prefixed default commands. */
66 64
@@ -3195,11 +3193,7 @@ syms_of_keymap (void)
3195 Each one is the value of a Lisp variable, and is also 3193 Each one is the value of a Lisp variable, and is also
3196 pointed to by a C variable */ 3194 pointed to by a C variable */
3197 3195
3198 global_map = Fmake_keymap (Qnil); 3196 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); 3197 staticpro (&current_global_map);
3204 3198
3205 meta_map = Fmake_keymap (Qnil); 3199 meta_map = Fmake_keymap (Qnil);
@@ -3328,10 +3322,3 @@ be preferred. */);
3328 defsubr (&Swhere_is_internal); 3322 defsubr (&Swhere_is_internal);
3329 defsubr (&Sdescribe_buffer_bindings); 3323 defsubr (&Sdescribe_buffer_bindings);
3330} 3324}
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}
diff --git a/src/keymap.h b/src/keymap.h
index 072c09348e2..1967025dcb4 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -40,7 +40,6 @@ extern ptrdiff_t current_minor_maps (Lisp_Object **, Lisp_Object **);
40extern void initial_define_key (Lisp_Object, int, const char *); 40extern void initial_define_key (Lisp_Object, int, const char *);
41extern void initial_define_lispy_key (Lisp_Object, const char *, const char *); 41extern void initial_define_lispy_key (Lisp_Object, const char *, const char *);
42extern void syms_of_keymap (void); 42extern void syms_of_keymap (void);
43extern void keys_of_keymap (void);
44 43
45typedef void (*map_keymap_function_t) 44typedef void (*map_keymap_function_t)
46 (Lisp_Object key, Lisp_Object val, Lisp_Object args, void *data); 45 (Lisp_Object key, Lisp_Object val, Lisp_Object args, void *data);
diff --git a/src/lisp.h b/src/lisp.h
index 5cc735be86c..d259e950dab 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3561,7 +3561,6 @@ extern void swap_in_global_binding (struct Lisp_Symbol *);
3561 3561
3562/* Defined in cmds.c */ 3562/* Defined in cmds.c */
3563extern void syms_of_cmds (void); 3563extern void syms_of_cmds (void);
3564extern void keys_of_cmds (void);
3565 3564
3566/* Defined in coding.c. */ 3565/* Defined in coding.c. */
3567extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t, 3566extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t,
diff --git a/src/window.c b/src/window.c
index ba8682eed7c..f2862a287d6 100644
--- a/src/window.c
+++ b/src/window.c
@@ -8590,7 +8590,6 @@ keys_of_window (void)
8590 initial_define_key (control_x_map, '<', "scroll-left"); 8590 initial_define_key (control_x_map, '<', "scroll-left");
8591 initial_define_key (control_x_map, '>', "scroll-right"); 8591 initial_define_key (control_x_map, '>', "scroll-right");
8592 8592
8593 initial_define_key (global_map, Ctl ('V'), "scroll-up-command");
8594 initial_define_key (meta_map, Ctl ('V'), "scroll-other-window"); 8593 initial_define_key (meta_map, Ctl ('V'), "scroll-other-window");
8595 initial_define_key (meta_map, 'v', "scroll-down-command"); 8594 initial_define_key (meta_map, 'v', "scroll-down-command");
8596} 8595}