From: JD Smith <jdtsmith@gmail.com>
To: emacs-devel@gnu.org
Subject: Recommendation for CAPF setup when you don't know completion string in advance
Date: Sat, 3 Apr 2021 18:23:28 -0400 [thread overview]
Message-ID: <E6BC3D85-0FE1-4510-A698-0829D5755FF1@gmail.com> (raw)
[-- 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 --]
next reply other threads:[~2021-04-03 22:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-03 22:23 JD Smith [this message]
2021-04-03 23:49 ` Recommendation for CAPF setup when you don't know completion string in advance 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
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=E6BC3D85-0FE1-4510-A698-0829D5755FF1@gmail.com \
--to=jdtsmith@gmail.com \
--cc=emacs-devel@gnu.org \
/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.