help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Canonical way to add a pre-filter to completing-read


From: Stefan Monnier
Subject: Re: Canonical way to add a pre-filter to completing-read
Date: Thu, 10 May 2018 11:21:42 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> (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

Could you clarify exactly here:
- "will show"... when the user does what?
  Just calling the above `completing-read` won't show any list of completions
- When I hit ? at the prompt, I indeed get a list of completions, but
  that list only includes `bcd` because the default completion style
  does not include `substring`.  So your use/test case is different from
  the default.

Let's say the user does

    M-: (km-completion "Entry: " '("abc" "bcd" "cde") "bc") RET

and then types `a` (and then hits `?` to see the list of remaining
completions, or maybe he uses icomplete-mode to always see the list of
remaining candidates).  What do you want the list of completions to be
at that point?

Some things you can do with the standard completion-UI:
- setup your completion table such that it uses `substring` completion
  by default.
- use `completion-table-in-turn` with the first table being a sub-table
  which only includes the entries that match "bc".


-- Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]