From: "Drew Adams" <drew.adams@oracle.com>
To: "'Roland Winkler'" <winkler@gnu.org>, <12331@debbugs.gnu.org>
Subject: bug#12331: 24.1; completing-read when COLLECTION has exactly one element
Date: Sat, 1 Sep 2012 19:49:58 -0700 [thread overview]
Message-ID: <F10E0E3A774F40D4A7D24942C8D90663@us.oracle.com> (raw)
In-Reply-To: <87k3wdqk4w.fsf@gnu.org>
> If the arg COLLECTION of completing-read is a list with exactly one
> element and REQUIRE-MATCH is t, it can be quite redundant to go via
> the minibuffer. Would it make sense if in such a case
> completing-read could skip the minibuffer completely and simply
> return the car of COLLECTION?
Hi Roland.
`completing-read' offers possible candidates, but for lax completion it does not
require you to choose any of them - you can enter anything you like. So this
would make sense only for strict completion.
Depending on the context, even for strict completion it might sometimes be
surprising for a user not to see any prompt for completion. That is, if a user
expects to choose and is not offered a choice, that can be surprising/confusing.
Of course if for some given occurrence of `completing-read' in the code
COLLECTION is *always* a singleton, then there will be no surprise. But in that
case there is also presumably no reason to call `completing-read'. ;-)
As you say, "the surrounding code could also shortcut the call of
completing-read in such a case." That makes the most sense to me. It is, after
all, the surrounding code that reflects the design intention and can tell what
it might really mean in the current context to have only a singleton COLLECTION.
"But completing-read is possibly the better place to
implement such a behavior"
I don't think so, for the above reasons. Why do you think so?
"say via a particular value of REQUIRE-MATCH."
In that case it is the surrounding code that is making the decision, as it
should. That is better at least than systematically having *any* non-nil
REQUIRE-MATCH mean that a singleton COLLECTION returns the sole candidate.
What you suggest is then equivalent to this:
(if (and COLLECTION (not (cdr COLLECTION)))
(first-candidate COLLECTION)
(completing-read ...))
where `first-candidate' returns the candidate corresponding to (car COLLECTION),
doing the right thing for a list or string.
Is it worth moving such logic into `completing-read', adding a particular
non-nil value of REQUIRE-MATCH to implement it? I don't think so. FWIW, I use
`completing-read' a lot, and I have never had a use for such treatment.
Others might disagree...
Why don't you try it for a while, and see if you really find it useful?
[FWIW, in Icicles users can choose whether completion happens automatically
whenever there is a sole matching candidate (which is more general than the
cases where COLLECTION is a singleton). In that case, they need only hit RET,
not TAB RET. (And they can configure a delay for the automatic completion, to
give them time to change erroneous input, since this is about a sole match
against their input.) But being prompted and hitting RET is still more
interaction than what you are suggesting.]
next prev parent reply other threads:[~2012-09-02 2:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-02 1:38 bug#12331: 24.1; completing-read when COLLECTION has exactly one element Roland Winkler
2012-09-02 2:49 ` Drew Adams [this message]
2012-09-02 16:25 ` Roland Winkler
2012-09-03 13:42 ` Stefan Monnier
2012-09-03 16:26 ` Roland Winkler
2012-09-03 18:47 ` Stefan Monnier
2012-09-04 3:38 ` Stefan Monnier
2012-09-23 12:55 ` Roland Winkler
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=F10E0E3A774F40D4A7D24942C8D90663@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=12331@debbugs.gnu.org \
--cc=winkler@gnu.org \
/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.