read-multiple-choice: Display "SPC" instead of " "

* lisp/emacs-lisp/rmc.el (rmc--add-key-description): Improve display
of the keys TAB, RET, SPC, DEL, and ESC.  This fixes a bug where " "
was highlighted in the description in a confusing way.
* test/lisp/emacs-lisp/rmc-tests.el
(test-rmc--add-key-description)
(test-rmc--add-key-description/with-attributes): Update tests for the
above change.
This commit is contained in:
Stefan Kangas 2021-12-26 06:47:15 +01:00
parent 1e7786437d
commit 40dcf9c2ab
2 changed files with 20 additions and 13 deletions

View file

@ -34,7 +34,9 @@
(should (equal (rmc--add-key-description '(?y "yes"))
'(?y . "yes")))
(should (equal (rmc--add-key-description '(?n "foo"))
'(?n . "[n] foo")))))
'(?n . "[n] foo")))
(should (equal (rmc--add-key-description '(?\s "foo bar"))
`(?\s . "[SPC] foo bar")))))
(ert-deftest test-rmc--add-key-description/with-attributes ()
(cl-letf (((symbol-function 'display-supports-face-attributes-p) (lambda (_ _) t)))
@ -43,7 +45,10 @@
`(?y . ,(concat (propertize "y" 'face 'read-multiple-choice-face) "es"))))
(should (equal-including-properties
(rmc--add-key-description '(?n "foo"))
`(?n . ,(concat "[" (propertize "n" 'face 'read-multiple-choice-face) "] foo"))))))
`(?n . ,(concat "[" (propertize "n" 'face 'read-multiple-choice-face) "] foo"))))
(should (equal-including-properties
(rmc--add-key-description '(?\s "foo bar"))
`(?\s . ,(concat "[" (propertize "SPC" 'face 'read-multiple-choice-face) "] foo bar"))))))
(ert-deftest test-rmc--add-key-description/non-graphical-display ()
(cl-letf (((symbol-function 'display-supports-face-attributes-p) (lambda (_ _) nil)))