diff --git a/IPython/core/history.py b/IPython/core/history.py index 6c51f73..5a9078e 100644 --- a/IPython/core/history.py +++ b/IPython/core/history.py @@ -924,6 +924,7 @@ def magic_rep(self, arg): self.set_next_input(cmd.rstrip()) print("Couldn't evaluate or find in history:", arg) + def magic_rerun(self, parameter_s=''): """Re-run previous input @@ -969,8 +970,8 @@ def init_ipython(ip): ip.define_magic("rep", magic_rep) ip.define_magic("recall", magic_rep) ip.define_magic("rerun", magic_rerun) - ip.define_magic("hist",magic_history) # Alternative name - ip.define_magic("history",magic_history) + ip.define_magic("hist", magic_history) # Alternative name + ip.define_magic("history", magic_history) # XXX - ipy_completers are in quarantine, need to be updated to new apis #import ipy_completers diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index de4c994..8c249d5 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -2674,7 +2674,7 @@ class InteractiveShell(SingletonConfigurable): make sense in all contexts, for example a terminal ipython can't display figures inline. """ - + from IPython.core.pylabtools import mpl_runner # We want to prevent the loading of pylab to pollute the user's # namespace as shown by the %who* magics, so we execute the activation # code in an empty namespace, and we update *both* user_ns and @@ -2690,7 +2690,7 @@ class InteractiveShell(SingletonConfigurable): # Now we must activate the gui pylab wants to use, and fix %run to take # plot updates into account self.enable_gui(gui) - self._magic.magic_run = self._pylab_magic_run + self._magic.default_runner = mpl_runner(self.safe_execfile) #------------------------------------------------------------------------- # Utilities diff --git a/IPython/core/magic.py b/IPython/core/magic.py index 15ed921..b9b658e 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -49,7 +49,6 @@ from IPython.core.error import StdinNotImplementedError from IPython.core.macro import Macro from IPython.core import magic_arguments, page from IPython.core.prefilter import ESC_MAGIC -from IPython.core.pylabtools import mpl_runner from IPython.testing.skipdoctest import skip_doctest from IPython.utils import py3compat from IPython.utils.encoding import DEFAULT_ENCODING @@ -124,6 +123,8 @@ class Magic(object): configurables = None + + default_runner = None #...................................................................... # some utility functions @@ -1796,6 +1797,8 @@ Currently the magic system has the following functions:\n""" self.shell.InteractiveTB(etype, value, tb, tb_offset=3) else: if runner is None: + runner = self.default_runner + if runner is None: runner = self.shell.safe_execfile if 't' in opts: # timed execution @@ -3549,16 +3552,6 @@ Defaulting color scheme to 'NoColor'""" "Add `--reset` to overwrite already existing config files with defaults." ]) - # Pylab support: simple wrappers that activate pylab, load gui input - # handling and modify slightly %run - - @skip_doctest - def _pylab_magic_run(self, parameter_s=''): - Magic.magic_run(self, parameter_s, - runner=mpl_runner(self.shell.safe_execfile)) - - _pylab_magic_run.__doc__ = magic_run.__doc__ - @skip_doctest def magic_pylab(self, s): """Load numpy and matplotlib to work interactively.