read-multiple-choice: Add face when key not in name string

* lisp/emacs-lisp/rmc.el (rmc--add-key-description): Add face
property also when key is not in the name string.
* test/lisp/emacs-lisp/rmc-tests.el
(test-rmc--add-key-description/with-attributes)
(test-rmc--add-key-description/non-graphical-display): Update tests.
This commit is contained in:
Stefan Kangas 2021-12-26 00:45:50 +01:00
parent 68f15e815e
commit 787030b021
2 changed files with 15 additions and 8 deletions

View file

@ -28,15 +28,22 @@
(defun rmc--add-key-description (elem)
(let* ((name (cadr elem))
(pos (seq-position name (car elem)))
(graphical-terminal
(display-supports-face-attributes-p
'(:underline t) (window-frame)))
(altered-name
(cond
;; Not in the name string.
((not pos)
(format "[%c] %s" (car elem) name))
(let ((ch (char-to-string (car elem))))
(format "[%s] %s"
(if graphical-terminal
(propertize ch 'face 'read-multiple-choice-face)
ch)
name)))
;; The prompt character is in the name, so highlight
;; it on graphical terminals.
((display-supports-face-attributes-p
'(:underline t) (window-frame))
(graphical-terminal
(setq name (copy-sequence name))
(put-text-property pos (1+ pos)
'face 'read-multiple-choice-face