unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: 46594@debbugs.gnu.org
Subject: bug#46594: Use short answers
Date: Wed, 17 Feb 2021 20:59:47 +0200	[thread overview]
Message-ID: <87im6qikpo.fsf@mail.linkov.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 512 bytes --]

Tags: patch

As discussed in
https://lists.gnu.org/archive/html/emacs-devel/2020-12/msg01915.html
here is an option that accomplishes the mapping of
(defalias 'yes-or-no-p 'y-or-n-p)

> It's a bit more than just
>
>   Non-nil means `yes-or-no-p' uses shorter answers "y" or "n".
>
> because short circuiting it to 'y-or-n-p' means it will also obey
> 'y-or-n-p-use-read-key'.

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?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: use-short-answers.patch --]
[-- Type: text/x-diff, Size: 1808 bytes --]

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..6be57a4fca 100644
--- a/lisp/emacs-lisp/map-ynp.el
+++ b/lisp/emacs-lisp/map-ynp.el
@@ -304,7 +304,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..f51ef2781d 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,10 @@ 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".  */);
+  use_short_answers = false;
+
   defsubr (&Sidentity);
   defsubr (&Srandom);
   defsubr (&Slength);

             reply	other threads:[~2021-02-17 18:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-17 18:59 Juri Linkov [this message]
2021-02-22 15:13 ` bug#46594: Use short answers Lars Ingebrigtsen
2021-02-22 17:13   ` bug#46594: [External] : " Drew Adams
2021-02-24 18:44     ` Juri Linkov
2021-02-24 19:26       ` Eli Zaretskii
2021-02-24 19:49         ` Juri Linkov
2021-02-24 20:27           ` Eli Zaretskii
2021-02-24 20:50             ` Juri Linkov
2021-02-25 15:04               ` Eli Zaretskii
2021-02-25 18:45                 ` Juri Linkov
2021-02-24 23:55       ` Drew Adams
2021-02-25  9:20         ` Juri Linkov
2021-02-25 16:40           ` Drew Adams

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87im6qikpo.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=46594@debbugs.gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).