aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorJuri Linkov2019-11-10 00:04:13 +0200
committerJuri Linkov2019-11-10 00:04:13 +0200
commita26a8cc1c85f29fb11209c16d53a8ae4e4ab7ced (patch)
tree73026908995a8daa8a96a6b1d0ebd9b64e169992 /doc
parent898cdc67f19ca15f4ac2b447adf350188baef604 (diff)
downloademacs-a26a8cc1c85f29fb11209c16d53a8ae4e4ab7ced.tar.gz
emacs-a26a8cc1c85f29fb11209c16d53a8ae4e4ab7ced.zip
'y-or-n-p' now uses the minibuffer to read 'y' or 'n' answer (bug#38076)
* doc/lispref/minibuf.texi (Yes-or-No Queries): Update the fact that y-or-n-p uses the minibuffer. * lisp/subr.el (y-or-n-p-history-variable): New variable. (y-or-n-p-map): New keymap. (y-or-n-p-insert-y, y-or-n-p-insert-n, y-or-n-p-insert-other): New commands. (y-or-n-p): Rewrite to use read-from-minibuffer and make-composed-keymap with y-or-n-p-map and query-replace-map.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/minibuf.texi36
1 files changed, 15 insertions, 21 deletions
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index 49add3f7a79..41c87ce0eea 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -2020,29 +2020,27 @@ uses keyboard input. You can force use either of the mouse or of keyboard
2020input by binding @code{last-nonmenu-event} to a suitable value around 2020input by binding @code{last-nonmenu-event} to a suitable value around
2021the call. 2021the call.
2022 2022
2023 Strictly speaking, @code{yes-or-no-p} uses the minibuffer and 2023 Both @code{yes-or-no-p} and @code{y-or-n-p} use the minibuffer.
2024@code{y-or-n-p} does not; but it seems best to describe them together.
2025 2024
2026@defun y-or-n-p prompt 2025@defun y-or-n-p prompt
2027This function asks the user a question, expecting input in the echo 2026This function asks the user a question, expecting input in the minibuffer.
2028area. It returns @code{t} if the user types @kbd{y}, @code{nil} if the 2027It returns @code{t} if the user types @kbd{y}, @code{nil} if the user
2029user types @kbd{n}. This function also accepts @key{SPC} to mean yes 2028types @kbd{n}. This function also accepts @key{SPC} to mean yes and
2030and @key{DEL} to mean no. It accepts @kbd{C-]} to quit, like 2029@key{DEL} to mean no. It accepts @kbd{C-]} and @kbd{C-g} to quit,
2031@kbd{C-g}, because the question might look like a minibuffer and for 2030because the question uses the minibuffer and for that reason the user
2032that reason the user might try to use @kbd{C-]} to get out. The answer 2031might try to use @kbd{C-]} to get out. The answer is a single
2033is a single character, with no @key{RET} needed to terminate it. Upper 2032character, with no @key{RET} needed to terminate it. Upper and lower
2034and lower case are equivalent. 2033case are equivalent.
2035 2034
2036``Asking the question'' means printing @var{prompt} in the echo area, 2035``Asking the question'' means printing @var{prompt} in the minibuffer,
2037followed by the string @w{@samp{(y or n) }}. If the input is not one of 2036followed by the string @w{@samp{(y or n) }}. If the input is not one of
2038the expected answers (@kbd{y}, @kbd{n}, @kbd{@key{SPC}}, 2037the expected answers (@kbd{y}, @kbd{n}, @kbd{@key{SPC}},
2039@kbd{@key{DEL}}, or something that quits), the function responds 2038@kbd{@key{DEL}}, or something that quits), the function responds
2040@samp{Please answer y or n.}, and repeats the request. 2039@samp{Please answer y or n.}, and repeats the request.
2041 2040
2042This function does not actually use the minibuffer, since it does not 2041This function actually uses the minibuffer, but does not allow editing
2043allow editing of the answer. It actually uses the echo area (@pxref{The 2042of the answer. The cursor moves to the minibuffer while the question
2044Echo Area}), which uses the same screen space as the minibuffer. The 2043is being asked.
2045cursor moves to the echo area while the question is being asked.
2046 2044
2047The answers and their meanings, even @samp{y} and @samp{n}, are not 2045The answers and their meanings, even @samp{y} and @samp{n}, are not
2048hardwired, and are specified by the keymap @code{query-replace-map} 2046hardwired, and are specified by the keymap @code{query-replace-map}
@@ -2053,10 +2051,6 @@ special responses @code{recenter}, @code{scroll-up},
2053@kbd{C-v}, @kbd{M-v}, @kbd{C-M-v} and @kbd{C-M-S-v} in 2051@kbd{C-v}, @kbd{M-v}, @kbd{C-M-v} and @kbd{C-M-S-v} in
2054@code{query-replace-map}), this function performs the specified window 2052@code{query-replace-map}), this function performs the specified window
2055recentering or scrolling operation, and poses the question again. 2053recentering or scrolling operation, and poses the question again.
2056
2057@noindent
2058We show successive lines of echo area messages, but only one actually
2059appears on the screen at a time.
2060@end defun 2054@end defun
2061 2055
2062@defun y-or-n-p-with-timeout prompt seconds default 2056@defun y-or-n-p-with-timeout prompt seconds default
@@ -2072,7 +2066,7 @@ minibuffer. It returns @code{t} if the user enters @samp{yes},
2072@code{nil} if the user types @samp{no}. The user must type @key{RET} to 2066@code{nil} if the user types @samp{no}. The user must type @key{RET} to
2073finalize the response. Upper and lower case are equivalent. 2067finalize the response. Upper and lower case are equivalent.
2074 2068
2075@code{yes-or-no-p} starts by displaying @var{prompt} in the echo area, 2069@code{yes-or-no-p} starts by displaying @var{prompt} in the minibuffer,
2076followed by @w{@samp{(yes or no) }}. The user must type one of the 2070followed by @w{@samp{(yes or no) }}. The user must type one of the
2077expected responses; otherwise, the function responds @samp{Please answer 2071expected responses; otherwise, the function responds @samp{Please answer
2078yes or no.}, waits about two seconds and repeats the request. 2072yes or no.}, waits about two seconds and repeats the request.