Skip to content

Commit

Permalink
Merge from 3.x: PR #6832
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed Mar 27, 2018
2 parents 6b80e36 + 66c094e commit ccdac16
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
1 change: 1 addition & 0 deletions spyder/config/main.py
Expand Up @@ -159,6 +159,7 @@
'startup/use_run_file': False,
'startup/run_file': '',
'greedy_completer': False,
'jedi_completer': False,
'autocall': 0,
'symbolic_math': False,
'in_prompt': '',
Expand Down
52 changes: 39 additions & 13 deletions spyder/plugins/ipythonconsole.py
Expand Up @@ -487,20 +487,46 @@ def setup_page(self):
run_file_group.setLayout(run_file_layout)

# ---- Advanced settings ----
# Enable Jedi completion
jedi_group = QGroupBox(_("Jedi completion"))
jedi_label = QLabel(_("Enable Jedi-based <tt>Tab</tt> completion "
"in the IPython console; similar to the "
"greedy completer, but without evaluating "
"the code.<br>"
"<b>Warning:</b> Slows down your console "
"when working with large dataframes!"))
jedi_label.setWordWrap(True)
jedi_box = newcb(_("Use Jedi completion in the IPython console"),
"jedi_completer",
tip="<b>Warning</b>: "
"Slows down your console when working with "
"large dataframes!<br>"
"Allows completion of nested lists etc.")

jedi_layout = QVBoxLayout()
jedi_layout.addWidget(jedi_label)
jedi_layout.addWidget(jedi_box)
jedi_group.setLayout(jedi_layout)

# Greedy completer group
greedy_group = QGroupBox(_("Greedy completion"))
greedy_label = QLabel(_("Enable <tt>Tab</tt> completion on elements "
"of lists, results of function calls, etc, "
"<i>without</i> assigning them to a "
"variable.<br>"
"For example, you can get completions on "
"things like <tt>li[0].&lt;Tab&gt;</tt> or "
"<tt>ins.meth().&lt;Tab&gt;</tt>"))
"<i>without</i> assigning them to a variable, "
"like <tt>li[0].&lt;Tab&gt;</tt> or "
"<tt>ins.meth().&lt;Tab&gt;</tt> <br>"
"<b>Warning:</b> Due to a bug, IPython's "
"greedy completer requires a leading "
"<tt>&lt;Space&gt;</tt> for some completions; "
"e.g. <tt>np.sin(&lt;Space&gt;np.&lt;Tab&gt;"
"</tt> works while <tt>np.sin(np.&lt;Tab&gt; "
"</tt> doesn't."))
greedy_label.setWordWrap(True)
greedy_box = newcb(_("Use the greedy completer"), "greedy_completer",
greedy_box = newcb(_("Use greedy completion in the IPython console"),
"greedy_completer",
tip="<b>Warning</b>: It can be unsafe because the "
"code is actually evaluated when you press "
"<tt>Tab</tt>.")
"code is actually evaluated when you press "
"<tt>Tab</tt>.")

greedy_layout = QVBoxLayout()
greedy_layout.addWidget(greedy_label)
Expand All @@ -510,10 +536,10 @@ def setup_page(self):
# Autocall group
autocall_group = QGroupBox(_("Autocall"))
autocall_label = QLabel(_("Autocall makes IPython automatically call "
"any callable object even if you didn't type "
"explicit parentheses.<br>"
"For example, if you type <i>str 43</i> it "
"becomes <i>str(43)</i> automatically."))
"any callable object even if you didn't "
"type explicit parentheses.<br>"
"For example, if you type <i>str 43</i> it "
"becomes <i>str(43)</i> automatically."))
autocall_label.setWordWrap(True)

smart = _('Smart')
Expand Down Expand Up @@ -585,7 +611,7 @@ def setup_page(self):
_("Graphics"))
tabs.addTab(self.create_tab(run_lines_group, run_file_group),
_("Startup"))
tabs.addTab(self.create_tab(greedy_group, autocall_group, sympy_group,
tabs.addTab(self.create_tab(jedi_group, greedy_group, autocall_group, sympy_group,
prompts_group), _("Advanced Settings"))

vlayout = QVBoxLayout()
Expand Down
1 change: 1 addition & 0 deletions spyder/utils/ipython/kernelspec.py
Expand Up @@ -126,6 +126,7 @@ def env(self):
'SPY_RUN_FILE_O': CONF.get('ipython_console', 'startup/run_file'),
'SPY_AUTOCALL_O': CONF.get('ipython_console', 'autocall'),
'SPY_GREEDY_O': CONF.get('ipython_console', 'greedy_completer'),
'SPY_JEDI_O': CONF.get('ipython_console', 'jedi_completer'),
'SPY_SYMPY_O': CONF.get('ipython_console', 'symbolic_math'),
'SPY_RUN_CYTHON': self.is_cython
}
Expand Down
4 changes: 3 additions & 1 deletion spyder/utils/ipython/start_kernel.py
Expand Up @@ -69,10 +69,12 @@ def kernel_config():
# Until we implement Issue 1052
spy_cfg.InteractiveShell.xmode = 'Plain'

# Jedi completer
jedi_o = os.environ.get('SPY_JEDI_O') == 'True'
# - Using Jedi slow completions a lot for objects with big repr's.
# - Jedi completions are not available in Python 2.
if not PY2:
spy_cfg.IPCompleter.use_jedi = False
spy_cfg.IPCompleter.use_jedi = jedi_o

# Run lines of code at startup
run_lines_o = os.environ.get('SPY_RUN_LINES_O')
Expand Down

0 comments on commit ccdac16

Please sign in to comment.