diff options
| author | Eli Zaretskii | 2023-03-28 21:08:12 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2023-03-28 21:08:12 +0300 |
| commit | c1eac5b6586a79e0d84cbdb2ea310b7acee66414 (patch) | |
| tree | ec6d1b9d924bd1dec153f146f6e662ef69d9e8a0 /lisp | |
| parent | a8c9283e1702af06fb6ad598ae32a2c124860af1 (diff) | |
| download | emacs-c1eac5b6586a79e0d84cbdb2ea310b7acee66414.tar.gz emacs-c1eac5b6586a79e0d84cbdb2ea310b7acee66414.zip | |
Improve documentation of 'read-choice' and related symbols
* doc/lispref/commands.texi (Reading One Event):
* lisp/subr.el (read-char-choice-use-read-key, read-char-choice)
(read-char-choice-with-read-key, y-or-n-p-use-read-key): Improve
documentation of these functions and variables.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/subr.el | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 8d27c831c96..a9d93e5fe5e 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -3196,34 +3196,38 @@ This function is used by the `interactive' code letter \"n\"." | |||
| 3196 | n)) | 3196 | n)) |
| 3197 | 3197 | ||
| 3198 | (defvar read-char-choice-use-read-key nil | 3198 | (defvar read-char-choice-use-read-key nil |
| 3199 | "Prefer `read-key' when reading a character by `read-char-choice'. | 3199 | "If non-nil, use `read-key' when reading a character by `read-char-choice'. |
| 3200 | Otherwise, use the minibuffer. | 3200 | Otherwise, use the minibuffer (this is the default). |
| 3201 | 3201 | ||
| 3202 | When using the minibuffer, the user is less constrained, and can | 3202 | When reading via the minibuffer, you can use the normal commands |
| 3203 | use the normal commands available in the minibuffer, and can, for | 3203 | available in the minibuffer, and can, for instance, temporarily |
| 3204 | instance, switch to another buffer, do things there, and then | 3204 | switch to another buffer, do things there, and then switch back |
| 3205 | switch back again to the minibuffer before entering the | 3205 | to the minibuffer before entering the character. This is not |
| 3206 | character. This is not possible when using `read-key', but using | 3206 | possible when using `read-key', but using `read-key' may be less |
| 3207 | `read-key' may be less confusing to some users.") | 3207 | confusing to some users.") |
| 3208 | 3208 | ||
| 3209 | (defun read-char-choice (prompt chars &optional inhibit-keyboard-quit) | 3209 | (defun read-char-choice (prompt chars &optional inhibit-keyboard-quit) |
| 3210 | "Read and return one of CHARS, prompting for PROMPT. | 3210 | "Read and return one of the characters in CHARS, prompting with PROMPT. |
| 3211 | Any input that is not one of CHARS is ignored. | 3211 | CHARS should be a list of single characters. |
| 3212 | 3212 | The function discards any input character that is not one of CHARS, | |
| 3213 | By default, the minibuffer is used to read the key | 3213 | and shows a message to the effect that it is not one of the expected |
| 3214 | non-modally (see `read-char-from-minibuffer'). If | 3214 | charcaters. |
| 3215 | `read-char-choice-use-read-key' is non-nil, the modal `read-key' | 3215 | |
| 3216 | function is used instead (see `read-char-choice-with-read-key')." | 3216 | By default, use the minibuffer to read the key non-modally (see |
| 3217 | `read-char-from-minibuffer'). But if `read-char-choice-use-read-key' | ||
| 3218 | is non-nil, the modal `read-key' function is used instead (see | ||
| 3219 | `read-char-choice-with-read-key')." | ||
| 3217 | (if (not read-char-choice-use-read-key) | 3220 | (if (not read-char-choice-use-read-key) |
| 3218 | (read-char-from-minibuffer prompt chars) | 3221 | (read-char-from-minibuffer prompt chars) |
| 3219 | (read-char-choice-with-read-key prompt chars inhibit-keyboard-quit))) | 3222 | (read-char-choice-with-read-key prompt chars inhibit-keyboard-quit))) |
| 3220 | 3223 | ||
| 3221 | (defun read-char-choice-with-read-key (prompt chars &optional inhibit-keyboard-quit) | 3224 | (defun read-char-choice-with-read-key (prompt chars &optional inhibit-keyboard-quit) |
| 3222 | "Read and return one of CHARS, prompting for PROMPT. | 3225 | "Read and return one of the characters in CHARS, prompting with PROMPT. |
| 3226 | CHARS should be a list of single characters. | ||
| 3223 | Any input that is not one of CHARS is ignored. | 3227 | Any input that is not one of CHARS is ignored. |
| 3224 | 3228 | ||
| 3225 | If optional argument INHIBIT-KEYBOARD-QUIT is non-nil, ignore | 3229 | If optional argument INHIBIT-KEYBOARD-QUIT is non-nil, ignore |
| 3226 | `keyboard-quit' events while waiting for a valid input. | 3230 | `keyboard-quit' events while waiting for valid input. |
| 3227 | 3231 | ||
| 3228 | If you bind the variable `help-form' to a non-nil value | 3232 | If you bind the variable `help-form' to a non-nil value |
| 3229 | while calling this function, then pressing `help-char' | 3233 | while calling this function, then pressing `help-char' |
| @@ -3519,15 +3523,15 @@ Also discard all previous input in the minibuffer." | |||
| 3519 | (sit-for 2))) | 3523 | (sit-for 2))) |
| 3520 | 3524 | ||
| 3521 | (defvar y-or-n-p-use-read-key nil | 3525 | (defvar y-or-n-p-use-read-key nil |
| 3522 | "Prefer `read-key' when answering a \"y or n\" question by `y-or-n-p'. | 3526 | "Use `read-key' when reading answers to \"y or n\" questions by `y-or-n-p'. |
| 3523 | Otherwise, use the minibuffer. | 3527 | Otherwise, use the `read-from-minibuffer' to read the answers. |
| 3524 | 3528 | ||
| 3525 | When using the minibuffer, the user is less constrained, and can | 3529 | When reading via the minibuffer, you can use the normal commands |
| 3526 | use the normal commands available in the minibuffer, and can, for | 3530 | available in the minibuffer, and can, for instance, temporarily |
| 3527 | instance, switch to another buffer, do things there, and then | 3531 | switch to another buffer, do things there, and then switch back |
| 3528 | switch back again to the minibuffer before entering the | 3532 | to the minibuffer before entering the character. This is not |
| 3529 | character. This is not possible when using `read-key', but using | 3533 | possible when using `read-key', but using `read-key' may be less |
| 3530 | `read-key' may be less confusing to some users.") | 3534 | confusing to some users.") |
| 3531 | 3535 | ||
| 3532 | (defvar from--tty-menu-p nil | 3536 | (defvar from--tty-menu-p nil |
| 3533 | "Non-nil means the current command was invoked from a TTY menu.") | 3537 | "Non-nil means the current command was invoked from a TTY menu.") |