From 7c15cf73535e7057931214efac0d29ebb2b57598 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sat, 4 Jun 2016 00:52:27 -0700 Subject: [PATCH] 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 --- src/wormhole/codes.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wormhole/codes.py b/src/wormhole/codes.py index a439613..b68eaf4 100644 --- a/src/wormhole/codes.py +++ b/src/wormhole/codes.py @@ -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: