New variable 'use-short-answers' to use 'y-or-n-p' instead of 'yes-or-no-p'
* lisp/cus-start.el: Add use-short-answers. * lisp/emacs-lisp/map-ynp.el (read-answer): Handle use-short-answers. (read-answer-short): Add use-short-answers to docstring. * src/fns.c (Fyes_or_no_p): Call y-or-n-p if use_short_answers is true. (syms_of_fns): Add DEFVAR_BOOL use-short-answers (bug#46594).
This commit is contained in:
parent
056b468f74
commit
297c0e0306
4 changed files with 24 additions and 2 deletions
5
etc/NEWS
5
etc/NEWS
|
@ -2414,6 +2414,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. The same variable also affects the function 'read-answer'.
|
||||
|
||||
+++
|
||||
** 'set-window-configuration' now takes an optional 'dont-set-frame'
|
||||
parameter which, when non-nil, instructs the function not to select
|
||||
|
|
|
@ -302,6 +302,7 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
|
|||
;; 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)
|
||||
|
|
|
@ -265,7 +265,8 @@ C-g to quit (cancel the whole command);
|
|||
"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 @@ Return a long answer even in case of accepting short ones.
|
|||
|
||||
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)
|
||||
|
|
14
src/fns.c
14
src/fns.c
|
@ -2873,6 +2873,11 @@ if `last-nonmenu-event' is nil, and `use-dialog-box' is non-nil. */)
|
|||
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 @@ that disables the use of a file dialog, regardless of the value of
|
|||
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, so you take time and perhaps think more about the answer.
|
||||
When non-nil, then `yes-or-no-p' uses `y-or-n-p' to read an answer.
|
||||
The same variable also affects the function `read-answer'. */);
|
||||
use_short_answers = false;
|
||||
|
||||
defsubr (&Sidentity);
|
||||
defsubr (&Srandom);
|
||||
defsubr (&Slength);
|
||||
|
|
Loading…
Add table
Reference in a new issue