all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Juri Linkov <juri@linkov.net>, Tino Calancha <tino.calancha@gmail.com>
Cc: contovob@tcd.ie, 30073@debbugs.gnu.org
Subject: bug#30073: 27.0.50; dired-do-delete ignores customization for short answers
Date: Mon, 15 Jan 2018 09:01:24 -0800 (PST)	[thread overview]
Message-ID: <e68e905a-6eca-4a79-8027-60d9f251f41b@default> (raw)
In-Reply-To: <874lno10di.fsf@mail.linkov.net>

> Neither (fset 'yes-or-no-p 'y-or-n-p) nor
> (advice-add 'yes-or-no-p :override #'y-or-n-p)
> are good methods of customization, so dired-deletion-confirmer
> and dired-recursive-deletion-confirmer are equally bad.
> 
> What I'm thinking about is introducing a boolean customizable variable
> that would define whether abbreviated answers are preferred by the user.
> Then a new minibuffer-reading function could accept a list of
> abbreviations and map them to long full answers.
> 
> Something like ‘read-multiple-choice’ or ‘map-y-or-n-p’, but that
> would allow either long or short answers depending on customization
> like ‘rmail-confirm-expunge’, ‘url-confirmation-func’,
> ‘org-confirm-shell-link-function’, ‘org-confirm-elisp-link-function’,
> or on its argument like ‘strong-query’ in ‘custom-command-apply’.
> 
> WDYT?

(I haven't been following this thread.  Apologies if I
misunderstand/misspeak.)

First, why is this being discussed (only) in the context of
Dired?  Isn't this something to consider more generally?

Do we all agree on the following points?

1. Users advising the yes/no confirmation-prompt functions
   is not a good solution to users wanting to sometimes (or
   always) use a different prompting approach from the one
   chosen by the author of the code that prompts.

2. Choosing a single prompt approach (e.g. `y-or-n-p' or
   `yes-or-no-p') for all contexts might be appropriate for
   some users, but it is probably not a great idea in general.

3. Even a given user might appreciate that a given prompting
   context asks them using the slow approach (`yes-or-no-p')
   at first, or most of the time, but she might sometimes,
   or even generally after some experience, prefer that that
   prompting context use a faster approach (e.g. `y-or-n-p').

   IOW, it would be good for a user to be able to easily
   specify anytime, for a given prompting context, which
   prompting approach to use.

An code author chooses which confirmation-prompting approach
s?he thinks is most appropriate for most users in a given
context.  Typically, contexts where the wrong answer can have
graver consequences get the `yes-or-no-p' approach.

IIUC, this bug discussion is looking into the possibility of
giving users a simple way to choose one or the other approach
generally, i.e., for use everywhere, or at least everywhere
within some overall context (e.g. Dired).  Is that right?
If so, that responds to #1 above, but not to #2 (or #3).

Along those lines, instead of a Boolean value for a user
option, to choose one or the other approach everywhere,
perhaps an alist value would be good, with the alist entries
(somehow) characterizing the prompting approach to use for
different contexts (defined how?).

Even so, though helpful, that would not really be a good
response to #3 above.

______

I've proposed the following before, but I'll mention it again.
It doesn't respond to #1 or #2, so it is likely complementary
to what I think you're proposing, which is a user option to
choose generally, as an alternative to advising.  That is, it
could be complementary.

The first thing needed here is for confirmation-prompting
functions to be able to (and preferably to do it) specify the
current context in which they are called.  That will give
users a way to specify what they want for a particular such
context.

A start in that direction is to provide to the prompting
function the name of the function that is calling it.

No, that won't distinguish particular calls (occurrences).
But it will be a good start.

For example, if `y-or-n-p' is called from function `foo',
and if the call records that fact, then a user can specify
that all `y-or-n-p' calls from `foo' should be handled as
if they were `yes-or-no-p' calls.

This means adding an optional argument to `y-or-n-p' and
`yes-or-no-p' (and other confirmation-prompting functions).

If function `foo' wants to give a user control then it
would use `(y-or-n-p "Do you agree? " 'foo)' instead of
just `(y-or-n-p "Do you agree? ")'.  Likewise, for
`yes-or-no-p'.  That's the only change needed, to give
users control here.

I've implemented this in library `yes-no.el'.  I think it's
a good start.  Combined with a user option as discussed
above, and overriding the option's more general behavior,
it could offer quite a lot of user control unobtrusively
and straightforwardly.

`yes-no.el' works by allowing, besides the y/n and yes/no
responses, a response that says "Switch to using the other
prompting method from now on".  It thus lets users change
the prompting function interactively for the given calling
function.

In addition or alternatively, users can specify such
preferences using a user option.  Specifying behavior
interactively updates the option value and saves it.  IOW,
interactive specification is an on-the-fly shortcut to
using Customize.

Rather than describe here just what it does and how, I
invite you to have a look at the Commentary or code of
the library, if you're interested.  But the easiest way
to see what it does is just to try it.

https://www.emacswiki.org/emacs/download/yes-no.el

I think it responds to the twin needs for (1) code author
being able to judge which behavior is preferable for most
users most of the time and (2) user being able to change
the behavior anytime.





  parent reply	other threads:[~2018-01-15 17:01 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10 21:41 bug#30073: 27.0.50; dired-do-delete ignores customization for short answers Juri Linkov
2018-01-11  3:00 ` Basil L. Contovounesios
2018-01-11 15:52   ` Eli Zaretskii
2018-01-11 17:34     ` Basil L. Contovounesios
2018-01-11 18:01       ` Eli Zaretskii
2018-01-11 19:39         ` Basil L. Contovounesios
2018-01-11 21:57         ` Juri Linkov
2018-01-11 21:54     ` Juri Linkov
2018-01-12  9:57       ` Eli Zaretskii
2018-01-13 22:38         ` Juri Linkov
2018-01-14 11:01           ` Tino Calancha
2018-01-14 22:53             ` Juri Linkov
2018-01-15  5:19               ` Eli Zaretskii
2018-01-15 23:02                 ` Juri Linkov
2018-01-16 17:56                   ` Eli Zaretskii
2018-01-17 22:56                     ` Juri Linkov
2018-01-18 21:11                       ` Juri Linkov
2018-01-15 17:01               ` Drew Adams [this message]
2018-01-15 23:13                 ` Juri Linkov
2018-01-16  0:48                   ` Drew Adams
2018-01-17 22:03                     ` Juri Linkov
2018-01-18  3:36                       ` Eli Zaretskii
2018-01-18 21:12                         ` Juri Linkov
2018-01-21 21:46                           ` Juri Linkov
2018-01-25 18:04                             ` Drew Adams
2018-01-25 21:20                               ` Juri Linkov
2018-01-25 21:48                                 ` Drew Adams
2018-01-26  7:57                                 ` Eli Zaretskii
2018-01-27 21:20                                   ` Juri Linkov

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

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

  git send-email \
    --in-reply-to=e68e905a-6eca-4a79-8027-60d9f251f41b@default \
    --to=drew.adams@oracle.com \
    --cc=30073@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    --cc=juri@linkov.net \
    --cc=tino.calancha@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.