diff options
| -rw-r--r-- | doc/lispref/commands.texi | 6 | ||||
| -rw-r--r-- | lisp/subr.el | 16 |
2 files changed, 16 insertions, 6 deletions
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index 1964ec8e3fe..3ea6ea045eb 100644 --- a/doc/lispref/commands.texi +++ b/doc/lispref/commands.texi | |||
| @@ -2618,7 +2618,7 @@ then continues to wait for a valid input character, or keyboard-quit. | |||
| 2618 | @end defun | 2618 | @end defun |
| 2619 | 2619 | ||
| 2620 | @defun read-multiple-choice prompt choices | 2620 | @defun read-multiple-choice prompt choices |
| 2621 | Ask user a multiple choice question. @var{prompt} should be a string | 2621 | Ask user a multiple choice question. @var{prompt} should be a string |
| 2622 | that will be displayed as the prompt. | 2622 | that will be displayed as the prompt. |
| 2623 | 2623 | ||
| 2624 | @var{choices} is an alist where the first element in each entry is a | 2624 | @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}. | |||
| 2636 | (?s "session only" "Accept this certificate this session only.") | 2636 | (?s "session only" "Accept this certificate this session only.") |
| 2637 | (?n "no" "Refuse to use this certificate, and close the connection."))) | 2637 | (?n "no" "Refuse to use this certificate, and close the connection."))) |
| 2638 | @end lisp | 2638 | @end lisp |
| 2639 | |||
| 2640 | The @code{read-multiple-choice-face} face is used to highlight the | ||
| 2641 | matching characters in the name string on graphical terminals. | ||
| 2642 | |||
| 2639 | @end defun | 2643 | @end defun |
| 2640 | 2644 | ||
| 2641 | @node Event Mod | 2645 | @node Event Mod |
diff --git a/lisp/subr.el b/lisp/subr.el index db1baf09c43..a45d4a721b7 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -2255,7 +2255,7 @@ Usage example: | |||
| 2255 | (let* ((altered-names nil) | 2255 | (let* ((altered-names nil) |
| 2256 | (full-prompt | 2256 | (full-prompt |
| 2257 | (format | 2257 | (format |
| 2258 | "%s (%s, ?): " | 2258 | "%s (%s): " |
| 2259 | prompt | 2259 | prompt |
| 2260 | (mapconcat | 2260 | (mapconcat |
| 2261 | (lambda (elem) | 2261 | (lambda (elem) |
| @@ -2285,19 +2285,25 @@ Usage example: | |||
| 2285 | (push (cons (car elem) altered-name) | 2285 | (push (cons (car elem) altered-name) |
| 2286 | altered-names) | 2286 | altered-names) |
| 2287 | altered-name)) | 2287 | altered-name)) |
| 2288 | choices ", "))) | 2288 | (append choices '((?? "?"))) |
| 2289 | tchar buf) | 2289 | ", "))) |
| 2290 | tchar buf wrong-char) | ||
| 2290 | (save-window-excursion | 2291 | (save-window-excursion |
| 2291 | (save-excursion | 2292 | (save-excursion |
| 2292 | (while (not tchar) | 2293 | (while (not tchar) |
| 2293 | (message "%s" full-prompt) | 2294 | (message "%s%s" |
| 2295 | (if wrong-char | ||
| 2296 | "Invalid choice. " | ||
| 2297 | "") | ||
| 2298 | full-prompt) | ||
| 2294 | (setq tchar (condition-case nil | 2299 | (setq tchar (condition-case nil |
| 2295 | (read-char) | 2300 | (read-char) |
| 2296 | (error nil))) | 2301 | (error nil))) |
| 2297 | ;; The user has entered an invalid choice, so display the | 2302 | ;; The user has entered an invalid choice, so display the |
| 2298 | ;; help messages. | 2303 | ;; help messages. |
| 2299 | (when (not (assq tchar choices)) | 2304 | (when (not (assq tchar choices)) |
| 2300 | (setq tchar nil) | 2305 | (setq wrong-char (not (memq tchar '(?? ?\C-h))) |
| 2306 | tchar nil) | ||
| 2301 | (with-help-window (setq buf (get-buffer-create | 2307 | (with-help-window (setq buf (get-buffer-create |
| 2302 | "*Multiple Choice Help*")) | 2308 | "*Multiple Choice Help*")) |
| 2303 | (with-current-buffer buf | 2309 | (with-current-buffer buf |