##// END OF EJS Templates
Fix handling of lines like '%%foo?' in cell magic logic.
Fernando Perez -
Show More
@@ -60,7 +60,6 b' Authors'
60 60 # Distributed under the terms of the BSD License. The full license is in
61 61 # the file COPYING, distributed as part of this software.
62 62 #-----------------------------------------------------------------------------
63 from __future__ import print_function
64 63
65 64 #-----------------------------------------------------------------------------
66 65 # Imports
@@ -598,7 +597,6 b' def _make_help_call(target, esc, lspace, next_input=None):'
598 597 else 'psearch' if '*' in target \
599 598 else 'pinfo'
600 599 arg = " ".join([method, target])
601
602 600 if next_input is None:
603 601 return '%sget_ipython().magic(%r)' % (lspace, arg)
604 602 else:
@@ -608,7 +606,7 b' def _make_help_call(target, esc, lspace, next_input=None):'
608 606
609 607 _initial_space_re = re.compile(r'\s*')
610 608
611 _help_end_re = re.compile(r"""(%?
609 _help_end_re = re.compile(r"""(%{0,2}
612 610 [a-zA-Z_*][\w*]* # Variable name
613 611 (\.[a-zA-Z_*][\w*]*)* # .etc.etc
614 612 )
@@ -841,7 +839,8 b' class IPythonInputSplitter(InputSplitter):'
841 839
842 840 # If the entire input block is a cell magic, return after handling it
843 841 # as the rest of the transformation logic should be skipped.
844 if lines.startswith('%%'):
842 if lines.startswith('%%') and not \
843 (len(lines.splitlines()) == 1 and lines.endswith('?')):
845 844 return self._handle_cell_magic(lines)
846 845
847 846 # In line mode, a cell magic can arrive in separate pieces
@@ -455,7 +455,8 b' syntax = \\'
455 455 (u'?x1', "get_ipython().magic({u}'pinfo x1')"),
456 456 (u'??x2', "get_ipython().magic({u}'pinfo2 x2')"),
457 457 (u'?a.*s', "get_ipython().magic({u}'psearch a.*s')"),
458 (u'?%hist', "get_ipython().magic({u}'pinfo %hist')"),
458 (u'?%hist1', "get_ipython().magic({u}'pinfo %hist1')"),
459 (u'?%%hist2', "get_ipython().magic({u}'pinfo %%hist2')"),
459 460 (u'?abc = qwe', "get_ipython().magic({u}'pinfo abc')"),
460 461 ]],
461 462
@@ -463,7 +464,10 b' syntax = \\'
463 464 [(i,py3compat.u_format(o)) for i,o in \
464 465 [ (u'x3?', "get_ipython().magic({u}'pinfo x3')"),
465 466 (u'x4??', "get_ipython().magic({u}'pinfo2 x4')"),
466 (u'%hist?', "get_ipython().magic({u}'pinfo %hist')"),
467 (u'%hist1?', "get_ipython().magic({u}'pinfo %hist1')"),
468 (u'%hist2??', "get_ipython().magic({u}'pinfo2 %hist2')"),
469 (u'%%hist3?', "get_ipython().magic({u}'pinfo %%hist3')"),
470 (u'%%hist4??', "get_ipython().magic({u}'pinfo2 %%hist4')"),
467 471 (u'f*?', "get_ipython().magic({u}'psearch f*')"),
468 472 (u'ax.*aspe*?', "get_ipython().magic({u}'psearch ax.*aspe*')"),
469 473 (u'a = abc?', "get_ipython().set_next_input({u}'a = abc');"
General Comments 0
You need to be logged in to leave comments. Login now