aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorEli Zaretskii2023-03-28 21:08:12 +0300
committerEli Zaretskii2023-03-28 21:08:12 +0300
commitc1eac5b6586a79e0d84cbdb2ea310b7acee66414 (patch)
treeec6d1b9d924bd1dec153f146f6e662ef69d9e8a0 /lisp
parenta8c9283e1702af06fb6ad598ae32a2c124860af1 (diff)
downloademacs-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.el56
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'.
3200Otherwise, use the minibuffer. 3200Otherwise, use the minibuffer (this is the default).
3201 3201
3202When using the minibuffer, the user is less constrained, and can 3202When reading via the minibuffer, you can use the normal commands
3203use the normal commands available in the minibuffer, and can, for 3203available in the minibuffer, and can, for instance, temporarily
3204instance, switch to another buffer, do things there, and then 3204switch to another buffer, do things there, and then switch back
3205switch back again to the minibuffer before entering the 3205to the minibuffer before entering the character. This is not
3206character. This is not possible when using `read-key', but using 3206possible when using `read-key', but using `read-key' may be less
3207`read-key' may be less confusing to some users.") 3207confusing 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.
3211Any input that is not one of CHARS is ignored. 3211CHARS should be a list of single characters.
3212 3212The function discards any input character that is not one of CHARS,
3213By default, the minibuffer is used to read the key 3213and shows a message to the effect that it is not one of the expected
3214non-modally (see `read-char-from-minibuffer'). If 3214charcaters.
3215`read-char-choice-use-read-key' is non-nil, the modal `read-key' 3215
3216function is used instead (see `read-char-choice-with-read-key')." 3216By default, use the minibuffer to read the key non-modally (see
3217`read-char-from-minibuffer'). But if `read-char-choice-use-read-key'
3218is 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.
3226CHARS should be a list of single characters.
3223Any input that is not one of CHARS is ignored. 3227Any input that is not one of CHARS is ignored.
3224 3228
3225If optional argument INHIBIT-KEYBOARD-QUIT is non-nil, ignore 3229If 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
3228If you bind the variable `help-form' to a non-nil value 3232If you bind the variable `help-form' to a non-nil value
3229while calling this function, then pressing `help-char' 3233while 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'.
3523Otherwise, use the minibuffer. 3527Otherwise, use the `read-from-minibuffer' to read the answers.
3524 3528
3525When using the minibuffer, the user is less constrained, and can 3529When reading via the minibuffer, you can use the normal commands
3526use the normal commands available in the minibuffer, and can, for 3530available in the minibuffer, and can, for instance, temporarily
3527instance, switch to another buffer, do things there, and then 3531switch to another buffer, do things there, and then switch back
3528switch back again to the minibuffer before entering the 3532to the minibuffer before entering the character. This is not
3529character. This is not possible when using `read-key', but using 3533possible when using `read-key', but using `read-key' may be less
3530`read-key' may be less confusing to some users.") 3534confusing 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.")