Keymaps
*******

The bindings between keyboard input and commands are recorded in data structures called keymaps.  Each binding in a keymap associates (or binds) an individual character either with another keymap or with a command.  When a character is bound to a keymap, that keymap is used to look up the next character typed; this continues until a command is found.  This process is called key lookup.

Keymaps: Terminology
====================

A keymap is a table mapping characters to definitions (which can be any Lisp objects, though only certain types are meaningful for execution by the command loop).  Given a character and a keymap, Emacs can get the character's definition.

A sequence of keyboard input characters that form a unit is called a key sequence, or key for short.  A sequence of one character is always a key sequence, and so are some multicharacter sequences.

A keymap determines a binding or definition for any key sequence.  If the key sequence is a single character, its binding is the definition of the character in the keymap.  The binding of a multicharacter key sequence is found by an iterative process: the binding of the first character is found, and must be a keymap; then the second character's binding is found in that keymap, and so on until all the characters in the key sequence are used up.

If the binding of a key sequence is a keymap, we call the key sequence a prefix key.  Otherwise, we call it a complete key (because no more characters can be added to it).  If the binding is nil, we call the key undefined.  Examples of prefix keys are C-c, C-x, and C-x 4.  Examples of defined complete keys are X, RET, and C-x 4 C-f.  Examples of undefined complete keys are C-x C-g, and C-c 3.  See Prefix Keys, for more details.

The rule for finding the binding of a key sequence assumes that the intermediate bindings (found for the characters before the last) are all keymaps; if this is not so, the sequence of characters does not form a unit---it is not really a key sequence.  In other words, removing one or more characters from the end of any key must always yield a prefix key. For example, C-f C-f is not a key; C-f is not a prefix key, so a longer sequence starting with C-f cannot be a key.  Note that the set of possible multicharacter key sequences depends on the bindings for prefix keys; therefore, it can be different for different keymaps, and can change when bindings are changed.  However, a one-character sequence is always a key sequence, because it does not depend on any prefix keys for its validity.

At any time, two primary keymaps are in use for finding key bindings: the global map, which is shared by all buffers, and the local keymap, which is usually associated with a specific major mode.  The local keymap bindings shadow (i.e., take precedence over) the corresponding global bindings.  See Global and Local Keymaps, for details.

Creating Keymaps
================

A keymap can be represented as one of two kinds of Lisp object: a vector or a list.  A full keymap is a vector of length 128.  The binding for a character in such a keymap is found by indexing into the vector with the character as the index.

A sparse keymap is a list whose CAR is the symbol keymap, and whose remaining elements are cons cells of the form (CHAR . BINDING).  It is called a sparse keymap because it stores only the entries which are significant.  Use a sparse keymap when you expect only a few entries.  (define-key automatically creates sparse keymaps for intermediate keymaps.)

Keymaps record directly only character codes less than 128; they are unable to handle directly the META characters, whose codes are from 128 to 255.  Instead, META characters are regarded for purposes of key lookup as sequences of two characters, the first of which is ESC (the usual value of meta-prefix-char).  Thus, the key M-a is really represented as ESC a, and its global binding is found at the slot for a in esc-map.

