prompt-toolkit / python-prompt-toolkit

Library for building powerful interactive command line applications in Python
https://python-prompt-toolkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
9.37k stars 716 forks source link

forward-word doesn't quite match emacs/readline, and isn't configurable #458

Open asmeurer opened 7 years ago

asmeurer commented 7 years ago

Consider a(123), with the cursor at a. In both emacs and readline, M-f moves forward one character, to the (. In prompt-toolkit, it moves to the 1.

It also would be nice to be able to configure word boundaries. In particular, I would like to be able to make it so that AbcDef and abc_def are both treated as two words for the purposes of word movement/deletion. The current approach does a regex search, but I believe you need to tokenize the input.

Also worth noting that the docs for forward-word state that words are composed of letters and numbers, but the implementation includes underscores as well (and that behavior in particular does not match readline and is quite annoying).

jonathanslenders commented 7 years ago

Thanks for reporting. If it's not entirely like readline, then we should consider it a bug (unless there is a good reason to do so.)