* State and caching in completion tables
@ 2023-11-22 19:36 Spencer Baugh
0 siblings, 0 replies; only message in thread
From: Spencer Baugh @ 2023-11-22 19:36 UTC (permalink / raw)
To: emacs-devel
If I have a completion table which wants to store internal state - in my
case, for caching data used to generate completions - is there a good
place to do that?
Ideally, the state (in my case, a cache) would only be preserved for a
given call to completing-read. If a new call to completing-read starts,
I'd like the state to be reset.
Usually, I would do this by having a function which creates a fresh
completion table with fresh state, and call that each time to generate
the completion table to pass to completing-read. So state would
naturally be preserved only for a given completing-read, because each
completing-read would use a new completion table.
But more specifically, I'm adding a new file-name-handler. As a
file-name-handler, I don't get the chance to return a fresh completion
table for each read-file-name invocation; I only get to handle
file-name-all-completions and file-name-completion. Given that, I don't
know where my file-name-all-completions and file-name-completion
functions could store some state which is specific to a read-file-name
call.
I want to store state for a read-file-name call to avoid making
duplicate network requests each time file-name-all-completions and
file-name-completion are called; instead I'd like to store the result I
got the first time. I'm happy with any way of achieving that.
Is there a natural place for a completion table to store state which is
specific to a given invocation of completing-read?
Or failing that more general solution, a way for a file-name-handler to
save state for a given read-file-name call?
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-22 19:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-22 19:36 State and caching in completion tables Spencer Baugh
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).