Function: read-char-choice

read-char-choice is a byte-compiled function defined in subr.el.gz.

Signature

(read-char-choice PROMPT CHARS &optional INHIBIT-KEYBOARD-QUIT)

Documentation

Read and return one of the characters in CHARS, prompting with PROMPT.

CHARS should be a list of single characters. The function discards any input character that is not one of CHARS, and by default shows a message to the effect that it is not one of the expected characters.

By default, this function uses the minibuffer to read the key non-modally (see read-char-from-minibuffer), and the optional argument INHIBIT-KEYBOARD-QUIT is ignored. However, if read-char-choice-use-read-key is non-nil, the modal read-key function is used instead (see read-char-choice-with-read-key), and INHIBIT-KEYBOARD-QUIT is passed to it.

View in manual

Probably introduced at or before Emacs version 24.1.

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun read-char-choice (prompt chars &optional inhibit-keyboard-quit)
  "Read and return one of the characters in CHARS, prompting with PROMPT.
CHARS should be a list of single characters.
The function discards any input character that is not one of CHARS,
and by default shows a message to the effect that it is not one of
the expected characters.

By default, this function uses the minibuffer to read the key
non-modally (see `read-char-from-minibuffer'), and the optional
argument INHIBIT-KEYBOARD-QUIT is ignored.  However, if
`read-char-choice-use-read-key' is non-nil, the modal `read-key'
function is used instead (see `read-char-choice-with-read-key'),
and INHIBIT-KEYBOARD-QUIT is passed to it."
  (if (not read-char-choice-use-read-key)
      ;; We are about to enter recursive-edit, which sets
      ;; 'last-command'.  If the callers of this function have some
      ;; logic based on 'last-command's value (example: 'kill-region'),
      ;; that could interfere with their logic.  So we let-bind
      ;; 'last-command' here to prevent that.
      (let ((last-command last-command))
        (read-char-from-minibuffer prompt chars))
    (read-char-choice-with-read-key prompt chars inhibit-keyboard-quit)))