Repository: ipython/ipython

Issue:
"return to editor to correct syntax error" is annoying
When I type a syntax error in the IPython console, like `def test()` without the colon, I get a prompt 

```
In [1]: def test
  File "<ipython-input-1-50eadd3e41eb>", line 1
    def test
            ^
SyntaxError: invalid syntax

Return to editor to correct syntax error? [Y/n]
```

This is annoying, and seems completely unnecessary, since with prompt_toolkit you now can reasonable edit the input in the console. 



Discussion:
Also consider that the average Joe who doesn't do any terminal configuration probably has `$EDITOR` set to the default `vi`, and dumping someone who doesn't know what they're doing into `vi` is about the worst user experience you can have. 

Hmm, seems this is because I enabled `autoedit_syntax` in my IPython config a long time ago, not knowing what it was. I guess this is the first version where the setting actually works. Anyway, it does seem that it is in fact disabled by default, so feel free to close. 

Let's turn that into "improving the text string of `autoedit_syntax` flag", and you are right, now that we have multiline, we might be able to get rid of this. 

I'm going to bump that to 6.0 and it will likely be "remove the feature". 

If we agree about removing the feature, we may as well do it for 5.0. It's currently broken if you enable it, so we need to do either remove it or fix it before releasing.


Resolving patch:
diff --git a/IPython/core/hooks.py b/IPython/core/hooks.py
--- a/IPython/core/hooks.py
+++ b/IPython/core/hooks.py
@@ -37,6 +37,7 @@ def load_ipython_extension(ip):
 
 import os
 import subprocess
+import warnings
 import sys
 
 from IPython.core.error import TryNext
@@ -83,13 +84,24 @@ def editor(self, filename, linenum=None, wait=True):
 
 import tempfile
 def fix_error_editor(self,filename,linenum,column,msg):
-    """Open the editor at the given filename, linenumber, column and
+    """DEPRECATED
+
+    Open the editor at the given filename, linenumber, column and
     show an error message. This is used for correcting syntax errors.
     The current implementation only has special support for the VIM editor,
     and falls back on the 'editor' hook if VIM is not used.
 
-    Call ip.set_hook('fix_error_editor',youfunc) to use your own function,
+    Call ip.set_hook('fix_error_editor',yourfunc) to use your own function,
     """
+
+    warnings.warn("""
+`fix_error_editor` is pending deprecation as of IPython 5.0 and will be removed
+in future versions. It appears to be used only for automatically fixing syntax
+error that has been broken for a few years and has thus been removed. If you
+happend to use this function and still need it please make your voice heard on
+the mailing list ipython-dev@scipy.org , or on the GitHub Issue tracker:
+https://github.com/ipython/ipython/issues/9649 """, UserWarning)
+
     def vim_quickfix_file():
         t = tempfile.NamedTemporaryFile()
         t.write('%s:%d:%d:%s\n' % (filename,linenum,column,msg))
diff --git a/IPython/terminal/interactiveshell.py b/IPython/terminal/interactiveshell.py
--- a/IPython/terminal/interactiveshell.py
+++ b/IPython/terminal/interactiveshell.py
@@ -93,11 +93,6 @@ def _space_for_menu_changed(self, old, new):
     def debugger_cls(self):
         return Pdb if self.simple_prompt else TerminalPdb
 
-    autoedit_syntax = Bool(False,
-        help="auto editing of files with syntax errors.",
-    ).tag(config=True)
-
-
     confirm_exit = Bool(True,
         help="""
         Set to confirm when you try to exit IPython with an EOF (Control-D
@@ -476,8 +471,6 @@ def interact(self, display_banner=DISPLAY_BANNER_DEPRECATED):
             else:
                 if code:
                     self.run_cell(code, store_history=True)
-                    if self.autoedit_syntax and self.SyntaxTB.last_syntax_error:
-                        self.edit_syntax_error()
 
     def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
         # An extra layer of protection in case someone mashing Ctrl-C breaks
@@ -505,65 +498,6 @@ def enable_gui(self, gui=None):
         else:
             self._inputhook = None
 
-    # Methods to support auto-editing of SyntaxErrors:
-
-    def edit_syntax_error(self):
-        """The bottom half of the syntax error handler called in the main loop.
-
-        Loop until syntax error is fixed or user cancels.
-        """
-
-        while self.SyntaxTB.last_syntax_error:
-            # copy and clear last_syntax_error
-            err = self.SyntaxTB.clear_err_state()
-            if not self._should_recompile(err):
-                return
-            try:
-                # may set last_syntax_error again if a SyntaxError is raised
-                self.safe_execfile(err.filename, self.user_ns)
-            except:
-                self.showtraceback()
-            else:
-                try:
-                    with open(err.filename) as f:
-                        # This should be inside a display_trap block and I
-                        # think it is.
-                        sys.displayhook(f.read())
-                except:
-                    self.showtraceback()
-
-    def _should_recompile(self, e):
-        """Utility routine for edit_syntax_error"""
-
-        if e.filename in ('<ipython console>', '<input>', '<string>',
-                          '<console>', '<BackgroundJob compilation>',
-                          None):
-            return False
-        try:
-            if (self.autoedit_syntax and
-                    not self.ask_yes_no(
-                        'Return to editor to correct syntax error? '
-                        '[Y/n] ', 'y')):
-                return False
-        except EOFError:
-            return False
-
-        def int0(x):
-            try:
-                return int(x)
-            except TypeError:
-                return 0
-
-        # always pass integer line and offset values to editor hook
-        try:
-            self.hooks.fix_error_editor(e.filename,
-                                        int0(e.lineno), int0(e.offset),
-                                        e.msg)
-        except TryNext:
-            warn('Could not open editor')
-            return False
-        return True
-
     # Run !system commands directly, not through pipes, so terminal programs
     # work correctly.
     system = InteractiveShell.system_raw


Test patch: