diff options
| author | Juri Linkov | 2019-11-10 00:04:13 +0200 |
|---|---|---|
| committer | Juri Linkov | 2019-11-10 00:04:13 +0200 |
| commit | a26a8cc1c85f29fb11209c16d53a8ae4e4ab7ced (patch) | |
| tree | 73026908995a8daa8a96a6b1d0ebd9b64e169992 /doc | |
| parent | 898cdc67f19ca15f4ac2b447adf350188baef604 (diff) | |
| download | emacs-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.texi | 36 |
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 | |||
| 2020 | input by binding @code{last-nonmenu-event} to a suitable value around | 2020 | input by binding @code{last-nonmenu-event} to a suitable value around |
| 2021 | the call. | 2021 | the 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 |
| 2027 | This function asks the user a question, expecting input in the echo | 2026 | This function asks the user a question, expecting input in the minibuffer. |
| 2028 | area. It returns @code{t} if the user types @kbd{y}, @code{nil} if the | 2027 | It returns @code{t} if the user types @kbd{y}, @code{nil} if the user |
| 2029 | user types @kbd{n}. This function also accepts @key{SPC} to mean yes | 2028 | types @kbd{n}. This function also accepts @key{SPC} to mean yes and |
| 2030 | and @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 | 2030 | because the question uses the minibuffer and for that reason the user |
| 2032 | that reason the user might try to use @kbd{C-]} to get out. The answer | 2031 | might try to use @kbd{C-]} to get out. The answer is a single |
| 2033 | is a single character, with no @key{RET} needed to terminate it. Upper | 2032 | character, with no @key{RET} needed to terminate it. Upper and lower |
| 2034 | and lower case are equivalent. | 2033 | case 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, |
| 2037 | followed by the string @w{@samp{(y or n) }}. If the input is not one of | 2036 | followed by the string @w{@samp{(y or n) }}. If the input is not one of |
| 2038 | the expected answers (@kbd{y}, @kbd{n}, @kbd{@key{SPC}}, | 2037 | the 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 | ||
| 2042 | This function does not actually use the minibuffer, since it does not | 2041 | This function actually uses the minibuffer, but does not allow editing |
| 2043 | allow editing of the answer. It actually uses the echo area (@pxref{The | 2042 | of the answer. The cursor moves to the minibuffer while the question |
| 2044 | Echo Area}), which uses the same screen space as the minibuffer. The | 2043 | is being asked. |
| 2045 | cursor moves to the echo area while the question is being asked. | ||
| 2046 | 2044 | ||
| 2047 | The answers and their meanings, even @samp{y} and @samp{n}, are not | 2045 | The answers and their meanings, even @samp{y} and @samp{n}, are not |
| 2048 | hardwired, and are specified by the keymap @code{query-replace-map} | 2046 | hardwired, 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 |
| 2055 | recentering or scrolling operation, and poses the question again. | 2053 | recentering or scrolling operation, and poses the question again. |
| 2056 | |||
| 2057 | @noindent | ||
| 2058 | We show successive lines of echo area messages, but only one actually | ||
| 2059 | appears 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 |
| 2073 | finalize the response. Upper and lower case are equivalent. | 2067 | finalize 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, |
| 2076 | followed by @w{@samp{(yes or no) }}. The user must type one of the | 2070 | followed by @w{@samp{(yes or no) }}. The user must type one of the |
| 2077 | expected responses; otherwise, the function responds @samp{Please answer | 2071 | expected responses; otherwise, the function responds @samp{Please answer |
| 2078 | yes or no.}, waits about two seconds and repeats the request. | 2072 | yes or no.}, waits about two seconds and repeats the request. |