From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#46594: [External] : bug#46594: Use short answers Date: Wed, 24 Feb 2021 20:44:51 +0200 Organization: LINKOV.NET Message-ID: <87v9ahi9uk.fsf@mail.linkov.net> References: <87im6qikpo.fsf@mail.linkov.net> <878s7gjftt.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27639"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: Lars Ingebrigtsen , "46594@debbugs.gnu.org" <46594@debbugs.gnu.org> To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 24 19:49:17 2021 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 1lEzDp-00074W-BN for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Feb 2021 19:49:17 +0100 Original-Received: from localhost ([::1]:48134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lEzDo-0002Ju-Dn for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Feb 2021 13:49:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lEzDZ-0002Gy-SB for bug-gnu-emacs@gnu.org; Wed, 24 Feb 2021 13:49:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52624) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lEzDZ-00071b-LU for bug-gnu-emacs@gnu.org; Wed, 24 Feb 2021 13:49:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lEzDZ-0001nd-KE for bug-gnu-emacs@gnu.org; Wed, 24 Feb 2021 13:49:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Feb 2021 18:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46594 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 46594-submit@debbugs.gnu.org id=B46594.16141924906860 (code B ref 46594); Wed, 24 Feb 2021 18:49:01 +0000 Original-Received: (at 46594) by debbugs.gnu.org; 24 Feb 2021 18:48:10 +0000 Original-Received: from localhost ([127.0.0.1]:35937 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lEzCk-0001mZ-7V for submit@debbugs.gnu.org; Wed, 24 Feb 2021 13:48:10 -0500 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:45509) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lEzCZ-0001l6-O3 for 46594@debbugs.gnu.org; Wed, 24 Feb 2021 13:48:00 -0500 X-Originating-IP: 91.129.96.116 Original-Received: from mail.gandi.net (m91-129-96-116.cust.tele2.ee [91.129.96.116]) (Authenticated sender: juri@linkov.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 1870F1C000C; Wed, 24 Feb 2021 18:47:51 +0000 (UTC) In-Reply-To: (Drew Adams's message of "Mon, 22 Feb 2021 17:13:28 +0000") 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" Xref: news.gmane.io gmane.emacs.bugs:200749 Archived-At: --=-=-= Content-Type: text/plain >> > This is a related option, but I'm not sure if it should be mentioned >> > in the docstring. Maybe a simple reference should be sufficient? >> >> I think mentioning it in the `yes-or-no-p' doc string would be good. > > I think that the doc for this option should explicitly discourage > using the value that abbreviates, and say why. > > It should say that `yes-or-no-p' is _intended_ to be used when it's > thought that you should not respond too quickly. At least point that > out, for users to think about before customizing. Thanks for suggestions. Now below is a new patch with these changes. > Presumably this option is being added because there are apparently > a lot of users who don't want to be slowed down by `yes-or-no-p'. > But that's exactly the point of `yes-or-no-p'. For many users using longer answers doesn't protect from mistakes. Sometimes I execute a command without verifying if it's right, e.g. first running a harmless command, then a more dangerous, then I forget about the last command, and thinking that the last one was the harmless command, quickly type a key sequence 'M-! M-p RET'. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=use-short-answers.patch diff --git a/etc/NEWS b/etc/NEWS index 2bad41f5ee..590fea5c97 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2408,6 +2408,11 @@ and display the result. When non-nil, then functions 'read-char-choice' and 'y-or-n-p' (respectively) use the function 'read-key' to read a character instead of using the minibuffer. +--- +** New variable 'use-short-answers' to use 'y-or-n-p' instead of 'yes-or-no-p'. +This relieves of the need to define an alias that maps one to another +in the init file. + +++ ** 'set-window-configuration' now takes an optional 'dont-set-frame' parameter which, when non-nil, instructs the function not to select diff --git a/lisp/cus-start.el b/lisp/cus-start.el index c0a4a6dda0..d17c419c36 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -302,6 +302,7 @@ minibuffer-prompt-properties--setter ;; fns.c (use-dialog-box menu boolean "21.1") (use-file-dialog menu boolean "22.1") + (use-short-answers menu boolean "28.1") (focus-follows-mouse frames (choice (const :tag "Off (nil)" :value nil) diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el index 14112a1c14..86a0c76fd1 100644 --- a/lisp/emacs-lisp/map-ynp.el +++ b/lisp/emacs-lisp/map-ynp.el @@ -265,7 +265,8 @@ read-answer-short "If non-nil, `read-answer' accepts single-character answers. If t, accept short (single key-press) answers to the question. If nil, require long answers. If `auto', accept short answers if -the function cell of `yes-or-no-p' is set to `y-or-n-p'." +`use-short-answers' is non-nil, or the function cell of `yes-or-no-p' +is set to `y-or-n-p'." :type '(choice (const :tag "Accept short answers" t) (const :tag "Require long answer" nil) (const :tag "Guess preference" auto)) @@ -304,7 +305,8 @@ read-answer When `use-dialog-box' is t, pop up a dialog window to get user input." (let* ((short (if (eq read-answer-short 'auto) - (eq (symbol-function 'yes-or-no-p) 'y-or-n-p) + (or use-short-answers + (eq (symbol-function 'yes-or-no-p) 'y-or-n-p)) read-answer-short)) (answers-with-help (if (assoc "help" answers) diff --git a/src/fns.c b/src/fns.c index c16f9c6399..7ab4bb525d 100644 --- a/src/fns.c +++ b/src/fns.c @@ -2873,6 +2873,11 @@ DEFUN ("yes-or-no-p", Fyes_or_no_p, Syes_or_no_p, 1, 1, 0, return obj; } + 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); @@ -5904,6 +5909,15 @@ syms_of_fns (void) this variable. */); use_file_dialog = true; + DEFVAR_BOOL ("use-short-answers", use_short_answers, + doc: /* Non-nil means `yes-or-no-p' uses shorter answers "y" or "n". +It's discouraged to use single-key answers because `yes-or-no-p' is +intended to be used when it's thought that you should not respond too +quickly, and giving the wrong answer would have serious consequences. +When non-nil, it uses `y-or-n-p'. In this case it means also obeying +the value of `y-or-n-p-use-read-key'. */); + use_short_answers = false; + defsubr (&Sidentity); defsubr (&Srandom); defsubr (&Slength); --=-=-=--