unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Recommendation for CAPF setup when you don't know completion string in advance
@ 2021-04-03 22:23 JD Smith
  2021-04-03 23:49 ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: JD Smith @ 2021-04-03 22:23 UTC (permalink / raw)
  To: emacs-devel

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

I’m endeavoring to more fully link completion in python-shell-mode directly to those provided by iPython, when it is running as the inferior shell.  Modern versions of iPython have fantastic built-in completion capabilities when run in a terminal, but they are not well exploited by python.el.  

Here’s the logical flow I’m trying to achieve:

Take the entire line from point back to the iPython prompt (call it `line’), and hand it to iPython’s internal completer:  get_ipython().Completer.complete(line_buffer=line,cursor_pos=len(line)): 
This returns both the sub-text iPython has chosen to complete (a trailing portion of the line), and a list of completions.  
Use this sub-text length to set the `beg’ and `end’ parameters that a CAPF needs to return, and the returned completions list as the `collection’.

In principle I could just do this directly in the CAPF, i.e. interact with the iPython process, compute `beg’ and `end’, return them with the completion list as the collection. But as Programmed Completions node says: 

Supplying a function for collection is strongly recommended if generating the list of completions is an expensive operation. Emacs may internally call functions in completion-at-point-functions many times, but care about the value of collection for only some of these calls.

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?  If not, other ideas I could try?

Thanks.

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-05-11 16:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).