Skip to content
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 a tab completion for Libedit in cmd, site, and pdb. #107738

Closed
wants to merge 3 commits into from

Conversation

Constantin1489
Copy link
Contributor

@Constantin1489 Constantin1489 commented Aug 7, 2023

After I dug the rabbit hole, I wanted to share something and commit it to cpython. I have my research for the .python_history compatibility problem. I will write comments within days.

My commit allows a tab complete in pdb and cmd for Libedit readline and improves compatibility between GNU readline and Libedit.

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.

tab of readline.parse_and_bind("tab: complete") is a symbolic character name. Libedit doesn't support a number of symbolic character names(like TAB, ESC, DEL).

Also, unlike emacs keybinding, GNU readline doesn't support control characters of the form '^character' (e.g. '^I' it's a tab).
Both GNU readline and Libedit support the following backslashed escape sequences.

\a     bell
\b     backspace
\f     form feed
\n     newline
\r     carriage return
\t     horizontal tab
\v     vertical tab
\nnn   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).


📚 Documentation preview 📚: https://cpython-previews--107738.org.readthedocs.build/

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Aug 7, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@Constantin1489 Constantin1489 changed the title gh-102130: Support a tab completion for Libedit in cmd, site and pdb. gh-102130: Support a tab completion for Libedit in cmd, site, and pdb. Aug 7, 2023
@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants