Open vfaronov opened 8 years ago
Hi @vfaronov,
Thanks a lot for pointing this out! This was indeed not yet implemented. It should be fixed in this commit: https://github.com/jonathanslenders/python-prompt-toolkit/commit/44e571b68e84d5007c6f5ab416771e7abbf25a64
Could you try with the latest "master" commit, and let me know whether it now works correctly? Whenever possible, we should follow GNU readline by default.
Thanks, Jonathan
This is great, thank you!
It’s still not quite the same as Readline, though. Readline’s backward-kill-word
deletes any non-word characters after a word, so if you’re at the end of /foo/bar/
and press Alt+Bksp, you get /foo/
. Whereas with your commit the result is /foo/bar
.
Also, as I mentioned earlier, Readline does not consider the underscore _
as part of a word.
But for me personally, this is not a big deal. What’s important is that now I can delete back to whitespace with a single keystroke.
GNU Readline has commands:
unix-word-rubout
(bound to C-w = Ctrl+W by default) kills the word before point, using white space as a word boundary;backward-kill-word
(bound to M-DEL = Alt+Bksp by default) kills the word before point, using “not a letter nor a digit” as a word boundary.The difference between these two commands is very useful. For example, suppose I have typed:
then realize that the path is wrong. I can then erase the entire path by pressing Ctrl+W, or erase it part-by-part by pressing Alt+Bksp.
However, prompt_toolkit binds both
unix-word-rubout
andbackward-kill-word
to the same action, which behaves more likebackward-kill-word
but not exactly (e.g. considers underscores as parts of words), and then binds both Ctrl+W and Alt+Bksp tounix-word-rubout
by default.Is there any specific reason for this divergence from Readline? Would you consider making prompt_toolkit behave the same as Readline here?