all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>, help-gnu-emacs@gnu.org
Subject: RE: `completing-read` without RET
Date: Fri, 11 Mar 2016 15:49:33 -0800 (PST)	[thread overview]
Message-ID: <dcd83c59-33ad-409a-9b01-842a0ae81b94@default> (raw)
In-Reply-To: <jwvbn6keiun.fsf-monnier+gmane.emacs.help@gnu.org>

> > If you hit TAB and there is only one matching candidate, the
> > OP wants that candidate to be chosen (returned).
> 
> Right, that's why I'm saying "use RET not TAB".  AFAIK (s)he never needs
> to use TAB in such completions, always using RET will give h(er|im) the
> behavior (s)he wants (either complete, or select the sole completion).

Naturally you left off the part that was significant here:

  There is a difference between (a) knowing that what you type
  is sufficient to choose a single candidate, and so you hit RET,
  and (b) not knowing whether there is only one match, and maybe
  not even knowing whether completion is lax or REQUIRE-MATCH is
  t, so you hit TAB.

(completing-read "Choose: " '("a" "aa" "b") nil t)

You type `a'.  You don't know what the candidates are, but you
guess that at least one begins with `a'.  If you hit RET then
you get the first candidate, `a'.  If you hit TAB then you see
that there are two matching candidates, `a' and `aa', and you
can choose whichever one you want.

There is NOT a sole candidate that matches your input `a' in
this case.  And what you said is not true in this case:
"either complete, or select the sole completion."  If you use
`a RET' then you get `a' - you see no completions, and what
you get is not the only match.

RET with REQUIRE-MATCHES = t does not respond to what was
requested, IIUC.

I interpret the OP request "doesn't need RET when only one
completion exists" as meaning that the OP (1) does not want
to have to use two keys when only one candidate matches, but
(2) s?he also wants completion - wants to see the matches
when there is more than one.

For vanilla Emacs, neither TAB nor RET does this - in the
general case you need to hit two keys: TAB to complete and
RET to choose.

As I said, if you KNOW that what you type matches only one
candidate then you can just hit RET - of course.  But that
is true regardless of the value of REQUIRE-MATCH.



  reply	other threads:[~2016-03-11 23:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-11 11:36 `completing-read` without RET egarrulo
2016-03-11 13:22 ` Stefan Monnier
2016-03-11 13:36   ` Stefan Monnier
2016-03-11 16:08     ` Drew Adams
2016-03-11 16:50       ` Stefan Monnier
2016-03-11 17:07         ` Drew Adams
2016-03-11 22:45           ` Stefan Monnier
2016-03-11 23:49             ` Drew Adams [this message]
     [not found]             ` <mailman.7363.1457740186.843.help-gnu-emacs@gnu.org>
2016-03-12 12:01               ` egarrulo
2016-04-11  9:01 ` Oleh Krehel

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=dcd83c59-33ad-409a-9b01-842a0ae81b94@default \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.