* bug#47575: python-shell-completion-at-point omits %magic commands
@ 2021-04-03 4:21 JD Smith
2021-05-06 11:05 ` Lars Ingebrigtsen
0 siblings, 1 reply; 6+ messages in thread
From: JD Smith @ 2021-04-03 4:21 UTC (permalink / raw)
To: 47575
[-- Attachment #1: Type: text/plain, Size: 1257 bytes --]
When using iPython as the inferior shell of python.el, `python-shell-completion-at-point' skips a `simple-operator’ regexp which include ?%. In iPython, magic commands begin with ‘%’, and the fallback completion method happily provides them for completion:
In [67]: __PYTHON_EL_get_completions("%ru")
Out[91]: ['%%ruby', '%run’]
python-shell-completion-at-point trims this to “ru”, which also provides the same completions above, but which `try-completions’ rejects as non-matching. So that:
In [1]: %ru[Tab]
Leads to “No matches”.
The solution would be to not skip the ?% character if it is at the start of the line. The modulo operator cannot occur there in any case.
One other point: the fallback mechanism sends and compiles the relatively long __PYTHON_EL_get_completions function each and every time it is called. Because of how CAPF functions, this actually occurs 3 times in quick succession with a single Tab press like the above! A more performant approach (esp. over remote buffer connections) would be to just call __PYTHON_EL_get_completions, and check for failure, setting up that function again if necessary. This would parallel the readline completer native method, which is only setup once.
[-- Attachment #2: Type: text/html, Size: 2481 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#47575: python-shell-completion-at-point omits %magic commands
2021-04-03 4:21 bug#47575: python-shell-completion-at-point omits %magic commands JD Smith
@ 2021-05-06 11:05 ` Lars Ingebrigtsen
2021-05-06 13:38 ` Andrii Kolomoiets
0 siblings, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-06 11:05 UTC (permalink / raw)
To: JD Smith; +Cc: 47575, Andrii Kolomoiets
JD Smith <jdtsmith@gmail.com> writes:
> When using iPython as the inferior shell of python.el,
> `python-shell-completion-at-point' skips a `simple-operator’ regexp which include
> ?%. In iPython, magic commands begin with ‘%’, and the fallback completion
> method happily provides them for completion:
>
> In [67]: __PYTHON_EL_get_completions("%ru")
> Out[91]: ['%%ruby', '%run’]
>
> python-shell-completion-at-point trims this to “ru”, which also provides the same
> completions above, but which `try-completions’ rejects as non-matching. So that:
>
> In [1]: %ru[Tab]
>
> Leads to “No matches”.
>
> The solution would be to not skip the ?% character if it is at the start of the line. The
> modulo operator cannot occur there in any case.
The simple-operator was added to fix bug#37808 in:
commit 51d3c95147efa80fd3e09c90705439517e8fb6ca
Author: Andrii Kolomoiets <andreyk.mad@gmail.com>
AuthorDate: Fri Oct 18 16:04:32 2019 +0300
I've added Andrii to the CCs.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#47575: python-shell-completion-at-point omits %magic commands
2021-05-06 11:05 ` Lars Ingebrigtsen
@ 2021-05-06 13:38 ` Andrii Kolomoiets
2022-06-29 10:46 ` Lars Ingebrigtsen
0 siblings, 1 reply; 6+ messages in thread
From: Andrii Kolomoiets @ 2021-05-06 13:38 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 47575, JD Smith
Lars Ingebrigtsen <larsi@gnus.org> writes:
> JD Smith <jdtsmith@gmail.com> writes:
>
>> The solution would be to not skip the ?% character if it is at the start of the line. The
>> modulo operator cannot occur there in any case.
Well :)
>>> foo=1
>>> bar=2
>>> foo\
... %bar
1
Though I don't think it's the common use case.
--
Andrii
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#47575: python-shell-completion-at-point omits %magic commands
2021-05-06 13:38 ` Andrii Kolomoiets
@ 2022-06-29 10:46 ` Lars Ingebrigtsen
2022-06-29 20:31 ` Andrii Kolomoiets
0 siblings, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-29 10:46 UTC (permalink / raw)
To: Andrii Kolomoiets; +Cc: 47575, JD Smith
Andrii Kolomoiets <andreyk.mad@gmail.com> writes:
>>> The solution would be to not skip the ?% character if it is at the
>>> start of the line. The
>>> modulo operator cannot occur there in any case.
>
> Well :)
>
> >>> foo=1
> >>> bar=2
> >>> foo\
> ... %bar
> 1
>
> Though I don't think it's the common use case.
It does sounds very unlikely, so should JD's suggestion be implemented?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#47575: python-shell-completion-at-point omits %magic commands
2022-06-29 10:46 ` Lars Ingebrigtsen
@ 2022-06-29 20:31 ` Andrii Kolomoiets
2022-06-30 10:06 ` Lars Ingebrigtsen
0 siblings, 1 reply; 6+ messages in thread
From: Andrii Kolomoiets @ 2022-06-29 20:31 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 47575, JD Smith
Lars Ingebrigtsen <larsi@gnus.org> writes:
>>>> modulo operator cannot occur there in any case.
>> ... %bar
>> 1
>>
>> Though I don't think it's the common use case.
>
> It does sounds very unlikely, so should JD's suggestion be implemented?
Agree, sounds good.
--
Andrii
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#47575: python-shell-completion-at-point omits %magic commands
2022-06-29 20:31 ` Andrii Kolomoiets
@ 2022-06-30 10:06 ` Lars Ingebrigtsen
0 siblings, 0 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-30 10:06 UTC (permalink / raw)
To: Andrii Kolomoiets; +Cc: 47575, JD Smith
Andrii Kolomoiets <andreyk.mad@gmail.com> writes:
>>>>> modulo operator cannot occur there in any case.
>>> ... %bar
>>> 1
>>>
>>> Though I don't think it's the common use case.
>>
>> It does sounds very unlikely, so should JD's suggestion be implemented?
>
> Agree, sounds good.
I'm really not that familiar with python-mode -- can anybody suggest a
patch here? (The code is question is in
python-shell-completion-at-point.)
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-06-30 10:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-03 4:21 bug#47575: python-shell-completion-at-point omits %magic commands JD Smith
2021-05-06 11:05 ` Lars Ingebrigtsen
2021-05-06 13:38 ` Andrii Kolomoiets
2022-06-29 10:46 ` Lars Ingebrigtsen
2022-06-29 20:31 ` Andrii Kolomoiets
2022-06-30 10:06 ` Lars Ingebrigtsen
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).