Function: which-key-add-keymap-based-replacements
which-key-add-keymap-based-replacements is an autoloaded and
byte-compiled function defined in which-key.el.gz.
Signature
(which-key-add-keymap-based-replacements KEYMAP KEY REPLACEMENT &rest MORE)
Documentation
Replace the description of KEY using REPLACEMENT in KEYMAP.
KEY should take a format suitable for use in kbd. REPLACEMENT
should be a cons cell of the form (STRING . COMMAND) for each
REPLACEMENT, where STRING is the replacement string and COMMAND
is a symbol corresponding to the intended command to be
replaced. COMMAND can be nil if the binding corresponds to a key
prefix. An example is
(which-key-add-keymap-based-replacements global-map
"C-x w" '("Save as" . write-file)).
For backwards compatibility, REPLACEMENT can also be a string, but the above format is preferred, and the option to use a string for REPLACEMENT will eventually be removed.
Source Code
;; Defined in /usr/src/emacs/lisp/which-key.el.gz
;;; Helper functions to modify replacement lists.
;;;###autoload
(defun which-key-add-keymap-based-replacements (keymap key replacement &rest more)
"Replace the description of KEY using REPLACEMENT in KEYMAP.
KEY should take a format suitable for use in `kbd'. REPLACEMENT
should be a cons cell of the form \(STRING . COMMAND\) for each
REPLACEMENT, where STRING is the replacement string and COMMAND
is a symbol corresponding to the intended command to be
replaced. COMMAND can be nil if the binding corresponds to a key
prefix. An example is
\(which-key-add-keymap-based-replacements global-map
\"C-x w\" \\='\(\"Save as\" . write-file\)\).
For backwards compatibility, REPLACEMENT can also be a string,
but the above format is preferred, and the option to use a string
for REPLACEMENT will eventually be removed."
(declare (indent defun))
(while key
(let ((def
(cond
((consp replacement) replacement)
((stringp replacement)
(cons replacement
(or (which-key--safe-lookup-key-description keymap key)
(make-sparse-keymap))))
(t
(user-error "Replacement is neither a cons cell or a string")))))
(define-key keymap (kbd key) def))
(setq key (pop more)
replacement (pop more))))