* doc/lispref/commands.texi (Reading One Event): Mention
read-multiple-choice-face.
* lisp/subr.el (read-multiple-choice): Make the prompting a bit
prettier.
@end defun
@defun read-multiple-choice prompt choices
-Ask user a multiple choice question. @var{prompt} should be a string
+Ask user a multiple choice question. @var{prompt} should be a string
that will be displayed as the prompt.
@var{choices} is an alist where the first element in each entry is a
(?s "session only" "Accept this certificate this session only.")
(?n "no" "Refuse to use this certificate, and close the connection.")))
@end lisp
+
+The @code{read-multiple-choice-face} face is used to highlight the
+matching characters in the name string on graphical terminals.
+
@end defun
@node Event Mod
(let* ((altered-names nil)
(full-prompt
(format
- "%s (%s, ?): "
+ "%s (%s): "
prompt
(mapconcat
(lambda (elem)
(push (cons (car elem) altered-name)
altered-names)
altered-name))
- choices ", ")))
- tchar buf)
+ (append choices '((?? "?")))
+ ", ")))
+ tchar buf wrong-char)
(save-window-excursion
(save-excursion
(while (not tchar)
- (message "%s" full-prompt)
+ (message "%s%s"
+ (if wrong-char
+ "Invalid choice. "
+ "")
+ full-prompt)
(setq tchar (condition-case nil
(read-char)
(error nil)))
;; The user has entered an invalid choice, so display the
;; help messages.
(when (not (assq tchar choices))
- (setq tchar nil)
+ (setq wrong-char (not (memq tchar '(?? ?\C-h)))
+ tchar nil)
(with-help-window (setq buf (get-buffer-create
"*Multiple Choice Help*"))
(with-current-buffer buf