code input: don't eat "b" under GNU readline

GNU libreadline, and the libedit-based library shipped on stock OS-X
python, require different key-binding syntaxes to enable tab completion.
The previous commit to fix this (0977ef0) added both binding commands
Unfortunately when GNU libreadline is given the libedit-style
command (i.e. "bind ^I rl_complete"), it binds the letter "b" to a
non-existent command "ind", or something, and as a result the letter "b"
doesn't work anymore.

This patch uses the readline docstring to sense which flavor is
installed, and only runs the one binding command that's appropriate.

refs #37
This commit is contained in:
Brian Warner 2016-06-04 00:52:27 -07:00
parent 996c739b2a
commit 7c15cf7353

View File

@ -87,8 +87,10 @@ def input_code_with_completion(prompt, initial_channelids, get_channel_ids,
try:
import readline
c = CodeInputter(initial_channelids, get_channel_ids, code_length)
readline.parse_and_bind("tab: complete")
readline.parse_and_bind("bind ^I rl_complete")
if "libedit" in readline.__doc__:
readline.parse_and_bind("bind ^I rl_complete")
else:
readline.parse_and_bind("tab: complete")
readline.set_completer(c.wrap_completer)
readline.set_completer_delims("")
except ImportError: