diff --git a/bpython/config.py b/bpython/config.py index e9bbe2d3e..0c96b25bd 100644 --- a/bpython/config.py +++ b/bpython/config.py @@ -74,7 +74,6 @@ def loadini(struct, configfile): 'transpose_chars': 'C-t', 'clear_line': 'C-u', 'clear_screen': 'C-l', - 'kill_line': 'C-k', 'clear_word': 'C-w', 'cut_to_buffer': 'C-k', 'delete': 'C-d', @@ -104,6 +103,10 @@ def loadini(struct, configfile): 'list_above' : False, 'right_arrow_completion' : True, }} + + default_keys_to_commands = dict((value, key) for (key, value) + in defaults['keyboard'].iteritems()) + fill_config_with_default_values(config, defaults) if not config.read(config_path): # No config file. If the user has it in the old place then complain @@ -113,17 +116,17 @@ def loadini(struct, configfile): "%s\n" % default_config_path()) sys.exit(1) - def get_key_no_doublebind(attr, already_used={}): - """Clears any other configured keybindings using this key""" - key = config.get('keyboard', attr) - if key in already_used: - default = defaults['keyboard'][already_used[key]] - if default in already_used: - setattr(struct, '%s_key' % already_used[key], '') - else: - setattr(struct, '%s_key' % already_used[key], default) - already_used[key] = attr - return key + + def get_key_no_doublebind(command): + default_commands_to_keys = defaults['keyboard'] + requested_key = config.get('keyboard', command) + default_command = default_keys_to_commands[requested_key] + + if default_commands_to_keys[default_command] == \ + config.get('keyboard', default_command): + setattr(struct, '%s_key' % default_command, '') + + return requested_key struct.config_path = config_path @@ -168,7 +171,6 @@ def get_key_no_doublebind(attr, already_used={}): struct.transpose_chars_key = get_key_no_doublebind('transpose_chars') struct.clear_line_key = get_key_no_doublebind('clear_line') struct.clear_screen_key = get_key_no_doublebind('clear_screen') - struct.kill_line_key = get_key_no_doublebind('kill_line') struct.exit_key = get_key_no_doublebind('exit') struct.last_output_key = get_key_no_doublebind('last_output') struct.edit_config_key = get_key_no_doublebind('edit_config') diff --git a/bpython/curtsiesfrontend/manual_readline.py b/bpython/curtsiesfrontend/manual_readline.py index 3c608b14d..d2e34126a 100644 --- a/bpython/curtsiesfrontend/manual_readline.py +++ b/bpython/curtsiesfrontend/manual_readline.py @@ -250,7 +250,7 @@ def delete_line(cursor_offset, line): def uppercase_next_word(cursor_offset, line): return cursor_offset, line #TODO Not implemented -@edit_keys.on(config='kill_line_key') +@edit_keys.on(config='cut_to_buffer_key') @kills_ahead def delete_from_cursor_forward(cursor_offset, line): return cursor_offset, line[:cursor_offset], line[cursor_offset:]