From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#60312: 30.0.50; Feature Request: Customize yes-or-n-p prompt from elisp: Date: Tue, 03 Jan 2023 15:52:47 +0100 Message-ID: <87lemjk6v4.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25271"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Jean Louis , 60312@debbugs.gnu.org To: "T.V Raman" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 03 15:53:18 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 1pCifE-0006Cf-Mn for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Jan 2023 15:53:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCif5-0007Al-9Q; Tue, 03 Jan 2023 09:53:07 -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 1pCif3-0007A4-5f for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2023 09:53:05 -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 1pCif0-0004C4-3I for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2023 09:53:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pCiez-0007nK-PQ for bug-gnu-emacs@gnu.org; Tue, 03 Jan 2023 09:53:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Jan 2023 14:53:01 +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.167275757729951 (code B ref 60312); Tue, 03 Jan 2023 14:53:01 +0000 Original-Received: (at 60312) by debbugs.gnu.org; 3 Jan 2023 14:52:57 +0000 Original-Received: from localhost ([127.0.0.1]:45047 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCieu-0007n0-GK for submit@debbugs.gnu.org; Tue, 03 Jan 2023 09:52:57 -0500 Original-Received: from mail-wm1-f47.google.com ([209.85.128.47]:50919) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCies-0007mn-NS for 60312@debbugs.gnu.org; Tue, 03 Jan 2023 09:52:55 -0500 Original-Received: by mail-wm1-f47.google.com with SMTP id m3so13984511wmq.0 for <60312@debbugs.gnu.org>; Tue, 03 Jan 2023 06:52:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=GLThsHXDo4TVe9+t7D2OVrUgx7csLm03r1rrqKkzYU8=; b=T6neEO1sM7AG78q5lY6kg4Yj30Dube+4ARMQgeDUb///Jq4JF4o1zzzhoyDuqyUdx7 cVNk3VShCWS/yUmbrW8zpOB+qZZo0yJ3KBj17eYpBpEiWGGfyevl0jCgEZeM/rZaCOld 8bk9TMy3aNLDwJDSXszRjagf8SX4kibrN2IuL6N4fcFVCYJdvGVvlU74Z+VTyIEzLy9X JaTaQg5ujJrIBZoTCe72bcs9E7ybgSdFYDfNFX/BL9MhHipFTqNXgWo4RDYsTGu+tNFt mAo4vnJTz5Y1TYCA9Ro846T3Qqm00nOKX0eZfEWRosE03nzY39B/+RPmclyCFaruelyU uFFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GLThsHXDo4TVe9+t7D2OVrUgx7csLm03r1rrqKkzYU8=; b=SCZRYbabcJNBI5vqttmv1hKtLIRmisSDuOiTmjapQamC42YHb2Z75IfYbZpwbcEyzM QTRI8DorHy1HPdxl2WGSJLBDBhMyQgBGLWSiUpQRwn1X98OxqcTCWKyf8bl2X6dY+92Y 0ETONcM7tuHY901bqBrP7C3kxj7ghCG/BirdqAUyaSeyXeQYGpBwTXTLY6c6B4NLm86r 9VJU2Csdy3GGOZJqU4SEZR9482V/1fpQA6jVkyk8dodYUo7muYvk6u1kFoGGPrNK8TZs 5QeONln73+FGkKZLlu3KWdHP5EbYlLkwT8uq5Bti2XozBu+QfW9tiYmR5F701CXj+Dos kVqw== X-Gm-Message-State: AFqh2kof3OFlhzZTFrCp/YxKumKsbJ8k4wt9B4tQaizrOqwvXCfPhx5x cym2L7KIIsybyyBnaUHpikPydZ+ufJI= X-Google-Smtp-Source: AMrXdXtD3fFpm5BBWeSi2x7qTvUrFE9SS3WwwLpOcE8rnV7KL/DS2D/gUSzVQDdYfA0tdh7bKy2Oiw== X-Received: by 2002:a05:600c:3491:b0:3d1:f16d:5848 with SMTP id a17-20020a05600c349100b003d1f16d5848mr31974067wmq.26.1672757568292; Tue, 03 Jan 2023 06:52:48 -0800 (PST) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id j1-20020adfff81000000b0024cb961b6aesm30705475wrr.104.2023.01.03.06.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 06:52:47 -0800 (PST) In-Reply-To: (Jean Louis's message of "Sun, 25 Dec 2022 20:19:28 +0300") 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:252409 Archived-At: >>>>> On Sun, 25 Dec 2022 20:19:28 +0300, Jean Louis said: Jean> * T.V Raman" via "Bug reports for GNU Emacs, the Swiss army knife of text editors [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);