From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "T.V Raman" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs 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 Message-ID: <25524.17520.145646.153474@retriever.mtv.corp.google.com> References: <87lemjk6v4.fsf@gmail.com> Reply-To: "T.V Raman" Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23312"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60312@debbugs.gnu.org, bugs@gnu.support, raman@google.com To: rpluim@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 03 16:07:25 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pCisv-0005ss-HF for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Jan 2023 16:07:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCisb-0003Gc-6N; Tue, 03 Jan 2023 10:07:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCisY-0003GN-R8 for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2023 10:07:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pCisY-0006Rs-As for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2023 10:07:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pCisY-0008Vs-36 for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2023 10:07:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "T.V Raman" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Jan 2023 15:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60312 X-GNU-PR-Package: emacs Original-Received: via spool by 60312-submit@debbugs.gnu.org id=B60312.167275839732687 (code B ref 60312); Tue, 03 Jan 2023 15:07:02 +0000 Original-Received: (at 60312) by debbugs.gnu.org; 3 Jan 2023 15:06:37 +0000 Original-Received: from localhost ([127.0.0.1]:46485 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCis8-0008V8-Ld for submit@debbugs.gnu.org; Tue, 03 Jan 2023 10:06:37 -0500 Original-Received: from mail-pf1-f172.google.com ([209.85.210.172]:39666) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCis4-0008Ur-RF for 60312@debbugs.gnu.org; Tue, 03 Jan 2023 10:06:36 -0500 Original-Received: by mail-pf1-f172.google.com with SMTP id a30so5124513pfr.6 for <60312@debbugs.gnu.org>; Tue, 03 Jan 2023 07:06:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=references:in-reply-to:subject:cc:to:date:message-id :content-transfer-encoding:mime-version:from:from:to:cc:subject:date :message-id:reply-to; bh=j3QgnpiC3aE9rD6r7Sn5fSKbEWqiigbi0q15r8es4XY=; b=YVDYLRV5lzKPEJR6L5ge8M0ACfpBir1mjg7JpVpjOJmQJpAlgYjxG1/Z0hxyRJ7Eul HAsVp9K9IWZCKUC+DNbgV3Jl5fZ2vDKcU6Z6wCkP93gqt2ocYieM8wMpMRf8ZhPk+4OV QpKmeKN49cgCrH3CbIx+YuUr4SiU8gbx6iJA1qbADKWnrxdEuNLjE2AvUtr4C/YttT7b xrVCZSrvTH4+XZPN782RR6twidr0sNRu+03F62ZoPNjaLnuNxTFyh3nd8NP1n5fSouzi +Iw1WjZhEfdYzzKzUPc1t4BV+WH7J0+92EuxDQsu6Ge9fnWvNTB6/YsEKU/WFSMi/STF upQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:subject:cc:to:date:message-id :content-transfer-encoding:mime-version:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=j3QgnpiC3aE9rD6r7Sn5fSKbEWqiigbi0q15r8es4XY=; b=7CflJ1qScRUTcfQtrNJ7jBgOaxmSRT80P96vaOcdmw9PmsbWVLFDl2ENW0nOs+ybDR +ABTgIEADZk/rkGq7zwYz10MDA8CydohIobFxz/YL/3gqEisPrFPClZEezcB61wwX6Wn NTBtOWDs8WIfj4F9f81FCm7g6ToE+P9EiyDvJF1xL7UE2vNvom2PJZkxw3qL/fQAHefB lzAWhjuH5a1OItI90k0KNhbY8IfQuuOzbLplHCknvOmUXxxlABjPERH+A0yZJfs4hIul 31oczwWiBL+v25UUEUUIti/y7tLBoE2kqsGFF28xTe/iU0Cnt8VVhNzkVNFJlA4zqRSl KWVA== X-Gm-Message-State: AFqh2krFRSRWn//iwM4C+z/9zHRalZwAo4pqDi9N1w/6M0t/X+Yk1lPI Etfpi/ic6HsyPFTAEiYELhXn3tMC4SNZ9TXG X-Google-Smtp-Source: AMrXdXvi0IMdS64mv0Mqc44bJ2CJsnzJEL0rVsN/3+5KBE3JVl+iChzpexJfYuLD8TfHoRl5u5GpKw== X-Received: by 2002:a62:1ec7:0:b0:56d:1e00:f078 with SMTP id e190-20020a621ec7000000b0056d1e00f078mr40301599pfe.32.1672758386262; Tue, 03 Jan 2023 07:06:26 -0800 (PST) Original-Received: from retriever.mtv.corp.google.com ([2620:0:1000:1612:c6e6:2e5d:19cc:b638]) by smtp.gmail.com with ESMTPSA id w18-20020a627b12000000b00580978caca7sm19372892pfc.45.2023.01.03.07.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 07:06:25 -0800 (PST) In-Reply-To: <87lemjk6v4.fsf@gmail.com> X-Mailer: VM 8.1.1 under 30.0.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:252412 Archived-At: this SGTM. Robert Pluim writes: > >>>>> On Sun, 25 Dec 2022 20:19:28 +0300, Jean Louis said: >=20 > Jean> * T.V Raman" via "Bug reports for GNU Emacs, the Swiss arm= y knife of text editors [2022-12-25 18:24]: > >> AUTO=5FSTRING (yes=5For=5Fno, "(yes or no) "); > >>=20 > >> I'd like to be able to customize this in some cases to someth= ing more > >> terse --- hearing "yes or no " each time gets wordy. >=20 > Jean> It can help to people who use different languages as well.= >=20 > Jean> This implies that also characters y and n shall be customi= zable. >=20 > That might be going a bit far. >=20 > TV, how does the below work for you=3F I thought `yes-or-no-p-prompt= ' > would have been overkill, so I painted this particular bikeshed as > `yes-or-no-prompt'. >=20 > Robert > --=20 >=20 > 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 > =20 > @cindex yes or no prompt > +@vindex yes-or-no-prompt > The second type of yes-or-no query is typically employed if givin= g > 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 w= ith > -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, i= f > +you invoke @kbd{C-x k} (@code{kill-buffer}) on a file-visiting buff= er > +with unsaved changes, Emacs activates the minibuffer with a prompt > +like this: > =20 > @smallexample > Buffer foo.el modified; kill anyway=3F (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{RE= T} to > finalize the response. Upper and lower case are equivalent. > =20 > -@code{yes-or-no-p} starts by displaying @var{prompt} in the minibuf= fer, > -followed by @w{@samp{(yes or no) }}. The user must type one of the= > -expected responses; otherwise, the function responds @samp{Please a= nswer > -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} (defau= lt > +@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. > =20 > @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") > =09 ;; fontset.c > =09 ;; FIXME nil is the initial value, fontset.el setqs it. > =09 (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=5For=5Fno=5Fp, Sy= es=5For=5Fno=5Fp, 1, 1, 0, > Return t if answer is yes, and nil if the answer is no. > =20 > 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 do= es > +not need to end in space, but if it does up to one space will be > +removed. > =20 > The user must confirm the answer with RET, and can edit it until it= > has been confirmed. > =20 > If the `use-short-answers' variable is non-nil, instead of asking f= or > -\"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'). > =20 > 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=5For=5Fno=5Fp, Syes= =5For=5Fno=5Fp, 1, 1, 0, > if (use=5Fshort=5Fanswers) > return call1 (intern ("y-or-n-p"), prompt); > =20 > - AUTO=5FSTRING (yes=5For=5Fno, "(yes or no) "); > - prompt =3D CALLN (Fconcat, prompt, yes=5For=5Fno); > + prompt =3D CALLN (Fconcat, prompt, Vyes=5For=5Fno=5Fprompt); > =20 > specpdl=5Fref count =3D SPECPDL=5FINDEX (); > specbind (Qenable=5Frecursive=5Fminibuffers, Qt); > @@ -6257,9 +6258,15 @@ syms=5Fof=5Ffns (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 als= o > +`yes-or-no-prompt'. */); > use=5Fshort=5Fanswers =3D false; > =20 > + DEFVAR=5FLISP ("yes-or-no-prompt", Vyes=5For=5Fno=5Fprompt, > + doc: /* String to append when `yes-or-no-p' asks a question. > +For best results this should end in a space. */); > + Vyes=5For=5Fno=5Fprompt =3D make=5Funibyte=5Fstring ("(yes or no)= ", strlen ("(yes or no) ")); > + > defsubr (&Sidentity); > defsubr (&Srandom); > defsubr (&Slength); --=20 Thanks, --Raman(I Search, I Find, I Misplace, I Research) =E2=99=89 Id: kg:/m/0285kf1 =F0=9F=A6=AE -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