emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master d6f30e5 1/3: * lisp/subr.el (global-map): Initialize inside decla


From: Stefan Monnier
Subject: master d6f30e5 1/3: * lisp/subr.el (global-map): Initialize inside declaration.
Date: Mon, 4 Jan 2021 23:44:35 -0500 (EST)

branch: master
commit d6f30e5632b1c9cf43ebfbdbf164d5c54be33475
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * 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.
---
 lisp/subr.el   | 36 +++++++++++++++++++++++++++++++-----
 src/cmds.c     | 21 ---------------------
 src/commands.h |  1 -
 src/emacs.c    |  2 --
 src/keyboard.c |  2 --
 src/keymap.c   | 15 +--------------
 src/keymap.h   |  1 -
 src/lisp.h     |  1 -
 src/window.c   |  1 -
 9 files changed, 32 insertions(+), 48 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index 1acc3c3..6187f7a 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1242,11 +1242,6 @@ in a cleaner way with command remapping, like this:
 ;; global-map, esc-map, and ctl-x-map have their values set up in
 ;; keymap.c; we just give them docstrings here.
 
-(defvar global-map nil
-  "Default global keymap mapping Emacs keyboard input into commands.
-The value is a keymap that is usually (but not necessarily) Emacs's
-global map.")
-
 (defvar esc-map nil
   "Default keymap for ESC (meta) commands.
 The 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.")
   "Keymap for tab-bar related commands.")
 (define-key ctl-x-map "t" tab-prefix-map)
 
+(defvar global-map
+  (let ((map (make-keymap)))
+    (define-key map "\C-[" 'ESC-prefix)
+    (define-key map "\C-x" 'Control-X-prefix)
+
+    (define-key map "\C-i" #'self-insert-command)
+    (let* ((vec1 (make-vector 1 nil))
+           (f (lambda (from to)
+                (while (< from to)
+                  (aset vec1 0 from)
+                  (define-key map vec1 #'self-insert-command)
+                  (setq from (1+ from))))))
+      (funcall f #o040 #o0177)
+      (when (eq system-type 'ms-dos)      ;FIXME: Why?
+        (funcall f #o0200 #o0240))
+      (funcall f #o0240 #o0400))
+
+    (define-key map "\C-a" #'beginning-of-line)
+    (define-key map "\C-b" #'backward-char)
+    (define-key map "\C-e" #'end-of-line)
+    (define-key map "\C-f" #'forward-char)
+    (define-key map "\C-z" #'suspend-emacs) ;FIXME: Re-bound later!
+
+    (define-key map "\C-v" #'scroll-up-command)
+    (define-key map "\C-]" #'abort-recursive-edit)
+    map)
+  "Default global keymap mapping Emacs keyboard input into commands.
+The value is a keymap that is usually (but not necessarily) Emacs's
+global map.")
+(use-global-map global-map)
+
 
 ;;;; Event manipulation functions.
 
diff --git a/src/cmds.c b/src/cmds.c
index 798fd68..1547db8 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -529,24 +529,3 @@ This is run after inserting the character.  */);
   defsubr (&Sdelete_char);
   defsubr (&Sself_insert_command);
 }
-
-void
-keys_of_cmds (void)
-{
-  int n;
-
-  initial_define_key (global_map, Ctl ('I'), "self-insert-command");
-  for (n = 040; n < 0177; n++)
-    initial_define_key (global_map, n, "self-insert-command");
-#ifdef MSDOS
-  for (n = 0200; n < 0240; n++)
-    initial_define_key (global_map, n, "self-insert-command");
-#endif
-  for (n = 0240; n < 0400; n++)
-    initial_define_key (global_map, n, "self-insert-command");
-
-  initial_define_key (global_map, Ctl ('A'), "beginning-of-line");
-  initial_define_key (global_map, Ctl ('B'), "backward-char");
-  initial_define_key (global_map, Ctl ('E'), "end-of-line");
-  initial_define_key (global_map, Ctl ('F'), "forward-char");
-}
diff --git a/src/commands.h b/src/commands.h
index a09858d..be6f582 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/>.  */
    calls to initial_define_key.  These should *not* be used after
    initialization; use-global-map doesn't affect these; it sets
    current_global_map instead.  */
-extern Lisp_Object global_map;
 extern Lisp_Object meta_map;
 extern Lisp_Object control_x_map;
 
diff --git a/src/emacs.c b/src/emacs.c
index fe8dcb1..3c293d8 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
 #endif
 
       keys_of_casefiddle ();
-      keys_of_cmds ();
       keys_of_buffer ();
       keys_of_keyboard ();
-      keys_of_keymap ();
       keys_of_window ();
     }
   else
diff --git a/src/keyboard.c b/src/keyboard.c
index cf15cd7..52d913c 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -12388,10 +12388,8 @@ syms_of_keyboard_for_pdumper (void)
 void
 keys_of_keyboard (void)
 {
-  initial_define_key (global_map, Ctl ('Z'), "suspend-emacs");
   initial_define_key (control_x_map, Ctl ('Z'), "suspend-emacs");
   initial_define_key (meta_map, Ctl ('C'), "exit-recursive-edit");
-  initial_define_key (global_map, Ctl (']'), "abort-recursive-edit");
   initial_define_key (meta_map, 'x', "execute-extended-command");
 
   initial_define_lispy_key (Vspecial_event_map, "delete-frame",
diff --git a/src/keymap.c b/src/keymap.c
index 1eeea81..772ced4 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/>.  */
 
 Lisp_Object current_global_map;        /* Current global keymap.  */
 
-Lisp_Object global_map;                /* Default global key bindings.  */
-
 Lisp_Object meta_map;          /* The keymap used for globally bound
                                   ESC-prefixed default commands.  */
 
@@ -3195,11 +3193,7 @@ syms_of_keymap (void)
      Each one is the value of a Lisp variable, and is also
      pointed to by a C variable */
 
-  global_map = Fmake_keymap (Qnil);
-  Fset (intern_c_string ("global-map"), global_map);
-
-  current_global_map = global_map;
-  staticpro (&global_map);
+  current_global_map = Qnil;
   staticpro (&current_global_map);
 
   meta_map = Fmake_keymap (Qnil);
@@ -3328,10 +3322,3 @@ be preferred.  */);
   defsubr (&Swhere_is_internal);
   defsubr (&Sdescribe_buffer_bindings);
 }
-
-void
-keys_of_keymap (void)
-{
-  initial_define_key (global_map, 033, "ESC-prefix");
-  initial_define_key (global_map, Ctl ('X'), "Control-X-prefix");
-}
diff --git a/src/keymap.h b/src/keymap.h
index 072c093..1967025 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -40,7 +40,6 @@ extern ptrdiff_t current_minor_maps (Lisp_Object **, 
Lisp_Object **);
 extern void initial_define_key (Lisp_Object, int, const char *);
 extern void initial_define_lispy_key (Lisp_Object, const char *, const char *);
 extern void syms_of_keymap (void);
-extern void keys_of_keymap (void);
 
 typedef void (*map_keymap_function_t)
      (Lisp_Object key, Lisp_Object val, Lisp_Object args, void *data);
diff --git a/src/lisp.h b/src/lisp.h
index 5cc735b..d259e95 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3561,7 +3561,6 @@ extern void swap_in_global_binding (struct Lisp_Symbol *);
 
 /* Defined in cmds.c */
 extern void syms_of_cmds (void);
-extern void keys_of_cmds (void);
 
 /* Defined in coding.c.  */
 extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t,
diff --git a/src/window.c b/src/window.c
index ba8682e..f2862a2 100644
--- a/src/window.c
+++ b/src/window.c
@@ -8590,7 +8590,6 @@ keys_of_window (void)
   initial_define_key (control_x_map, '<', "scroll-left");
   initial_define_key (control_x_map, '>', "scroll-right");
 
-  initial_define_key (global_map, Ctl ('V'), "scroll-up-command");
   initial_define_key (meta_map, Ctl ('V'), "scroll-other-window");
   initial_define_key (meta_map, 'v', "scroll-down-command");
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]