Make the read-multiple-choice prompt a bit prettier
* doc/lispref/commands.texi (Reading One Event): Mention read-multiple-choice-face. * lisp/subr.el (read-multiple-choice): Make the prompting a bit prettier.
This commit is contained in:
parent
605f9019b4
commit
b3a28d088f
2 changed files with 16 additions and 6 deletions
|
@ -2618,7 +2618,7 @@ then continues to wait for a valid input character, or keyboard-quit.
|
|||
@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
|
||||
|
@ -2636,6 +2636,10 @@ The return value is the matching value from @var{choices}.
|
|||
(?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
|
||||
|
|
16
lisp/subr.el
16
lisp/subr.el
|
@ -2255,7 +2255,7 @@ Usage example:
|
|||
(let* ((altered-names nil)
|
||||
(full-prompt
|
||||
(format
|
||||
"%s (%s, ?): "
|
||||
"%s (%s): "
|
||||
prompt
|
||||
(mapconcat
|
||||
(lambda (elem)
|
||||
|
@ -2285,19 +2285,25 @@ Usage example:
|
|||
(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
|
||||
|
|
Loading…
Add table
Reference in a new issue