Function: use-package-autoload-keymap

use-package-autoload-keymap is an autoloaded and byte-compiled function defined in use-package-bind-key.el.gz.

Signature

(use-package-autoload-keymap KEYMAP-SYMBOL PACKAGE OVERRIDE)

Documentation

Load PACKAGE and bind key sequence invoking this function to KEYMAP-SYMBOL.

Then simulate pressing the same key sequence a again, so that the next key pressed is routed to the newly loaded keymap.

This function supports use-package's :bind-keymap keyword. It works by binding the given key sequence to an invocation of this function for a particular keymap. The keymap is expected to be defined by the package. In this way, loading the package is deferred until the prefix key sequence is pressed.

Source Code

;; Defined in /usr/src/emacs/lisp/use-package/use-package-bind-key.el.gz
;;;###autoload
(defun use-package-autoload-keymap (keymap-symbol package override)
  "Load PACKAGE and bind key sequence invoking this function to KEYMAP-SYMBOL.
Then simulate pressing the same key sequence a again, so that the
next key pressed is routed to the newly loaded keymap.

This function supports use-package's :bind-keymap keyword.  It
works by binding the given key sequence to an invocation of this
function for a particular keymap.  The keymap is expected to be
defined by the package.  In this way, loading the package is
deferred until the prefix key sequence is pressed."
  (if (not (require package nil t))
      (use-package-error (format "Cannot load package.el: %s" package))
    (if (and (boundp keymap-symbol)
             (keymapp (symbol-value keymap-symbol)))
        (let* ((kv (this-command-keys-vector))
               (key (key-description kv))
               (keymap (symbol-value keymap-symbol)))
          (if override
              (bind-key* key keymap)
            (bind-key key keymap))
          (setq unread-command-events
                (mapcar (lambda (ev) (cons t ev))
                        (listify-key-sequence kv))))
      (use-package-error
       (format "package.el %s failed to define keymap %s"
               package keymap-symbol)))))