gh-102130: Support a tab completion for Libedit in cmd, site, and pdb. #107738
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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).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.
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/