@@ -35,7 +35,7 @@ def loadini(struct, configfile):
3535config_path = os .path .expanduser (configfile )
3636
3737config = ConfigParser ()
38- fill_config_with_default_values ( config , {
38+ defaults = {
3939'general' : {
4040'arg_spec' :True ,
4141'auto_display_list' :True ,
@@ -61,8 +61,15 @@ def loadini(struct, configfile):
6161'editor' :os .environ .get ('VISUAL' ,os .environ .get ('EDITOR' ,'vi' ))
6262 },
6363'keyboard' : {
64+ 'backspace' :'C-h' ,
65+ 'left' :'C-b' ,
66+ 'right' :'C-f' ,
67+ 'beginning_of_line' :'C-a' ,
68+ 'end_of_line' :'C-e' ,
69+ 'transpose_chars' :'C-t' ,
6470'clear_line' :'C-u' ,
6571'clear_screen' :'C-l' ,
72+ 'kill_line' :'C-k' ,
6673'clear_word' :'C-w' ,
6774'cut_to_buffer' :'C-k' ,
6875'delete' :'C-d' ,
@@ -90,7 +97,8 @@ def loadini(struct, configfile):
9097'curtsies' : {
9198'list_above' :False ,
9299'right_arrow_completion' :True ,
93- }})
100+ }}
101+ fill_config_with_default_values (config ,defaults )
94102if not config .read (config_path ):
95103# No config file. If the user has it in the old place then complain
96104if os .path .isfile (os .path .expanduser ('~/.bpython.ini' )):
@@ -99,6 +107,18 @@ def loadini(struct, configfile):
99107"%s\n " % default_config_path ())
100108sys .exit (1 )
101109
110+ def get_key_no_doublebind (attr ,already_used = {}):
111+ """Clears any other configured keybindings using this key"""
112+ key = config .get ('keyboard' ,attr )
113+ if key in already_used :
114+ default = defaults ['keyboard' ][already_used [key ]]
115+ if default in already_used :
116+ setattr (struct ,'%s_key' % already_used [key ],'' )
117+ else :
118+ setattr (struct ,'%s_key' % already_used [key ],default )
119+ already_used [key ]= attr
120+ return key
121+
102122struct .config_path = config_path
103123
104124struct .dedent_after = config .getint ('general' ,'dedent_after' )
@@ -115,28 +135,39 @@ def loadini(struct, configfile):
115135struct .hist_length = config .getint ('general' ,'hist_length' )
116136struct .hist_duplicates = config .getboolean ('general' ,'hist_duplicates' )
117137struct .flush_output = config .getboolean ('general' ,'flush_output' )
118- struct .pastebin_key = config .get ('keyboard' ,'pastebin' )
119- struct .save_key = config .get ('keyboard' ,'save' )
120- struct .search_key = config .get ('keyboard' ,'search' )
121- struct .show_source_key = config .get ('keyboard' ,'show_source' )
122- struct .suspend_key = config .get ('keyboard' ,'suspend' )
123- struct .toggle_file_watch_key = config .get ('keyboard' ,'toggle_file_watch' )
124- struct .undo_key = config .get ('keyboard' ,'undo' )
125- struct .reimport_key = config .get ('keyboard' ,'reimport' )
126- struct .up_one_line_key = config .get ('keyboard' ,'up_one_line' )
127- struct .down_one_line_key = config .get ('keyboard' ,'down_one_line' )
128- struct .cut_to_buffer_key = config .get ('keyboard' ,'cut_to_buffer' )
129- struct .yank_from_buffer_key = config .get ('keyboard' ,'yank_from_buffer' )
130- struct .clear_word_key = config .get ('keyboard' ,'clear_word' )
131- struct .clear_line_key = config .get ('keyboard' ,'clear_line' )
132- struct .clear_screen_key = config .get ('keyboard' ,'clear_screen' )
133- struct .delete_key = config .get ('keyboard' ,'delete' )
134- struct .exit_key = config .get ('keyboard' ,'exit' )
135- struct .last_output_key = config .get ('keyboard' ,'last_output' )
136- struct .edit_config_key = config .get ('keyboard' ,'edit_config' )
137- struct .edit_current_block_key = config .get ('keyboard' ,'edit_current_block' )
138- struct .external_editor_key = config .get ('keyboard' ,'external_editor' )
139- struct .help_key = config .get ('keyboard' ,'help' )
138+
139+ struct .pastebin_key = get_key_no_doublebind ('pastebin' )
140+ struct .save_key = get_key_no_doublebind ('save' )
141+ struct .search_key = get_key_no_doublebind ('search' )
142+ struct .show_source_key = get_key_no_doublebind ('show_source' )
143+ struct .suspend_key = get_key_no_doublebind ('suspend' )
144+ struct .toggle_file_watch_key = get_key_no_doublebind ('toggle_file_watch' )
145+ struct .undo_key = get_key_no_doublebind ('undo' )
146+ struct .reimport_key = get_key_no_doublebind ('reimport' )
147+ struct .up_one_line_key = get_key_no_doublebind ('up_one_line' )
148+ struct .down_one_line_key = get_key_no_doublebind ('down_one_line' )
149+ struct .cut_to_buffer_key = get_key_no_doublebind ('cut_to_buffer' )
150+ struct .yank_from_buffer_key = get_key_no_doublebind ('yank_from_buffer' )
151+ struct .clear_word_key = get_key_no_doublebind ('clear_word' )
152+ struct .backspace_key = get_key_no_doublebind ('backspace' )
153+ struct .clear_line_key = get_key_no_doublebind ('clear_line' )
154+ struct .clear_screen_key = get_key_no_doublebind ('clear_screen' )
155+ struct .delete_key = get_key_no_doublebind ('delete' )
156+
157+ struct .left_key = get_key_no_doublebind ('left' )
158+ struct .right_key = get_key_no_doublebind ('right' )
159+ struct .end_of_line_key = get_key_no_doublebind ('end_of_line' )
160+ struct .beginning_of_line_key = get_key_no_doublebind ('beginning_of_line' )
161+ struct .transpose_chars_key = get_key_no_doublebind ('transpose_chars' )
162+ struct .clear_line_key = get_key_no_doublebind ('clear_line' )
163+ struct .clear_screen_key = get_key_no_doublebind ('clear_screen' )
164+ struct .kill_line_key = get_key_no_doublebind ('kill_line' )
165+ struct .exit_key = get_key_no_doublebind ('exit' )
166+ struct .last_output_key = get_key_no_doublebind ('last_output' )
167+ struct .edit_config_key = get_key_no_doublebind ('edit_config' )
168+ struct .edit_current_block_key = get_key_no_doublebind ('edit_current_block' )
169+ struct .external_editor_key = get_key_no_doublebind ('external_editor' )
170+ struct .help_key = get_key_no_doublebind ('help' )
140171
141172struct .pastebin_confirm = config .getboolean ('general' ,'pastebin_confirm' )
142173struct .pastebin_url = config .get ('general' ,'pastebin_url' )