diff --git a/lisp/which-key.el b/lisp/which-key.el index 1de599e5497..7d986b7cb05 100644 --- a/lisp/which-key.el +++ b/lisp/which-key.el @@ -239,12 +239,20 @@ which-key-highlighted-command-list :package-version "1.0" :version "30.1") (defcustom which-key-special-keys '() - "These keys will automatically be truncated to one character. + "These keys will be truncated to first character or provided unicode symbol. They also have `which-key-special-key-face' applied to them. This -is disabled by default. An example configuration is - -\(setq which-key-special-keys \\='(\"SPC\" \"TAB\" \"RET\" \"ESC\" \"DEL\")\)" - :type '(repeat string) +is disabled by default. Example configurations are + +\(setq which-key-special-keys \\='(\"SPC\" \"TAB\" \"RET\" \"ESC\" \"DEL\")\) OR + +\(setq which-key-special-keys + \\='((\"SPC\" . \"␣\") + (\"TAB\" . \"↹\") + (\"RET\" . \"⏎\") + (\"ESC\" . \"⎋\") + (\"DEL\" . \"⌦\") + (\"backspace\" . \"⌫\"))\)" + :type '(repeat (choice string cons)) :package-version "1.0" :version "30.1") (defcustom which-key-buffer-name " *which-key*" @@ -1686,7 +1694,10 @@ which-key--propertize-key `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 + (mapconcat #'identity + (if (consp (car which-key-special-keys)) + (mapcar #'car which-key-special-keys) + which-key-special-keys) "\\|") "\\)")) (case-fold-search nil)) @@ -1695,8 +1706,12 @@ which-key--propertize-key (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) + (which-key--propertize + (or (cdr + (assoc (substring key-w-face beg end) + which-key-special-keys #'string=)) + (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))))