Function: which-key-add-key-based-replacements
which-key-add-key-based-replacements is an autoloaded and
byte-compiled function defined in which-key.el.gz.
Signature
(which-key-add-key-based-replacements KEY-SEQUENCE REPLACEMENT &rest MORE)
Documentation
Replace the description of KEY-SEQUENCE with REPLACEMENT.
KEY-SEQUENCE is a string suitable for use in kbd.
REPLACEMENT may either be a string, as in
(which-key-add-key-based-replacements "C-x 1" "maximize")
a cons of two strings as in
(which-key-add-key-based-replacements "C-x 8"
'("unicode" . "Unicode keys"))
or a function that takes a (KEY . BINDING) cons and returns a replacement.
In the second case, the second string is used to provide a longer name for the keys under a prefix.
MORE allows you to specify additional KEY REPLACEMENT pairs. All
replacements are added to which-key-replacement-alist.
Source Code
;; Defined in /usr/src/emacs/lisp/which-key.el.gz
;;;###autoload
(defun which-key-add-key-based-replacements
(key-sequence replacement &rest more)
"Replace the description of KEY-SEQUENCE with REPLACEMENT.
KEY-SEQUENCE is a string suitable for use in `kbd'.
REPLACEMENT may either be a string, as in
\(which-key-add-key-based-replacements \"C-x 1\" \"maximize\"\)
a cons of two strings as in
\(which-key-add-key-based-replacements \"C-x 8\"
\\='(\"unicode\" . \"Unicode keys\")\)
or a function that takes a \(KEY . BINDING\) cons and returns a
replacement.
In the second case, the second string is used to provide a longer
name for the keys under a prefix.
MORE allows you to specify additional KEY REPLACEMENT pairs. All
replacements are added to `which-key-replacement-alist'."
;; TODO: Make interactive
(while key-sequence
;; normalize key sequences before adding
(let ((key-seq (key-description (kbd key-sequence)))
(replace (or (and (functionp replacement) replacement)
(car-safe replacement)
replacement)))
(push (cons (cons (concat "\\`" (regexp-quote key-seq) "\\'") nil)
(if (functionp replace) replace (cons nil replace)))
which-key-replacement-alist)
(when (and (not (functionp replacement)) (consp replacement))
(push (cons key-seq (cdr-safe replacement))
which-key--prefix-title-alist)))
(setq key-sequence (pop more) replacement (pop more))))