-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-102130: Support tab completion in cmd for Libedit. #107748
Conversation
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
There is something that Python core developers decide.
OR just
If this is supported, then other third-party libraries can support Libedit tab completion without changing their code.
Because of the absence of the GNU inputrc example in For Vim keybinding in the editrc example(
Just so you know, if you want to debug this problem, please check what I found below. Use one of these lines to enable tab completion in Python using
To use them with The key sequences( But the last two lines are not. I stumble across them. To do another complete command in Libedit, this is possible. I found several ways to debug it. (these are examples.)
How to check the keybinding setting applied with Libedit.
This shows the user's current applied libedit readline setting. |
I don't think we should change the default and hope the completekey passed in is correct. It could break users code, for example, if they compare class MyCmd(cmd.Cmd):
def __init__(self, completekey='tab'):
cmd.Cmd.__init__(self, completekey) They will still have the issue. We should convert the completekey internally and just do a different binding command with Also, why do you want to change the I believe the right way to do this is just add an extra check in Also, if you want to finish this, you'd need a regression test on at least I can help you with the review and find the core-dev for approval if you want to work on this. |
Yes, what you pointed is valid.
Because I was unsure about the decision I made. This is what I asked in number 1 #107748 (comment). At the time I wrote this PR, I thought, that if a user did something wrong, the wrong result must be thrown. And the docs must give a pledge. (You know when learning the linux thing there must be some reason I don't know and some result is unintuitive or counterintuitive for newcomer.). Thank you for giving me direction for what I consider. I will do that within a week as soon as possible. The second thing you mention(site.py) is just for a tone and manner thing(second and third thing that I asked in #107748 (comment)). I will revert it. Thank you for helping me. |
I believe you only need to change BTW, you should not use |
… site, and pdb." This reverts commit 1374212.
Co-authored-by: Tian Gao <[email protected]>
This comment was marked as resolved.
This comment was marked as resolved.
I have the hardest time believing that commit can cause the completion issue. The code should not be executed at all for completion. Are you sure you did the test correctly? |
I'm sorry. You are right. Maybe my environment goes something wrong. |
Hi @Constantin1489 , now that #111826 is merged, you have the utility to write tests for the feature. Could you:
|
Co-authored-by: Petr Viktorin <[email protected]>
Co-authored-by: Petr Viktorin <[email protected]>
Alright!
|
And one more thing I always forget to point out (sorry for that)! At the end of the
Also, please ignore the free-threaded CI failures; they're not your fault and they're allowed to fail for now. |
Misc/NEWS.d/next/Library/2023-08-07-21-11-24.gh-issue-102130._UyI5i.rst
Outdated
Show resolved
Hide resolved
change the NEWS text, the commit names don't matter
On December 1, 2023 5:02:04 PM GMT+01:00, Constantin Hong ***@***.***> wrote:
@Constantin1489 commented on this pull request.
> @@ -0,0 +1 @@
+Support tab completion in :mod:`cmd` for Libedit.
Should I change Libedit to editline of this and this commit post's name?
```
gh-102130: Support tab completion in cmd for Libedit.
->
gh-102130: Support tab completion in cmd for editline.
```
--
Reply to this email directly or view it on GitHub:
#107748 (review)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
Co-authored-by: Petr Viktorin <[email protected]>
Co-authored-by: Petr Viktorin <[email protected]>
Thank you for your contribution! |
…-107748) --- Co-authored-by: Tian Gao <[email protected]>
…-107748) --- Co-authored-by: Tian Gao <[email protected]>
After I dug the rabbit hole, I wanted to share something and commit it to CPython.
My commit allows tab completion in cmd for Libedit. (EDIT AFTER MERGE: this allows tab completion for pdb with libedit)
tab
ofreadline.parse_and_bind("tab: complete")
is a symbolic character name. Libedit doesn't support a number of symbolic character names(like TAB, ESC, DEL).FYI, for better compatibility, Python Documents should suggest using backslashed escape sequences(e.g.
\t
,\a
) or the ASCII character corresponding to the octal number(or octal excape sequences).(e.g.\011
), It's because the only thing GNU readline(man bash
and/Readline Key Bindings
to search the part.) and Libedit(man editrc
) have in common.Also, unlike GNU emacs software, GNU readline doesn't support control characters of the form '^character' (e.g. '^I' it's a tab).
Both GNU readline(
man bash
and/Readline Key Bindings
to search the part.) and Libedit(man editrc
) support the following backslashed escape sequences and octal escape sequences.GNU readline's predefined commands are in the '/Readline Command Names' of
man bash
.Libedit's predefined commands are in the section "EDITOR COMMANDS" of
man editrc
. But there are other undocumented commands in its source code.Or you can get a list by
import readline; readline.parse_and_bind('bind -l')
(Libedit only. This shows undocumented commands too).📚 Documentation preview 📚: https://cpython-previews--107748.org.readthedocs.build/