mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 18:40:39 -08:00
Fix return value of help--key-description-fontified
This fixes a bug with warning about obsolete commands in `command-execute', where we incorrectly showed empty parenthesis instead of the empty string when there was no keybinding for the new command. * lisp/help.el (help--key-description-fontified): Return nil instead of the empty string if KEYS argument is nil. * test/lisp/help-tests.el (help--key-description-fontified): New test. (with-substitute-command-keys-test): Fix indentation.
This commit is contained in:
parent
935e4da0e1
commit
a936335aa0
2 changed files with 22 additions and 13 deletions
17
lisp/help.el
17
lisp/help.el
|
|
@ -566,13 +566,16 @@ To record all your input, use `open-dribble-file'."
|
||||||
;; Key bindings
|
;; Key bindings
|
||||||
|
|
||||||
(defun help--key-description-fontified (keys &optional prefix)
|
(defun help--key-description-fontified (keys &optional prefix)
|
||||||
"Like `key-description' but add face for \"*Help*\" buffers."
|
"Like `key-description' but add face for \"*Help*\" buffers.
|
||||||
;; We add both the `font-lock-face' and `face' properties here, as this
|
KEYS is the return value of `(where-is-internal \\='foo-cmd nil t)'.
|
||||||
;; seems to be the only way to get this to work reliably in any
|
Return nil if KEYS is nil."
|
||||||
;; buffer.
|
(when keys
|
||||||
(propertize (key-description keys prefix)
|
;; We add both the `font-lock-face' and `face' properties here, as this
|
||||||
'font-lock-face 'help-key-binding
|
;; seems to be the only way to get this to work reliably in any
|
||||||
'face 'help-key-binding))
|
;; buffer.
|
||||||
|
(propertize (key-description keys prefix)
|
||||||
|
'font-lock-face 'help-key-binding
|
||||||
|
'face 'help-key-binding)))
|
||||||
|
|
||||||
(defcustom describe-bindings-outline t
|
(defcustom describe-bindings-outline t
|
||||||
"Non-nil enables outlines in the output buffer of `describe-bindings'."
|
"Non-nil enables outlines in the output buffer of `describe-bindings'."
|
||||||
|
|
|
||||||
|
|
@ -55,18 +55,24 @@
|
||||||
(should (equal (help-split-fundoc nil t 'usage) nil))
|
(should (equal (help-split-fundoc nil t 'usage) nil))
|
||||||
(should (equal (help-split-fundoc nil t 'doc) nil))))
|
(should (equal (help-split-fundoc nil t 'doc) nil))))
|
||||||
|
|
||||||
|
(ert-deftest help--key-description-fontified ()
|
||||||
|
(should (equal (help--key-description-fontified
|
||||||
|
(where-is-internal #'next-line nil t))
|
||||||
|
"C-n"))
|
||||||
|
(should-not (help--key-description-fontified nil)))
|
||||||
|
|
||||||
|
|
||||||
;;; substitute-command-keys
|
;;; substitute-command-keys
|
||||||
|
|
||||||
(defmacro with-substitute-command-keys-test (&rest body)
|
(defmacro with-substitute-command-keys-test (&rest body)
|
||||||
`(cl-flet* ((test
|
`(cl-flet* ((test
|
||||||
(lambda (orig result)
|
(lambda (orig result)
|
||||||
(should (equal (substitute-command-keys orig)
|
(should (equal (substitute-command-keys orig)
|
||||||
result))))
|
result))))
|
||||||
(test-re
|
(test-re
|
||||||
(lambda (orig regexp)
|
(lambda (orig regexp)
|
||||||
(should (string-match (concat "\\`" regexp "\\'")
|
(should (string-match (concat "\\`" regexp "\\'")
|
||||||
(substitute-command-keys orig))))))
|
(substitute-command-keys orig))))))
|
||||||
,@body))
|
,@body))
|
||||||
|
|
||||||
(ert-deftest help-tests-substitute-command-keys/no-change ()
|
(ert-deftest help-tests-substitute-command-keys/no-change ()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue