Function: keymap-set

keymap-set is a byte-compiled function defined in compat-29.el.

Signature

(keymap-set KEYMAP KEY DEFINITION)

Documentation

[Compatibility function for keymap-set, defined in Emacs 29.1. See (compat)
Emacs 29.1' for more details.]

Set KEY to DEFINITION in KEYMAP. KEY is a string that satisfies key-valid-p.

DEFINITION is anything that can be a key's definition: nil (means key is
 undefined in this keymap), a command (a Lisp function suitable for interactive
 calling), a string (treated as a keyboard macro), a keymap (to define a prefix
 key), a symbol (when the key is looked up, the symbol will stand for its
 function definition, which should at that time be one of the above, or another
 symbol whose function definition is used, etc.), a cons (STRING . DEFN),
 meaning that DEFN is the definition (DEFN should be a valid definition in its
 own right) and STRING is the menu item name (which is used only if the
 containing keymap has been created with a menu name, see make-keymap), or a
 cons (MAP . CHAR), meaning use definition of CHAR in keymap MAP, or an extended
 menu item definition. (See info node (elisp)Extended Menu Items.)

Source Code

;; Defined in ~/.emacs.d/elpa/compat-30.1.0.1/compat-29.el
(compat-defun keymap-set (keymap key definition) ;; <compat-tests:defvar-keymap>
  "Set KEY to DEFINITION in KEYMAP.
KEY is a string that satisfies `key-valid-p'.

DEFINITION is anything that can be a key's definition:
 nil (means key is undefined in this keymap),
 a command (a Lisp function suitable for interactive calling),
 a string (treated as a keyboard macro),
 a keymap (to define a prefix key),
 a symbol (when the key is looked up, the symbol will stand for its
    function definition, which should at that time be one of the above,
    or another symbol whose function definition is used, etc.),
 a cons (STRING . DEFN), meaning that DEFN is the definition
    (DEFN should be a valid definition in its own right) and
    STRING is the menu item name (which is used only if the containing
    keymap has been created with a menu name, see `make-keymap'),
 or a cons (MAP . CHAR), meaning use definition of CHAR in keymap MAP,
 or an extended menu item definition.
 (See info node `(elisp)Extended Menu Items'.)"
  (keymap--check key)
  (when (stringp definition)
    (keymap--check definition)
    (setq definition (key-parse definition)))
  (define-key keymap (key-parse key) definition))