Function: which-key--propertize-key

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

Signature

(which-key--propertize-key KEY)

Documentation

Add a face to KEY.

If KEY contains any "special keys" defined in which-key-special-keys then truncate and add the corresponding which-key-special-key-face.

Source Code

;; Defined in /usr/src/emacs/lisp/which-key.el.gz
(defun which-key--propertize-key (key)
  "Add a face to KEY.
If KEY contains any \"special keys\" defined in
`which-key-special-keys' then truncate and add the corresponding
`which-key-special-key-face'."
  (let ((key-w-face (which-key--propertize key 'face 'which-key-key-face))
        (regexp (concat "\\("
                        (mapconcat #'identity which-key-special-keys
                                   "\\|")
                        "\\)"))
        (case-fold-search nil))
    (save-match-data
      (if (and which-key-special-keys
               (string-match regexp key))
          (let ((beg (match-beginning 0)) (end (match-end 0)))
            (concat (substring key-w-face 0 beg)
                    (which-key--propertize (substring key-w-face beg (1+ beg))
                                           'face 'which-key-special-key-face)
                    (substring key-w-face end
                               (which-key--string-width key-w-face))))
        key-w-face))))