From: Stefan Monnier <monnier@iro.umontreal.ca>
To: JD Smith <jdtsmith@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Recommendation for CAPF setup when you don't know completion string in advance
Date: Sat, 03 Apr 2021 23:20:12 -0400 [thread overview]
Message-ID: <jwv1rbqwxpe.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <4B051055-CC87-419A-A106-C5F2A7674869@gmail.com> (JD Smith's message of "Sat, 3 Apr 2021 22:52:25 -0400")
> 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
next prev parent reply other threads:[~2021-04-04 3:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-03 22:23 Recommendation for CAPF setup when you don't know completion string in advance JD Smith
2021-04-03 23:49 ` Stefan Monnier
2021-04-04 2:52 ` JD Smith
2021-04-04 3:20 ` Stefan Monnier [this message]
2021-04-04 15:29 ` JD Smith
2021-05-11 3:33 ` JD Smith
2021-05-11 4:04 ` Stefan Monnier
2021-05-11 13:42 ` JD Smith
2021-05-11 15:52 ` Stefan Monnier
2021-05-11 14:37 ` Daniel Mendler
2021-05-11 15:57 ` Stefan Monnier
2021-05-11 16:10 ` Daniel Mendler
2021-05-11 16:54 ` Stefan Monnier
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv1rbqwxpe.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=jdtsmith@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).