all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: JD Smith <jdtsmith@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Recommendation for CAPF setup when you don't know completion string in advance
Date: Sat, 3 Apr 2021 22:52:25 -0400	[thread overview]
Message-ID: <4B051055-CC87-419A-A106-C5F2A7674869@gmail.com> (raw)
In-Reply-To: <jwvh7knvss3.fsf-monnier+emacs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2337 bytes --]



> On Apr 3, 2021, at 7:49 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> 
>> So it’s a quandary: I won’t yet know `beg’ and `end’ until _after_
>> interacting with iPython.  Is there any way to “revise” ‘beg’ and ‘end’ in
>> a collection function returned from a CAPF?
> 
> Make your CAPF function return a beg..end that covers "the whole line"
> and which returns a completion table in the form of a function.
> That function will then defer to the iPython code for the grunt of its
> work and will return the "real" boundaries via the
> `completion-boundaries` method.  This will probably require some caching
> in the completion table so we don't call iPython too many times for
> a single completion (like once for `completion-boundaries`, once for
> `try-completion`, once for `all-completions`, etc…).

Thank you, that sounds quite promising.  I’ve started sketching out a mash-up of `completion-table-with-cache’ and `python-shell-completion-at-point’ and it seems it should work out.  

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?  I’d expect this function to live only throughout a single “event" of completion (M-tab or what have you).  But if that is indeed the case, I’m confused by why `completion-table-with-cache’ needs to test:

	(string-prefix-p last-arg arg ignore-case)

Won’t this _always_ be true for the custom-wrapped closure which `completion-table-with-cache’ constructs?  In other words, I can see two possibilities:

The cache is there simply to prevent the multiple subsequent collection function calls with the various action flags '(lambda, t, nil, boundaries, metadata) from repeating the expensive completion results lookup.
The cache must guard against _future_ calls of the collection function providing yet other not-yet-conceived-of completion strings.  

If #1 is true, wouldn’t all of these calls provide the same completion string? And if #2 is true, why does the completion engine “hold on” to a bespoke completion table function beyond the initial completion event which created it?  

Probably I’m missing the real #3.  This is relevant here for deciding when to re-consult IPython for new completion data. 


[-- Attachment #2: Type: text/html, Size: 4393 bytes --]

  reply	other threads:[~2021-04-04  2:52 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 [this message]
2021-04-04  3:20     ` Stefan Monnier
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B051055-CC87-419A-A106-C5F2A7674869@gmail.com \
    --to=jdtsmith@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.