Function: which-key--maybe-replace

which-key--maybe-replace is a byte-compiled function defined in which-key.el.gz.

Signature

(which-key--maybe-replace KEY-BINDING)

Documentation

Use which-key-replacement-alist to maybe replace KEY-BINDING.

KEY-BINDING is a cons cell of the form (KEY . BINDING) each of which are strings. KEY is of the form produced by key-binding.

Source Code

;; Defined in /usr/src/emacs/lisp/which-key.el.gz
(defun which-key--maybe-replace (key-binding)
  "Use `which-key-replacement-alist' to maybe replace KEY-BINDING.
KEY-BINDING is a cons cell of the form \(KEY . BINDING\) each of
which are strings.  KEY is of the form produced by `key-binding'."
  (let* ((replacer (if which-key-allow-multiple-replacements
                       #'which-key--replace-in-repl-list-many
                     #'which-key--replace-in-repl-list-once)))
    (pcase
        (apply replacer
               (list key-binding
                     (cdr-safe (assq major-mode which-key-replacement-alist))))
      (`(replaced . ,repl)
       (if which-key-allow-multiple-replacements
           (pcase (apply replacer (list repl which-key-replacement-alist))
             (`(replaced . ,repl) repl)
             ('() repl))
         repl))
      ('()
       (pcase (apply replacer (list key-binding which-key-replacement-alist))
         (`(replaced . ,repl) repl)
         ('() key-binding))))))