emacs-devel
[Top][All Lists]
Advanced

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

Re: Recommendation for CAPF setup when you don't know completion string


From: Stefan Monnier
Subject: Re: Recommendation for CAPF setup when you don't know completion string in advance
Date: Sat, 03 Apr 2021 23:20:12 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> There’s one thing I’m unclear on: how long does the completion engine in
> Emacs hold on to a collection aka "completion table" function?

As long as needed.  It all depends on the situation.
E.g. if the completion table is passed to `completing-read`, then it
will be used during the whole lifetime of the minibuffer.

When the completion table comes from CAPF, it's usually used for a much
shorter duration, among other things because we have to regularly call
CAPF in order to detect when changes to the buffer's content or to
`point` have caused a change in the kind of things we're completing.

> I’d expect this function to live only throughout a single “event" of
> completion (M-tab or what have you).

It will often live a little longer, but not much, usually, indeed.
This said, it all depends on the UI.  I can imagine a UI where CAPF is
called once and then the completion is performed within a kind of modal
interface which insures that CAPF doesn't need to be re-called, in which
case the completion-table may be used for quite a while, just as is the
case in minibuffers.

> I’m confused by why `completion-table-with-cache’ needs to test:
>
>       (string-prefix-p last-arg arg ignore-case)

This was designef for completion-tables in general (rather than only
those used in a particular kind of situation).  Furthermore, even
a single M-TAB completion may easily query the completion table several
times with different prefix strings (because of `completion-styles`).

> Won’t this _always_ be true for the custom-wrapped closure which
> `completion-table-with-cache’ constructs?

I'm pretty sure there will be cases where this is not the case, no.

E.g. you may have a first call for the `basic` completion style with
a prefix "foo" which ends up returning nothing, after which we fall back
to `substring` completion style and hence query the completion table
again with a prefix of "".


        Stefan




reply via email to

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