diff --git a/IPython/core/magics/code.py b/IPython/core/magics/code.py index 27d622c..66a2bc6 100644 --- a/IPython/core/magics/code.py +++ b/IPython/core/magics/code.py @@ -221,15 +221,6 @@ class CodeMagics(Magics): if not shell.user_ns.has_key(args): args = last_call[1] - # use last_call to remember the state of the previous call, but don't - # let it be clobbered by successive '-p' calls. - try: - last_call[0] = shell.displayhook.prompt_count - if not opts_prev: - last_call[1] = args - except: - pass - # by default this is done with temp files, except when the given # arg is a filename use_temp = True @@ -310,6 +301,16 @@ class CodeMagics(Magics): filename = shell.mktempfile(data) print 'IPython will make a temporary file named:',filename + # use last_call to remember the state of the previous call, but don't + # let it be clobbered by successive '-p' calls. + try: + last_call[0] = shell.displayhook.prompt_count + if not opts_prev: + last_call[1] = args + except: + pass + + return filename, lineno, use_temp def _edit_macro(self,mname,macro):