summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Kangas <stefan@marxist.se>2021-12-26 06:47:15 +0100
committerStefan Kangas <stefan@marxist.se>2021-12-26 17:05:39 +0100
commit40dcf9c2abd62425e599f30548dc53fa58fe2202 (patch)
tree66cf9b740b06d5c9317d35b2bbc34e23692f77be /lisp/emacs-lisp
parent1e7786437d3d471bffe48d91a067556f9223e9cf (diff)
downloademacs-40dcf9c2abd62425e599f30548dc53fa58fe2202.tar.gz
emacs-40dcf9c2abd62425e599f30548dc53fa58fe2202.tar.bz2
emacs-40dcf9c2abd62425e599f30548dc53fa58fe2202.zip
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.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/rmc.el24
1 files changed, 13 insertions, 11 deletions
diff --git a/lisp/emacs-lisp/rmc.el b/lisp/emacs-lisp/rmc.el
index 90fd8b370e8..522d395eba7 100644
--- a/lisp/emacs-lisp/rmc.el
+++ b/lisp/emacs-lisp/rmc.el
@@ -26,21 +26,23 @@
(require 'seq)
(defun rmc--add-key-description (elem)
- (let* ((name (cadr elem))
- (pos (seq-position name (car elem)))
+ (let* ((char (car elem))
+ (name (cadr elem))
+ (pos (seq-position name char))
+ (desc (key-description (char-to-string char)))
(graphical-terminal
(display-supports-face-attributes-p
'(:underline t) (window-frame)))
(altered-name
(cond
- ;; Not in the name string.
- ((not pos)
- (let ((ch (char-to-string (car elem))))
- (format "[%s] %s"
- (if graphical-terminal
- (propertize ch 'face 'read-multiple-choice-face)
- ch)
- name)))
+ ;; Not in the name string, or a special character.
+ ((or (not pos)
+ (member desc '("ESC" "TAB" "RET" "DEL" "SPC")))
+ (format "[%s] %s"
+ (if graphical-terminal
+ (propertize desc 'face 'read-multiple-choice-face)
+ desc)
+ name))
;; The prompt character is in the name, so highlight
;; it on graphical terminals.
(graphical-terminal
@@ -57,7 +59,7 @@
(upcase (substring name pos (1+ pos)))
"]"
(substring name (1+ pos)))))))
- (cons (car elem) altered-name)))
+ (cons char altered-name)))
(defun rmc--show-help (prompt help-string show-help choices altered-names)
(let* ((buf-name (if (stringp show-help)