Merge IDLE-syntax-branch r39668:41449 into trunk

A    idlelib/AutoCompleteWindow.py
A    idlelib/AutoComplete.py
A    idlelib/HyperParser.py
M    idlelib/PyShell.py
M    idlelib/ParenMatch.py
M    idlelib/configDialog.py
M    idlelib/EditorWindow.py
M    idlelib/PyParse.py
M    idlelib/CallTips.py
M    idlelib/CallTipWindow.py
M    idlelib/run.py
M    idlelib/config-extensions.def
A    idlelib/MultiCall.py
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py
index 63bcae2..2d8835c 100644
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configDialog.py
@@ -1106,6 +1106,13 @@
             idleConf.userCfg[configType].Save()
         self.ResetChangedItems() #clear the changed items dict
 
+    def DeactivateCurrentConfig(self):
+        #Before a config is saved, some cleanup of current
+        #config must be done - remove the previous keybindings
+        winInstances=self.parent.instance_dict.keys()
+        for instance in winInstances:
+            instance.RemoveKeybindings()
+
     def ActivateConfigChanges(self):
         "Dynamically apply configuration changes"
         winInstances=self.parent.instance_dict.keys()
@@ -1113,7 +1120,7 @@
             instance.ResetColorizer()
             instance.ResetFont()
             instance.set_notabs_indentwidth()
-            instance.ResetKeybindings()
+            instance.ApplyKeybindings()
             instance.reset_help_menu_entries()
 
     def Cancel(self):
@@ -1124,6 +1131,7 @@
         self.destroy()
 
     def Apply(self):
+        self.DeactivateCurrentConfig()
         self.SaveAllChangedConfigs()
         self.ActivateConfigChanges()