Here as an example is the local keymap for Lisp mode, a sparse keymap. It defines C-c C-l as the run-lisp command, M-C-q as indent-sexp, and M-C-x as lisp-send-defun.

     lisp-mode-map
     =>
     (keymap
      (9 . lisp-indent-line)                 ; TAB
      (127 . backward-delete-char-untabify)  ; DEL
      (3 keymap
         (12 . run-lisp))                    ; C-c C-l
      (27 keymap
          (17 . indent-sexp)                 ; M-C-q, treated as ESC C-q
          (24 . lisp-send-defun)))           ; M-C-x, treated as ESC C-x

 -- Function: keymapp object
     This function returns t if OBJECT is a keymap, nil otherwise.  A keymap is either a vector of length 128, or a list with the form (keymap PAIRS...), where PAIRS stands for a series of associations, cons cells of the form (CHAR . BINDING).

          (keymapp '(keymap))
              => t
          (keymapp (current-global-map))
              => t

 -- Function: make-keymap
     This function creates and returns a new full keymap (i.e., a vector of length 128).  All entries in the keymap are nil, which means that no characters are defined.

          (make-keymap)
              => [nil nil nil ... nil nil]

 -- Function: make-sparse-keymap
     This function creates and returns a new sparse keymap with no entries. In this keymap, no characters are defined.

          (make-sparse-keymap)
              => (keymap)

 -- Function: copy-keymap keymap
     This function returns a copy of KEYMAP.  Any keymaps which appear directly as bindings in KEYMAP are also copied recursively, and so on to any number of levels.  However, recursive copying does not take place when the definition of a character is a symbol whose function definition is a keymap; the same symbol appears in the new copy.

          (setq map (copy-keymap (current-local-map)))
          => (keymap
               (27 keymap         ; (This implements META characters.)
                 (83 . center-paragraph)
                 (115 . center-line))
               (9 . tab-to-tab-stop))

          (eq map (current-local-map))
              => nil
          (equal map (current-local-map))
              => t

Key Lookup
==========

Key lookup is the process of finding the binding of a key sequence from a given keymap.  Actual execution of the definition is not part of key lookup.

When the key sequence consists of multiple characters, the characters are handled sequentially: the binding of the first character is found, and must be a keymap; then the second character's binding is found in that keymap, and so on until all the characters in the key sequence are used up.  (The binding thus found for the last character may or may not be a keymap.)  Thus, the process of key lookup is defined in terms of a simpler process for looking up a single character in a keymap.  How this is done depends on the type of object associated with the character in that keymap.

The value directly associated with a character in a keymap is called a keymap entry.  While any Lisp object may be stored in a keymap entry, only a few types of object make sense for key lookup.  Here is a list of them, and what they mean:

nil
     nil means that the characters used so far in the lookup form an undefined key.  When a sparse keymap fails to mention a character, that is equivalent to an entry of nil.

KEYMAP
     The characters used so far in the lookup form a prefix key.  The next character of the key sequence is looked up in KEYMAP, which may be full or sparse.

COMMAND
     The characters used so far in the lookup form a complete key, and COMMAND is its definition.

STRING
     STRING represents a keyboard macro.  The characters used so far in the lookup form a complete key, and STRING is its definition. (See Keyboard Macros, for more information.)

LIST
     The meaning of a list depends on the types of the elements of the list.

       * If the CAR of LIST is the symbol keymap, then the list is a sparse keymap, and is treated as a keymap (see above).

       * If the CAR of LIST is lambda, then the list is a lambda expression.  This is presumed to be a command, and is treated as such (see above).

       * If the CAR of LIST is a keymap and the CDR is a character, then this entry is an indirection to a slot in the other keymap.  When an indirect entry is found in key lookup, it is immediately replaced by the entry in the specified keymap for the specified character.  This permits you to define one key as an alias for another key.  For example, an entry whose CAR is the keymap called esc-map and whose CDR is 32 (the code for space) means, ``Use the global definition of Meta-SPC, whatever that may be.''

SYMBOL
     The function definition of SYMBOL is used in place of SYMBOL.  If that too is a symbol, then this process is repeated, any number of times.  Ultimately this should lead to a definition which is a keymap, a command or a string.  A list is allowed if it is a keymap or a command, but indirect entries are not understood when found via symbols.

     Note that keymaps and strings are not valid functions, so a symbol with a keymap or string as its function definition is likewise not valid as a function.  It is, however, valid as a key binding.  If the definition is a string, then the symbol is also valid as an argument to command-execute (see Interactive Call).

     The symbol undefined is worth special mention: it means to treat the key as undefined.  Strictly speaking, the key is defined, and its definition is the symbol undefined, but that command does the same thing that is done automatically for an undefined key: it rings the bell (by calling ding) but does not signal an error.

     undefined is used in local keymaps to override a global key binding and make the key undefined locally.  A local binding of nil would fail to do this because it would not override the global binding.

ANYTHING ELSE
     If any other type of object is found, the characters used so far in the lookup form a complete key, and the object is its definition.

In short, a keymap entry may be a keymap, a command, a string, a symbol which leads to one of them, or an indirection or nil. Here is an example of a sparse keymap with two characters bound to commands and one bound to another keymap.  This map is the normal value of emacs-lisp-mode-map.  Note that 9 is the code for TAB, 127 for DEL, 27 for ESC, 17 for C-q and 24 for C-x.

     (keymap (9 . lisp-indent-line)
             (127 . backward-delete-char-untabify)
             (27 keymap (17 . indent-sexp) (24 . eval-defun)))

Functions for Key Lookup
========================

Here are the functions and variables pertaining to key lookup.

 -- Function: lookup-key keymap key
     This function returns the definition of KEY in KEYMAP.  If the string KEY is not a valid key sequence according to the prefix keys specified in KEYMAP (which means it is ``too long'' and has extra characters at the end), then the value is a number, the number of characters at the front of KEY that compose a complete key.

     All the other functions described in this chapter that look up keys use lookup-key.

          (lookup-key (current-global-map) "\C-x\C-f")
              => find-file
          (lookup-key (current-global-map) "\C-x\C-f12345")
              => 2

     If KEY contains a meta-character, that character is implicitly replaced by a two-character sequence: the value of meta-prefix-char, followed by the corresponding non-meta character.  Thus, the first example below is handled by conversion into the second example.

          (lookup-key (current-global-map) "\M-f")
              => forward-word
          (lookup-key (current-global-map) "\ef")
              => forward-word

     This function does not perform automatic downcasing like that of read-key-sequence (see Keyboard Input).

 -- Command: undefined
     Used in keymaps to undefine keys.  It calls ding, but does not cause an error.

 -- Variable: meta-prefix-char
     This variable is the meta-prefix character code.  It is used when translating a meta-character to a two-character sequence so it can be looked up in a keymap.  For useful results, the value should be a prefix character (see Prefix Keys).  The default value is 27, which is the ASCII code for ESC.

     As long as the value of meta-prefix-char remains 27, key lookup translates M-b into ESC b, which is normally defined as the backward-word command.  However, if you set meta-prefix-char to 24, the code for C-x, then Emacs will translate M-b into C-x b, and call the switch-to-buffer command.

          meta-prefix-char                    ; The default value.
               => 27
          (key-binding "\M-b")
               => backward-word
          ?\C-x                               ; The print representation
               => 24                          ; of a character.
          (setq meta-prefix-char 24)
               => 24
          (key-binding "\M-b")
               => switch-to-buffer            ; Now, typing M-b is
                                              ; like typing C-x b.

          (setq meta-prefix-char 27)          ; Avoid confusion!
               => 27                          ; Restore the default value!

Prefix Keys
===========

A prefix key has an associated keymap which defines what to do with key sequences that start with the prefix key.  For example, ctl-x-map is the keymap used for characters following the prefix key C-x.  Here is a list of the standard prefix keys of Emacs and their keymaps:

  * ctl-x-map is the variable name for the map used for characters that follow C-x.  This map is also the function definition of Control-X-prefix.

  * ctl-x-4-map used is for characters that follow C-x 4.

  * esc-map is used for characters that follow ESC.  Thus, the global definitions of all Meta characters are actually found here.  This map is also the function definition of ESC-prefix.

  * help-map is used for characters that follow C-h.

  * mode-specific-map is for characters that follow C-c.  This map is not actually mode specific; its name was chosen to be informative for the user in C-h b (display-bindings), where it describes the main use of the C-c prefix key.

The binding of a prefix key is the keymap to use for looking up the characters that follow the prefix key.  (It may instead be a symbol whose function definition is a keymap.  The effect is the same, but the symbol serves as a name for the prefix key.)  Thus, the binding of C-x is the symbol Control-X-prefix, whose function definition is the keymap for C-x commands.  This keymap is also the value of ctl-x-map.

Prefix key definitions of this sort can appear in either the global map or a local map.  The definitions of C-c, C-x, C-h and ESC as prefix keys appear in the global map, so these prefix keys are always available.  Major modes can locally redefine a key as a prefix by putting a prefix key definition for it in the local map.

If a key is defined as a prefix in both the local map and the global, the two definitions are effectively merged: the commands defined in the local map's prefix definition take priority; those not defined there are taken from the global map.

In the following example, C-p is made a prefix key in the local keymap (so that C-p is identical to C-x).  Then the binding for C-p C-f is the function find-file, just like C-x C-f.  The key sequence C-p 6 is not found in either the local map or global map.

     (use-local-map (make-sparse-keymap))
         => nil
     (local-set-key "\C-p" ctl-x-map)
         => nil
     (key-binding "\C-p\C-f")
         => find-file

     (key-binding "\C-p6")
         => nil

 -- Function: define-prefix-command symbol
     This function defines SYMBOL as a prefix command: it creates a full keymap and stores it as SYMBOL's function definition. Storing the symbol as the binding of a key makes the key a prefix key which has a name.  This function returns SYMBOL.

     It is convenient to store the keymap as the value of a variable as well.  In version 19, this function stores the keymap in both the function definition and value of SYMBOL.  However, in version 18, only the function definition of SYMBOL is set, not the value.

Global and Local Keymaps
========================

The global keymap holds the bindings of keys that are defined regardless of the current buffer, such as C-f.  The variable global-map holds this keymap.

Each buffer may have another keymap, its local keymap, which may contain new or overriding definitions for keys.  Each buffer records which local keymap is used with it.

Both the global and local keymaps are used to determine what command to execute when a key is entered.  The key lookup proceeds as described earlier (see Key Lookup), but Emacs first searches for the key in the local map; if Emacs does not find a local definition, Emacs then searches the global map.

Since every buffer that uses the same major mode normally uses the very same local keymap, it may appear as if the keymap is local to the mode.  A change to the local keymap of a buffer (using local-set-key, for example) will be seen also in the other buffers that share that keymap.

The local keymaps that are used for Lisp mode, C mode, and several other major modes exist even if they have not yet been used.  These local maps are the values of the variables lisp-mode-map, c-mode-map, and so on.  For most other modes, which are less frequently used, the local keymap is constructed only when the mode is used for the first time in a session.

The minibuffer has local keymaps, too; they contain various completion and exit commands.  See Minibuffers.

See Standard Keymaps, for a list of standard keymaps.

 -- Variable: global-map
     This variable contains the default global keymap that maps Emacs keyboard input to commands.  Normally this keymap is the global keymap. The default global keymap is a full keymap that binds self-insert-command to all of the printing characters.

 -- Function: current-global-map
     This function returns the current global keymap.  Normally, this is the same as the value of the global-map.

          (current-global-map)
          => [set-mark-command beginning-of-line ... delete-backward-char]

 -- Function: current-local-map
     This function returns the current buffer's local keymap, or nil if it has none.  In the following example, the keymap for the *scratch* buffer (using Lisp Interaction mode) is a sparse keymap in which the entry for ESC, ASCII code 27, is another sparse keymap.

          (current-local-map)
          => (keymap
              (10 . eval-print-last-sexp)
              (9 . lisp-indent-line)
              (127 . backward-delete-char-untabify)
              (27 keymap
                  (24 . eval-defun)
                  (17 . indent-sexp)))

 -- Function: use-global-map keymap
     This function makes KEYMAP the new current global keymap. The KEYMAP map must be a full keymap (a vector of length 128).  It returns nil.

     It is very unusual to change the global keymap.

 -- Function: use-local-map keymap
     This function makes KEYMAP the new current local keymap of the current buffer.  If KEYMAP is nil, then there will be no local keymap.  It returns nil.  Most major modes use this function.

 -- Function: key-binding key
     This function returns the definition for KEY in the current keymaps trying the current buffer's local map and then the global map. The result is nil if KEY is undefined in the keymaps.

     An error is signaled if KEY is not a string.

          (key-binding "\C-x\C-f")
              => find-file

 -- Function: local-key-binding key
     This function returns the definition for KEY in the current local keymap, or nil if it is undefined there.

 -- Function: global-key-binding key
     This function returns the definition for command KEY in the current global keymap, or nil if it is undefined there.

Changing Key Bindings
=====================

The way to rebind a key is to change its entry in a keymap.  You can change the global keymap, so that the change is effective in all buffers (except those that override the global definition with a local one).  Or you can change the current buffer's local map, which usually affects all buffers using the same major mode.  The global-set-key and local-set-key functions are convenient interfaces for these operations.  Or you can change bindings in any map by specifying it explicitly in define-key.

People often use global-set-key in their .emacs file for simple customization.  For example,

     (global-set-key "\C-x\C-\\" 'next-line)

redefines C-x C-\ to move down a line.

In writing the string for the key sequence to rebind, it is useful to use the special escape sequences for control and meta characters (see String Type).  In a string, the syntax \C- means that the following character is a control character and \M- means that the following character is a META character.  Thus, the string "\M-x" is read as containing a single M-x, "\C-f" is read as containing a single C-f, and "\M-\C-x" and "\C-\M-x" are both read as containing a single C-M-x.

For the functions below, an error is signaled if KEYMAP is not a keymap or if KEY is not a string representing a key sequence.

 -- Function: define-key keymap key definition
     This function sets the binding for KEY in KEYMAP.  (If KEY is more than one character long, the change is actually made in another keymap reached from KEYMAP.)  The argument DEFINITION can be any Lisp object, but only certain types are meaningful.  (For a list of meaningful types, see Key Lookup.) The value returned by define-key is DEFINITION.

     Every prefix of KEY must be a prefix key (i.e., bound to a keymap) or undefined; otherwise an error is signaled (with data (error "Key sequence KEY uses invalid prefix characters")). If some prefix of KEY is undefined, then define-key defines it as a prefix key so that the rest of KEY may be defined as specified.

     In the following example, a sparse keymap is created and a number of bindings are added to it.

          (setq map (make-sparse-keymap))
              => (keymap)
          (define-key map "\C-f" 'forward-char)
              => forward-char
          map
              => (keymap (6 . forward-char))

          ;; Build sparse submap for C-x and bind f in that.
          (define-key map "\C-xf" 'forward-word)
              => forward-word

          map
          => (keymap
              (24 keymap                ; C-x
                  (102 . forward-word)) ;      f
              (6 . forward-char))       ; C-f

          ;; Bind C-p to the ctl-x-map.
          (define-key map "\C-p" ctl-x-map)
          => [nil ...  find-file ... backward-kill-sentence] ; ctl-x-map

          ;; Bind C-f to foo in the ctl-x-map.
          (define-key map "\C-p\C-f" 'foo)
          => 'foo
          map
          => (keymap     ; Note foo in ctl-x-map.
              (16 . [nil ...  foo ... backward-kill-sentence])
              (24 keymap
                  (102 . forward-word))
              (6 . forward-char))

     Note that storing a new binding for C-p C-f actually works by changing an entry in ctl-x-map, and this has the effect of changing the bindings of both C-p C-f and C-x C-f in the default global map.

 -- Function: substitute-key-definition olddef newdef keymap
     This function replaces OLDDEF with NEWDEF for any keys in KEYMAP that were bound to OLDDEF.  In other words, OLDDEF is replaced with NEWDEF wherever it appears.  It returns nil.

     Prefix keymaps that appear within KEYMAP are not checked recursively for keys bound to OLDDEF; they are not changed at all. Perhaps it would be better to check nested keymaps recursively.

          (setq map '(keymap
                      (?1 . olddef-1)
                      (?2 . olddef-2)
                      (?3 . olddef-1)))
          => (keymap (49 . olddef-1) (50 . olddef-2) (51 . olddef-1))

          (substitute-key-definition 'olddef-1 'newdef map)
          => nil
          map
          => (keymap (49 . newdef) (50 . olddef-2) (51 . newdef))

          ;; The following will redefine C-x C-f, if you do it in an
          ;; Emacs with standard bindings.

          (substitute-key-definition
           'find-file 'find-file-read-only (current-global-map))

 -- Function: suppress-keymap keymap &optional nodigits
     This function changes the contents of the full keymap KEYMAP by replacing the self-insertion commands for numbers with the digit-argument function, unless NODIGITS is non-nil, and by replacing the functions for the rest of the printing characters with undefined.  This means that ordinary insertion of text is impossible in a buffer with a local keymap on which suppress-keymap has been called.

     suppress-keymap returns nil.

     The suppress-keymap function does not make it impossible to modify a buffer, as it does not suppress commands such as yank and quote-insert.  To prevent any modification of a buffer, make it read-only (see Read Only Buffers).

     Since this function modifies KEYMAP, you would normally use it on a newly created keymap.  Operating on an existing keymap that is used for some other purpose is likely to cause trouble; for example, suppressing global-map would make it impossible to use most of Emacs.

     Most often, suppress-keymap is used for initializing local keymaps of modes such as Rmail and Dired where insertion of text is not desirable and the buffer is read-only.  Here is an example taken from the file emacs/lisp/dired.el, showing how the local keymap for Dired mode is set up:

            ...
            (setq dired-mode-map (make-keymap))
            (suppress-keymap dired-mode-map)
            (define-key dired-mode-map "r" 'dired-rename-file)
            (define-key dired-mode-map "\C-d" 'dired-flag-file-deleted)
            (define-key dired-mode-map "d" 'dired-flag-file-deleted)
            (define-key dired-mode-map "v" 'dired-view-file)
            (define-key dired-mode-map "e" 'dired-find-file)
            (define-key dired-mode-map "f" 'dired-find-file)
            ...

Commands for Binding Keys
=========================

This section describes some convenient interactive interfaces for changing key bindings.  They work by calling define-key.

 -- Command: global-set-key key definition
     This function sets the binding of KEY in the current global map to DEFINITION.

          (global-set-key KEY DEFINITION)
          ==
          (define-key (current-global-map) KEY DEFINITION)

 -- Command: global-unset-key key
     This function removes the binding of KEY from the current global map.

     One use of this function is in preparation for defining a longer key which uses it implicitly as a prefix---which would not be allowed otherwise.  For example:

          (global-unset-key "\C-l")
              => nil
          (global-set-key "\C-l\C-l" 'redraw-display)
              => nil

     This function is implemented simply using define-key:

          (global-unset-key KEY)
          ==
          (define-key (current-global-map) KEY nil)

 -- Command: local-set-key key definition
     This function sets the binding of KEY in the current local keymap to DEFINITION.

          (local-set-key KEY DEFINITION)
          ==
          (define-key (current-local-map) KEY DEFINITION)

 -- Command: local-unset-key key
     This function removes the binding of KEY from the current local map.

          (local-unset-key KEY)
          ==
          (define-key (current-local-map) KEY nil)

Scanning Keymaps
================

This section describes functions used to scan all the current keymaps for the sake of printing help information.

 -- Function: accessible-keymaps keymap
     This function returns a list of all the keymaps that can be accessed (via prefix keys) from KEYMAP.  The list returned is an association list with elements of the form (KEY . MAP), where KEY is a prefix whose definition in KEYMAP is MAP.

     The elements of the alist are ordered so that the KEY increases in length.  The first element is always ("" . KEYMAP), because the specified keymap is accessible from itself with a prefix of no characters.

     In the example below, the returned alist indicates that the key ESC, which is displayed as "^[", is a prefix key whose definition is the sparse keymap (keymap (83 . center-paragraph) (115 . foo)).

          (accessible-keymaps (current-local-map))
          =>(("" keymap
                (27 keymap   ; Note this keymap for ESC is repeated below.
                    (83 . center-paragraph)
                    (115 . center-line))
                (9 . tab-to-tab-stop))

             ("^[" keymap
              (83 . center-paragraph)
              (115 . foo)))

     In the following example, C-h is a prefix key that uses a sparse keymap starting (118 . describe-variable) ....  Another prefix, C-x 4, uses the full keymap beginning [nil ...] (which happens to be ctl-x-4-map).

          (accessible-keymaps (current-global-map))
          => (("" . [set-mark-command beginning-of-line ...
                        delete-backward-char])
              ("^C" keymap (13 . x-flush-mouse-queue))
              ("^H" keymap (118 . describe-variable) ... (8 . help-for-help))
              ("^X" . [x-flush-mouse-queue  ... backward-kill-sentence])
              ("^[" . [mark-sexp backward-sexp ... backward-kill-word])
              ("^X4" . [nil ... find-file-other-window nil ... nil nil]))

 -- Function: where-is-internal command &optional keymap firstonly
     This function returns a list of key sequences (of any length) that are bound to COMMAND in KEYMAP and the global keymap.  The argument COMMAND can be any object; it is compared with all keymap entries using eq.  If KEYMAP is not supplied, then the global map alone is used.

     If FIRSTONLY is non-nil, then the value is a single string representing the first key sequence found, rather than a list of all possible key sequences.

     This function is used by where-is (see Help (The GNU Emacs Manual)).

          (where-is-internal 'describe-function)
              => ("\^hf" "\^hd")

 -- Command: describe-bindings
     This function creates a listing of all defined keys, and their definitions.  The listing is put in a buffer named *Help*, which is then displayed in a window.

     A meta character is shown as ESC followed by the corresponding non-meta character.  Control characters are indicated with C-.

     When several consecutive characters have the same definition, they are shown together, as FIRSTCHAR..LASTCHAR.  In this instance, you need to know the ASCII codes to understand which characters this means.  For example, in the default global map, the characters SPC .. ~ are described by a single line. SPC is ASCII 32, ~ is ASCII 126, and the characters between them include all the normal printing characters, (e.g., letters, digits, punctuation, etc.); all these characters are bound to self-insert-command.