(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
;;; Commentary:
-;;
-
;;; Code:
(require 'ert)
`(?y . ,(concat (propertize "y" 'face 'read-multiple-choice-face) "es"))))
(should (equal-including-properties
(rmc--add-key-description '(?n "foo"))
- '(?n . "[n] foo")))))
+ `(?n . ,(concat "[" (propertize "n" 'face 'read-multiple-choice-face) "] foo"))))))
(ert-deftest test-rmc--add-key-description/non-graphical-display ()
(cl-letf (((symbol-function 'display-supports-face-attributes-p) (lambda (_ _) nil)))
(should (equal-including-properties
(rmc--add-key-description '(?y "yes"))
- '(?y . "[Y]es")))))
+ '(?y . "[Y]es")))
+ (should (equal-including-properties
+ (rmc--add-key-description '(?n "foo"))
+ '(?n . "[n] foo")))))
(ert-deftest test-read-multiple-choice ()
(dolist (char '(?y ?n))
(should (equal (list char str)
(read-multiple-choice "Do it? " '((?y "yes") (?n "no"))))))))
-
(provide 'rmc-tests)
;;; rmc-tests.el ends here