helpful

a fork of Wilfred's helpful
git clone https://git.trogloxene.org/helpful.git
Log | Files | Refs | README

commit 94c25337b2de2f9da60914a7c0c6cca9584c0231
parent 4a8d5765c97bdd3103cc921d740b93bf3fc1c162
Author: Nacho Barrientos <nacho.barrientos@cern.ch>
Date:   Fri,  9 Dec 2022 09:45:57 +0100

Use help-key-binding as face for keystrokes

Diffstat:
Mhelpful.el | 10+++++++---
Mtest/helpful-unit-test.el | 11++++++++++-
2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/helpful.el b/helpful.el @@ -980,7 +980,8 @@ vector suitable for `key-description', and COMMAND is a smbol." ;; Text of the form \\[foo-command] (rx "\\[" (group (+ (not (in "]")))) "]") (lambda (it) - (let* ((symbol-name (match-string 1 it)) + (let* ((button-face (if (>= emacs-major-version 28) 'help-key-binding 'button)) + (symbol-name (match-string 1 it)) (symbol (intern symbol-name)) (key (where-is-internal symbol keymap t)) (key-description @@ -991,7 +992,8 @@ vector suitable for `key-description', and COMMAND is a smbol." key-description 'helpful-describe-exactly-button 'symbol symbol - 'callable-p t))) + 'callable-p t + 'face button-face))) str t t)) @@ -1632,7 +1634,9 @@ Includes keybindings for aliases, unlike (push (format "%s %s" (propertize map 'face 'font-lock-variable-name-face) - key) + (if (>= emacs-major-version 28) + (propertize key 'face 'help-key-binding) + key)) (if (eq map 'global-map) global-lines mode-lines))))) (setq global-lines (-sort #'string< global-lines)) (setq mode-lines (-sort #'string< mode-lines)) diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el @@ -293,7 +293,16 @@ symbol (not a form)." (get-text-property 0 'button formatted))) ;; If we have quotes around a key sequence, we should not propertize ;; it as the button styling will no longer be visible. - (-let [formatted (helpful--format-docstring "`\\[set-mark-command]'")] + (-let* ((emacs-major-version 28) + (formatted (helpful--format-docstring "`\\[set-mark-command]'"))) + (should + (string-equal formatted "C-SPC")) + (should + (eq + (get-text-property 0 'face formatted) + 'help-key-binding))) + (-let* ((emacs-major-version 27) + (formatted (helpful--format-docstring "`\\[set-mark-command]'"))) (should (string-equal formatted "C-SPC")) (should