diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2023-05-12 12:45:32 +0200 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2023-05-12 12:45:32 +0200 |
commit | cbb59267c757b747c48a2690f96073614e8b4fd4 (patch) | |
tree | 60773448d227eabffbfd6fdc6314db3ce44961db /src/fns.c | |
parent | c9cf673d505b2dd9a666fed50d7f3b2f7dff163f (diff) | |
download | emacs-cbb59267c757b747c48a2690f96073614e8b4fd4.tar.gz |
Add trailing space to PROMPT in yes-or-no-p
* doc/lispref/minibuf.texi (Yes-or-No Queries): Describe PROMPT
massage for y-or-n-p and yes-or-no-p.
* lisp/subr.el (y-or-n-p): Adapt docstring.
* src/fns.c (Fyes_or_no_p): Add trailing space to PROMPT if
needed. (Bug#63399)
Diffstat (limited to 'src/fns.c')
-rw-r--r-- | src/fns.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/fns.c b/src/fns.c index bb6efdda655..561f526f8d0 100644 --- a/src/fns.c +++ b/src/fns.c @@ -26,6 +26,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include <intprops.h> #include <vla.h> #include <errno.h> +#include <ctype.h> #include "lisp.h" #include "bignum.h" @@ -3202,7 +3203,9 @@ DEFUN ("yes-or-no-p", Fyes_or_no_p, Syes_or_no_p, 1, 1, 0, Return t if answer is yes, and nil if the answer is no. PROMPT is the string to display to ask the question; `yes-or-no-p' -appends `yes-or-no-prompt' (default \"(yes or no) \") to it. +appends `yes-or-no-prompt' (default \"(yes or no) \") to it. If +PROMPT is a non-empty string, and it ends with a non-space character, +a space character will be appended to it. The user must confirm the answer with RET, and can edit it until it has been confirmed. @@ -3234,6 +3237,12 @@ if `last-nonmenu-event' is nil, and `use-dialog-box' is non-nil. */) if (use_short_answers) return call1 (intern ("y-or-n-p"), prompt); + { + char *s = SSDATA (prompt); + ptrdiff_t len = strlen (s); + if ((len > 0) && !isspace (s[len - 1])) + prompt = CALLN (Fconcat, prompt, build_string (" ")); + } prompt = CALLN (Fconcat, prompt, Vyes_or_no_prompt); specpdl_ref count = SPECPDL_INDEX (); |