diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 9d17bdf..b8fdec2 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -250,8 +250,7 @@ class InteractiveShell(SingletonConfigurable): objects are automatically called (even if no arguments are present). """ ).tag(config=True) - # TODO: remove all autoindent logic and put into frontends. - # We can't do this yet because even runlines uses the autoindent. + autoindent = Bool(True, help= """ Autoindent IPython code entered interactively. diff --git a/IPython/terminal/magics.py b/IPython/terminal/magics.py index 837aaae..b9bcfe8 100644 --- a/IPython/terminal/magics.py +++ b/IPython/terminal/magics.py @@ -82,8 +82,6 @@ class TerminalMagics(Magics): @line_magic def autoindent(self, parameter_s = ''): """Toggle autoindent on/off (deprecated)""" - print("%autoindent is deprecated since IPython 5: you can now paste " - "multiple lines without turning autoindentation off.") self.shell.set_autoindent() print("Automatic indentation is:",['OFF','ON'][self.shell.autoindent]) diff --git a/IPython/terminal/shortcuts.py b/IPython/terminal/shortcuts.py index e3c4364..4b99f7e 100644 --- a/IPython/terminal/shortcuts.py +++ b/IPython/terminal/shortcuts.py @@ -112,13 +112,19 @@ def newline_or_execute_outer(shell): if not (d.on_last_line or d.cursor_position_row >= d.line_count - d.empty_line_count_at_the_end() ): - b.insert_text('\n' + (' ' * (indent or 0))) + if shell.autoindent: + b.insert_text('\n' + (' ' * (indent or 0))) + else: + b.insert_text('\n') return if (status != 'incomplete') and b.accept_handler: b.validate_and_handle() else: - b.insert_text('\n' + (' ' * (indent or 0))) + if shell.autoindent: + b.insert_text('\n' + (' ' * (indent or 0))) + else: + b.insert_text('\n') return newline_or_execute diff --git a/docs/source/config/intro.rst b/docs/source/config/intro.rst index af8bc79..115315c 100644 --- a/docs/source/config/intro.rst +++ b/docs/source/config/intro.rst @@ -67,7 +67,6 @@ Example config file 'mycode.py', 'fancy.ipy' ] - c.InteractiveShell.autoindent = True c.InteractiveShell.colors = 'LightBG' c.InteractiveShell.confirm_exit = False c.InteractiveShell.editor = 'nano' diff --git a/docs/source/interactive/tutorial.rst b/docs/source/interactive/tutorial.rst index f072110..5a70345 100644 --- a/docs/source/interactive/tutorial.rst +++ b/docs/source/interactive/tutorial.rst @@ -146,7 +146,7 @@ The built-in magics include: :magic:`macro`, :magic:`recall`, etc. - Functions which affect the shell: :magic:`colors`, :magic:`xmode`, - :magic:`autoindent`, :magic:`automagic`, etc. + :magic:`automagic`, etc. - Other functions such as :magic:`reset`, :magic:`timeit`, :cellmagic:`writefile`, :magic:`load`, or :magic:`paste`. diff --git a/docs/source/whatsnew/pr/re-autoindent.rst b/docs/source/whatsnew/pr/re-autoindent.rst new file mode 100644 index 0000000..a670d5f --- /dev/null +++ b/docs/source/whatsnew/pr/re-autoindent.rst @@ -0,0 +1,2 @@ +The autoindent feature that was deprecated in 5.x was re-enabled and +un-deprecated in :ghpull:`11257`