Subject: bug#28525: 26.0.60; dired-delete-file: Accept y/n if yes-or-no-p is aliased to y-or-n-p

From: Drew Adams <[email-masked]>
Date: Sun, 1 Oct 2017 16:15:56 -0700 (PDT)

FWIW: I don't think that Emacs should test for
function aliases and change its behavior accordingly.

I don't think users should be encouraged to alias
`yes-or-no-p' to `y-or-n-p'.  That's a bad idea
_in general_, IMO, even if it some users might
find it's appropriate for them.

I think that making Emacs code automatically
recognize such an alias just encourages such
(bad) practice on the part of users.

----

FWIW2: It can, however, be helpful to let users
override a design choice of `y-or-n-p' or
`yes-or-no-p' _for a given calling function_
(as opposed to globally).  I've written library
Yes-No, to provide such a feature.

https://www.emacswiki.org/emacs/Yes-No

`yes-no.el' provides no behavior change, except for
code that wants to let users decide.  For that, the
author just provides the symbol for the calling
function as an additional argument to the prompting
function.

For example, the behavior of this call from function
`foo' is unchanged: (yes-or-no-p "Agree? ").

But this call from function `foo' lets users decide:
(yes-or-no-p "Agree? " 'foo).

In the latter case, a user can answer `yes', `no',
or `use-y-or-n' (which is available with completion).
If the latter then the call immediately switches to
using `y-or-n-p', and all `yes-or-no-p' calls from
function `foo' from then on are redirected to use
`y-or-n-p' instead.

Similarly, this call from `bar' lets users decide:
(y-or-n-p "Agree? " 'bar).

Here, a user can answer using character `y', `n',
or `e'.  Answer `e' switches immediately to using
`yes-or-no-p', and all `y-or-n-p' calls from
function `bar' from then on are redirected to
`yes-or-no-p'.

When either redirection is in effect, a user can
of course redirect back again, to the original
behavior (programmer-defined).

And when either redirection is in effect, a user
can reset the call to use only the default behavior
from then on.

To reset a `yes-or-no-p' prompt (redirected from
`y-or-n-p') a user chooses input `reset-to-default'
(with completion).  To reset a `y-or-n-p' prompt
(redirected from `yes-or-no-p') a user uses character
`^'.

A user option lets a user turn off respect of the
optional CALLER arg.  If nil then there is no change
in behavior from vanilla Emacs: no other inputs are
allowed besides yes/no or y/n.  So even if a library
author provides CALLER, to let users decide on a
case-by-case basis, a user can choose not to allow
herself to do so.

(Obviously, a library that uses argument CALLER
must require library `yes-no.el'.)

The behavior is implemented by putting the symbol
for the prompting function to redirect to on the
symbol for the calling function, as the value of
property `yes/no-prompting'.  For example, if a
user chooses `use-y-or-n' from `yes-or-no-p'
called from `foo', we do this to redirect such
calls to prompt with `y-or-n-p':

(put 'foo 'yes/no-prompting 'y-or-n-p)

Resetting to the default behavior just puts
nil as the property value.