Skip to content

Commit 94c2533

Browse files
nbarrientosWilfred
authored andcommitted
Use help-key-binding as face for keystrokes
1 parent 4a8d576 commit 94c2533

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

helpful.el

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,8 @@ vector suitable for `key-description', and COMMAND is a smbol."
980980
;; Text of the form \\[foo-command]
981981
(rx "\\[" (group (+ (not (in "]")))) "]")
982982
(lambda (it)
983-
(let* ((symbol-name (match-string 1 it))
983+
(let* ((button-face (if (>= emacs-major-version 28) 'help-key-binding 'button))
984+
(symbol-name (match-string 1 it))
984985
(symbol (intern symbol-name))
985986
(key (where-is-internal symbol keymap t))
986987
(key-description
@@ -991,7 +992,8 @@ vector suitable for `key-description', and COMMAND is a smbol."
991992
key-description
992993
'helpful-describe-exactly-button
993994
'symbol symbol
994-
'callable-p t)))
995+
'callable-p t
996+
'face button-face)))
995997
str
996998
t
997999
t))
@@ -1632,7 +1634,9 @@ Includes keybindings for aliases, unlike
16321634
(push
16331635
(format "%s %s"
16341636
(propertize map 'face 'font-lock-variable-name-face)
1635-
key)
1637+
(if (>= emacs-major-version 28)
1638+
(propertize key 'face 'help-key-binding)
1639+
key))
16361640
(if (eq map 'global-map) global-lines mode-lines)))))
16371641
(setq global-lines (-sort #'string< global-lines))
16381642
(setq mode-lines (-sort #'string< mode-lines))

test/helpful-unit-test.el

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,16 @@ symbol (not a form)."
293293
(get-text-property 0 'button formatted)))
294294
;; If we have quotes around a key sequence, we should not propertize
295295
;; it as the button styling will no longer be visible.
296-
(-let [formatted (helpful--format-docstring "`\\[set-mark-command]'")]
296+
(-let* ((emacs-major-version 28)
297+
(formatted (helpful--format-docstring "`\\[set-mark-command]'")))
298+
(should
299+
(string-equal formatted "C-SPC"))
300+
(should
301+
(eq
302+
(get-text-property 0 'face formatted)
303+
'help-key-binding)))
304+
(-let* ((emacs-major-version 27)
305+
(formatted (helpful--format-docstring "`\\[set-mark-command]'")))
297306
(should
298307
(string-equal formatted "C-SPC"))
299308
(should

0 commit comments

Comments
 (0)