From: "T.V Raman" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: rpluim@gmail.com
Cc: 60312@debbugs.gnu.org, bugs@gnu.support, raman@google.com
Subject: bug#60312: 30.0.50; Feature Request: Customize yes-or-n-p prompt from elisp:
Date: Tue, 3 Jan 2023 07:06:24 -0800 [thread overview]
Message-ID: <25524.17520.145646.153474@retriever.mtv.corp.google.com> (raw)
In-Reply-To: <87lemjk6v4.fsf@gmail.com>
this SGTM.
Robert Pluim writes:
> >>>>> On Sun, 25 Dec 2022 20:19:28 +0300, Jean Louis <bugs@gnu.support> said:
>
> Jean> * T.V Raman" via "Bug reports for GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org> [2022-12-25 18:24]:
> >> AUTO_STRING (yes_or_no, "(yes or no) ");
> >>
> >> I'd like to be able to customize this in some cases to something more
> >> terse --- hearing "yes or no " each time gets wordy.
>
> Jean> It can help to people who use different languages as well.
>
> Jean> This implies that also characters y and n shall be customizable.
>
> That might be going a bit far.
>
> TV, how does the below work for you? I thought `yes-or-no-p-prompt'
> would have been overkill, so I painted this particular bikeshed as
> `yes-or-no-prompt'.
>
> Robert
> --
>
> diff --git i/doc/emacs/mini.texi w/doc/emacs/mini.texi
> index 90e50a41d53..e4ec4cd3785 100644
> --- i/doc/emacs/mini.texi
> +++ w/doc/emacs/mini.texi
> @@ -953,12 +953,14 @@ Yes or No Prompts
> @end smallexample
>
> @cindex yes or no prompt
> +@vindex yes-or-no-prompt
> The second type of yes-or-no query is typically employed if giving
> the wrong answer would have serious consequences; it thus features a
> -longer prompt ending with @samp{(yes or no)}. For example, if you
> -invoke @kbd{C-x k} (@code{kill-buffer}) on a file-visiting buffer with
> -unsaved changes, Emacs activates the minibuffer with a prompt like
> -this:
> +longer prompt ending with @samp{(yes or no)} (or the value of
> +@code{yes-or-no-prompt} if you've customized that). For example, if
> +you invoke @kbd{C-x k} (@code{kill-buffer}) on a file-visiting buffer
> +with unsaved changes, Emacs activates the minibuffer with a prompt
> +like this:
>
> @smallexample
> Buffer foo.el modified; kill anyway? (yes or no)
> diff --git i/doc/lispref/minibuf.texi w/doc/lispref/minibuf.texi
> index 332a453619c..546e46813ec 100644
> --- i/doc/lispref/minibuf.texi
> +++ w/doc/lispref/minibuf.texi
> @@ -2233,10 +2233,12 @@ Yes-or-No Queries
> @code{nil} if the user types @samp{no}. The user must type @key{RET} to
> finalize the response. Upper and lower case are equivalent.
>
> -@code{yes-or-no-p} starts by displaying @var{prompt} in the minibuffer,
> -followed by @w{@samp{(yes or no) }}. The user must type one of the
> -expected responses; otherwise, the function responds @samp{Please answer
> -yes or no.}, waits about two seconds and repeats the request.
> +@vindex yes-or-no-prompt
> +@code{yes-or-no-p} starts by displaying @var{prompt} in the
> +minibuffer, followed by the value of @code{yes-or-no-prompt} (default
> +@w{@samp{(yes or no) }}). The user must type one of the expected
> +responses; otherwise, the function responds @samp{Please answer yes or
> +no.}, waits about two seconds and repeats the request.
>
> @code{yes-or-no-p} requires more work from the user than
> @code{y-or-n-p} and is appropriate for more crucial decisions.
> diff --git i/lisp/cus-start.el w/lisp/cus-start.el
> index d7fb56c9854..197c41c5ebb 100644
> --- i/lisp/cus-start.el
> +++ w/lisp/cus-start.el
> @@ -310,6 +310,7 @@ minibuffer-prompt-properties--setter
> (const :tag "Off" :value nil)
> (const :tag "On" :value t)
> (const :tag "Auto-raise" :value auto-raise)) "26.1")
> + (yes-or-no-prompt menu string "30.1")
> ;; fontset.c
> ;; FIXME nil is the initial value, fontset.el setqs it.
> (vertical-centering-font-regexp display
> diff --git i/src/fns.c w/src/fns.c
> index eeb65cadf3f..1a7b6b11c44 100644
> --- i/src/fns.c
> +++ w/src/fns.c
> @@ -3173,14 +3173,16 @@ 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'
> -adds \"(yes or no) \" to it. It does not need to end in space, but if
> -it does up to one space will be removed.
> +appends `yes-or-no-prompt' (default \"(yes or no) \") to it. It does
> +not need to end in space, but if it does up to one space will be
> +removed.
>
> The user must confirm the answer with RET, and can edit it until it
> has been confirmed.
>
> If the `use-short-answers' variable is non-nil, instead of asking for
> -\"yes\" or \"no\", this function will ask for \"y\" or \"n\".
> +\"yes\" or \"no\", this function will ask for \"y\" or \"n\" (and
> +ignore the value of `yes-or-no-prompt').
>
> If dialog boxes are supported, a dialog box will be used
> if `last-nonmenu-event' is nil, and `use-dialog-box' is non-nil. */)
> @@ -3205,8 +3207,7 @@ DEFUN ("yes-or-no-p", Fyes_or_no_p, Syes_or_no_p, 1, 1, 0,
> if (use_short_answers)
> return call1 (intern ("y-or-n-p"), prompt);
>
> - AUTO_STRING (yes_or_no, "(yes or no) ");
> - prompt = CALLN (Fconcat, prompt, yes_or_no);
> + prompt = CALLN (Fconcat, prompt, Vyes_or_no_prompt);
>
> specpdl_ref count = SPECPDL_INDEX ();
> specbind (Qenable_recursive_minibuffers, Qt);
> @@ -6257,9 +6258,15 @@ syms_of_fns (void)
> We recommend against setting this variable non-nil, because `yes-or-no-p'
> is intended to be used when users are expected not to respond too
> quickly, but to take their time and perhaps think about the answer.
> -The same variable also affects the function `read-answer'. */);
> +The same variable also affects the function `read-answer'. See also
> +`yes-or-no-prompt'. */);
> use_short_answers = false;
>
> + DEFVAR_LISP ("yes-or-no-prompt", Vyes_or_no_prompt,
> + doc: /* String to append when `yes-or-no-p' asks a question.
> +For best results this should end in a space. */);
> + Vyes_or_no_prompt = make_unibyte_string ("(yes or no) ", strlen ("(yes or no) "));
> +
> defsubr (&Sidentity);
> defsubr (&Srandom);
> defsubr (&Slength);
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
next prev parent reply other threads:[~2023-01-03 15:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-25 15:22 bug#60312: 30.0.50; Feature Request: Customize yes-or-n-p prompt from elisp: T.V Raman via Bug reports for GNU Emacs, the Swiss army knife of text editors
[not found] ` <handler.60312.B.167198177811134.ack@debbugs.gnu.org>
2022-12-25 15:53 ` bug#60312: Acknowledgement (30.0.50; Feature Request: Customize yes-or-n-p prompt from elisp:) T.V Raman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-25 17:19 ` bug#60312: 30.0.50; Feature Request: Customize yes-or-n-p prompt from elisp: Jean Louis
2023-01-03 14:52 ` Robert Pluim
2023-01-03 15:06 ` T.V Raman via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-01-03 15:12 ` Robert Pluim
2023-01-03 15:32 ` Eli Zaretskii
2023-01-23 8:23 ` Robert Pluim
2023-09-10 17:35 ` Stefan Kangas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25524.17520.145646.153474@retriever.mtv.corp.google.com \
--to=bug-gnu-emacs@gnu.org \
--cc=60312@debbugs.gnu.org \
--cc=bugs@gnu.support \
--cc=raman@google.com \
--cc=rpluim@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.