unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Canonical way to add a pre-filter to completing-read
@ 2018-05-10 13:09 Kaushal Modi
  2018-05-10 14:10 ` Drew Adams
  2018-05-10 15:21 ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Kaushal Modi @ 2018-05-10 13:09 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hello,

I want to use completing-read to provide a "pre-filter" to narrow down the
completion list.

My real use use is to take the symbol-at-point as the pre-filter to narrow
down in a list of all identifiers. For a real example, the symbol name is
"walkDirRec", but the completion list contains "os.walkDirRec".. so I am
trying to figure out how to use completing-read with that.

(I am aware that I can use the counsel library to make this easier, but was
looking for a way for completing-read to Just Work(TM).)

So here are some minimal examples to explain my conundrum..

Below works exactly as I want.. but the docs and manual say that
INITIAL-INPUT is deprecated.

(completing-read "Entry: " '("abc" "bcd" "cde") nil :require-match "bc")
;INITIAL-INPUT deprecated, but works as I want

Above will show in the completion list with just the filtered items
matching "bc":

    abc
    bcd

So following the manual, I tried using the DEF (default) argument instead,
but that doesn't work as I want.. that just throws in that DEF value
verbatim to the completion list..

(completing-read "Entry: " '("abc" "bcd" "cde") nil :require-match nil nil
"bc") ;Using DEF does not work.. it just inserts that as one more element
in the completion list

Above will end up with this list:

    bc
    abc
    bcd
    cde

So the DEF approach is not useful unless the DEF value is matching exactly
with one of the items in COLLECTION.

So, what would be the right way, i.e. not using the deprecated
INITIAL-INPUT?

Thanks.
-- 

Kaushal Modi


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-10 22:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-10 13:09 Canonical way to add a pre-filter to completing-read Kaushal Modi
2018-05-10 14:10 ` Drew Adams
2018-05-10 17:36   ` Kaushal Modi
2018-05-10 15:21 ` Stefan Monnier
2018-05-10 17:19   ` Kaushal Modi
2018-05-10 22:05     ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).