Summary: Suggest `yes-or-mumble-p'
> The inconvenience can be having to type "no" to cancel `yes-or-no-p'.
> If you would prefer to have an empty response (hitting `RET') or any
> other input to be "no" and still require the full word "yes" use this
> function as an alias for `yes-or-no-p'.
> (defun my-yes-or-mumble-p (prompt)
> "PROMPT user with a yes-or-no question, but only test for yes."
> (if (string= "yes"
> (concat prompt "(yes or no) "))))
> (defalias 'yes-or-no-p 'my-yes-or-mumble-p)
‘y-or-n-p’ Emacs’s way of asking a yes-or-no question, usually to get your confirmation for something you requested.
‘yes-or-no-p’ is Emacs’s way of asking an important yes-or-no question. You must type a full
‘no’ to answer. See yes-or-no-p.
The Emacs designers decided which questions are important enough to make you answer with a full word. They based their decisions on years of experience with user problems. You are asked to type a full word not to annoy you but to save you from shooting yourself in the foot.
However, Emacs design decisions need to be relatively conservative, and they need to fit the needs of the average user, as well as the EmacsNewbie. Some people feel that
‘yes-or-no-p’ questions are never important enough to warrant typing two or three characters, and they prefer to substitute
‘yes-or-no-p’ everywhere to save one or two characters. If you want to do that, put this in your init file (
(defalias 'yes-or-no-p 'y-or-n-p)
‘yes-or-no-p’ questions can be disabled. For example, RevertBuffer asks before re-reading a file, but you can set user option
‘revert-without-query’ to record files that you want to be able to revert without confirming.
And you can always use
‘defadvice’ (see AdvisingFunctions) to modify a command, inhibiting it from asking yes or no. But if you do this, be careful that it doesn’t also catch lower-level questions. And see also AdviceVsHooks before you decide to advise a function.
(defadvice WHATEVER (around stfu compile activate) (flet ((yes-or-no-p (&rest args) t) (y-or-n-p (&rest args) t)) ad-do-it))
Or you can predefine the answers for yes-or-no-p so you can select them with M-p.
(mapcar (lambda (elt) (add-to-list 'yes-or-no-p-history elt)) '("no" "yes"))
The inconvenience can be having to type “no” to cancel
If you would prefer to have an empty response (hitting
‘RET’) or any other input to be “no” and still require the full word “yes” use this function as an alias for
(defun my-yes-or-mumble-p (prompt) "PROMPT user with a yes-or-no question, but only test for yes." (if (string= "yes" (downcase (read-from-minibuffer (concat prompt "(yes or no) ")))) t nil)) (defalias 'yes-or-no-p 'my-yes-or-mumble-p)