* `completing-read` without RET @ 2016-03-11 11:36 egarrulo 2016-03-11 13:22 ` Stefan Monnier 2016-04-11 9:01 ` Oleh Krehel 0 siblings, 2 replies; 10+ messages in thread From: egarrulo @ 2016-03-11 11:36 UTC (permalink / raw To: help-gnu-emacs Is there a function with the same behaviour of `completing-read`, except that it doesn't need RET when only one completion exists? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: `completing-read` without RET 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-04-11 9:01 ` Oleh Krehel 1 sibling, 1 reply; 10+ messages in thread From: Stefan Monnier @ 2016-03-11 13:22 UTC (permalink / raw To: help-gnu-emacs > Is there a function with the same behaviour of `completing-read`, except > that it doesn't need RET when only one completion exists? Of course, it's called `completing-read'. You just have to configure its TAB key accordingly. I.e. rebind TAB in minibuffer-local-completion-map from `minibuffer-complete' to a new command which does what you want. Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: `completing-read` without RET 2016-03-11 13:22 ` Stefan Monnier @ 2016-03-11 13:36 ` Stefan Monnier 2016-03-11 16:08 ` Drew Adams 0 siblings, 1 reply; 10+ messages in thread From: Stefan Monnier @ 2016-03-11 13:36 UTC (permalink / raw To: help-gnu-emacs >> Is there a function with the same behaviour of `completing-read`, except >> that it doesn't need RET when only one completion exists? > Of course, it's called `completing-read'. > You just have to configure its TAB key accordingly. > I.e. rebind TAB in minibuffer-local-completion-map from > `minibuffer-complete' to a new command which does what you want. Oh, actually, I think I misunderstood your question and there's an even closer answer: just provide a neither-nil neither-t value for the `require-match' argument or `completing-read'. Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: `completing-read` without RET 2016-03-11 13:36 ` Stefan Monnier @ 2016-03-11 16:08 ` Drew Adams 2016-03-11 16:50 ` Stefan Monnier 0 siblings, 1 reply; 10+ messages in thread From: Drew Adams @ 2016-03-11 16:08 UTC (permalink / raw To: Stefan Monnier, help-gnu-emacs > >> Is there a function with the same behaviour of `completing-read`, except > >> that it doesn't need RET when only one completion exists? > > > Of course, it's called `completing-read'. > > You just have to configure its TAB key accordingly. > > I.e. rebind TAB in minibuffer-local-completion-map from > > `minibuffer-complete' to a new command which does what you want. > > Oh, actually, I think I misunderstood your question and there's an even > closer answer: just provide a neither-nil neither-t value for the > `require-match' argument or `completing-read'. No, I don't think so. (completing-read "Choose: " '("a") nil 'foobar) Choose: Nothing happens. Choose: TAB Choose: a Nothing happens. Choose: a Nothing happens. Choose: a TAB Nothing happens. --- FWIW, If you use Icicles, if you set option `icicle-top-level-when-sole-completion-flag' to non-nil then completion (e.g. TAB) chooses the only match for your input. In the examples above where TAB is used, the result is the same as hitting RET: the sole match (in this case also the sole candidate) is chosen. But beware that you might not always want this behavior (which is why it is not the default behavior). If you accidentally type the wrong thing then you don't get a chance to change your mind. (Of course, that's what you've said you are after: quicker choosing.) ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: `completing-read` without RET 2016-03-11 16:08 ` Drew Adams @ 2016-03-11 16:50 ` Stefan Monnier 2016-03-11 17:07 ` Drew Adams 0 siblings, 1 reply; 10+ messages in thread From: Stefan Monnier @ 2016-03-11 16:50 UTC (permalink / raw To: help-gnu-emacs >> >> Is there a function with the same behaviour of `completing-read`, except >> >> that it doesn't need RET when only one completion exists? >> > Of course, it's called `completing-read'. >> > You just have to configure its TAB key accordingly. >> > I.e. rebind TAB in minibuffer-local-completion-map from >> > `minibuffer-complete' to a new command which does what you want. >> Oh, actually, I think I misunderstood your question and there's an even >> closer answer: just provide a neither-nil neither-t value for the >> `require-match' argument or `completing-read'. > No, I don't think so. You're right, it's when require-match is t. > Choose: a TAB > Nothing happens. Don't use TAB, use RET. Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: `completing-read` without RET 2016-03-11 16:50 ` Stefan Monnier @ 2016-03-11 17:07 ` Drew Adams 2016-03-11 22:45 ` Stefan Monnier 0 siblings, 1 reply; 10+ messages in thread From: Drew Adams @ 2016-03-11 17:07 UTC (permalink / raw To: Stefan Monnier, help-gnu-emacs > You're right, it's when require-match is t. > > > Choose: a TAB > > Nothing happens. > > Don't use TAB, use RET. Sure, but that's not what the OP requested. 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. If you hit TAB and there is only one matching candidate, the OP wants that candidate to be chosen (returned). That's my understanding of the request. Vanilla `completing-read' does not offer that possibility (feature). ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: `completing-read` without RET 2016-03-11 17:07 ` Drew Adams @ 2016-03-11 22:45 ` Stefan Monnier 2016-03-11 23:49 ` Drew Adams [not found] ` <mailman.7363.1457740186.843.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 10+ messages in thread From: Stefan Monnier @ 2016-03-11 22:45 UTC (permalink / raw To: help-gnu-emacs > 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). Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: `completing-read` without RET 2016-03-11 22:45 ` Stefan Monnier @ 2016-03-11 23:49 ` Drew Adams [not found] ` <mailman.7363.1457740186.843.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 10+ messages in thread From: Drew Adams @ 2016-03-11 23:49 UTC (permalink / raw To: Stefan Monnier, help-gnu-emacs > > 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. ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <mailman.7363.1457740186.843.help-gnu-emacs@gnu.org>]
* Re: `completing-read` without RET [not found] ` <mailman.7363.1457740186.843.help-gnu-emacs@gnu.org> @ 2016-03-12 12:01 ` egarrulo 0 siblings, 0 replies; 10+ messages in thread From: egarrulo @ 2016-03-12 12:01 UTC (permalink / raw To: help-gnu-emacs Dear Drew and Stefan, thank you for your helpful replies. Regrettably, what I was looking for, wouldn't actually work for future use cases, therefore using RET or TAB is still the best solution. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: `completing-read` without RET 2016-03-11 11:36 `completing-read` without RET egarrulo 2016-03-11 13:22 ` Stefan Monnier @ 2016-04-11 9:01 ` Oleh Krehel 1 sibling, 0 replies; 10+ messages in thread From: Oleh Krehel @ 2016-04-11 9:01 UTC (permalink / raw To: egarrulo; +Cc: help-gnu-emacs egarrulo <egarrulo@gmail.com> writes: > Is there a function with the same behaviour of `completing-read`, > except that it doesn't need RET when only one completion exists? I've made an implementation for my bookmarks a long time ago: https://github.com/abo-abo/headlong I still use it and it works fine. As soon as there is only one match, the completion will exit. Example: (headlong-with (completing-read "Test: " '("a" "b" "c") nil t)) Hopefully it's still useful, I was going through this mailing list just now. Oleh ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-04-11 9:01 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 [not found] ` <mailman.7363.1457740186.843.help-gnu-emacs@gnu.org> 2016-03-12 12:01 ` egarrulo 2016-04-11 9:01 ` Oleh Krehel
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.