emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Confused by y-or-n-p


From: Juri Linkov
Subject: Re: Confused by y-or-n-p
Date: Mon, 28 Dec 2020 19:09:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> And while we're there we could also try to relieve some of our .emacs
> files (mine included) of those
>
> (defalias 'yes-or-no-p 'y-or-n-p)
>
> by providing an option that accomplishes the necessary mapping.

Maybe something like this:

diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 2e8872341f..4376f9835e 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/src/fns.c b/src/fns.c
index 2de1d26dd3..128bd7af55 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);
 
@@ -5791,6 +5796,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 via email to

[Prev in Thread] Current Thread [Next in Thread]