From 0f127776bf967fdf5d80015778837b11efa02556 2018-09-01 16:08:42 From: Matthias Bussonnier Date: 2018-09-01 16:08:42 Subject: [PATCH] Merge remote-tracking branch 'origin/master' into inputtransformer2 --- diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 13b7b0c..e9bb2f8 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 46b17b5..3c7e82b 100644 --- a/IPython/terminal/magics.py +++ b/IPython/terminal/magics.py @@ -80,8 +80,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 0d113bb..28aa5b4 100644 --- a/IPython/terminal/shortcuts.py +++ b/IPython/terminal/shortcuts.py @@ -111,13 +111,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) + if shell.autoindent: + b.insert_text('\n' + indent) + else: + b.insert_text('\n') return if (status != 'incomplete') and b.accept_handler: b.validate_and_handle() else: - b.insert_text('\n' + indent) + if shell.autoindent: + b.insert_text('\n' + indent) + 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`