Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

tab auto-completion fails if there is no space #2657

Open
klonuo opened this Issue · 17 comments

7 participants

@klonuo
In [1]: import numpy as np

In [2]: x=np.[tab]
--> no auto-completion

In [2]: x= np.[tab]
--> ok
@Carreau
Owner

This is because you've set the --enforce-pep8 flag.

Without kidding, which frontend ? Both works for me in terminal and qtconsole.
Which IPython version ?

@klonuo

:) yeah, I always try to follow PEP8, but was in a hurry and then I noticed this (although working example also violates PEP8 ;)

Noticed in latest stable (0.13.1), in both qtconsole and terminal console, on Windows XP with Python27

ipython_config.py in my profile folder is all commented except: c.IPCompleter.greedy = True

@jenshnielsen

I think greedy is the issue. Without the greedy completer it works fine but for me but with it I can confirm this behaviour
i.e. no tab completion after a =np.a @klonuo does it work for you if you change greedy to false?

@klonuo

yep, that's the offender

@klonuo

This is quick fix:

index 83f9f5b..45c8413 100644
--- "a/IPython\\core\\completer.py"
+++ "b/IPython\\core\\completer.py"
@@ -182,7 +182,7 @@ class Bunch(object): pass


 DELIMS = ' \t\n`!@#$^&*()=+[{]}\\|;:\'",<>?'
-GREEDY_DELIMS = ' \r\n'
+GREEDY_DELIMS = ' =\r\n'


 class CompletionSplitter(object):

But I think some more experienced should look at it.

@takluyver
Owner
@minrk
Owner

I added @konuo's patch as PR #2820

@klonuo

Thanks @minrk
It looks to me like more delimiters should be added, but I don't have whole set.
For example: x = y * (np.<tab> won't auto-complete also, and perhaps in other scenarios

@minrk
Owner

I thought about other binary operators as well, but there are two cases:

x = y * np.<tab>

and

(x*y).<tab>

If you add *, you will get the first one but lose the second. The greedy completer is tricky, because its point is evaluating results and completing on those results.

@klonuo

I see your point.
So user should have in mind that greedy completer is active anyway, and just pad variable/function with space if single variable completer is desired. It makes sense, although maybe not obvious on first thought.

@minrk
Owner

Right - and nobody will have the greedy completer on by accident (though some may have forgotten).
It should probably be better documented how it behaves (for instance (x*y).<TAB> works, but (x * y).<TAB> doesn't.

@ellisonbg
Owner

Seems like the is a bigger issue with the greedy completer and that this PR will not fix that bigger issue. Do we want to close this and open an issue for the larger issue? Or will we try to use this PR to address the bigger issue?

@minrk
Owner

This is not a PR, no reason to close and reopen.

@ellisonbg
Owner

Sorry meant that to go on PR #2820

@minrk
Owner

Ah, gotcha. Under no circumstances is PR #2820 not an improvement over the current situation, so it would be silly to discard it.

@minrk minrk closed this issue from a commit
@klonuo klonuo add '=' to greedy completer delims
closes #2657

Signed-off-by: MinRK <benjaminrk@gmail.com>
c924f19
@minrk minrk closed this in c924f19
@minrk
Owner

autoclosed by #2820, but keeping open to track greedy completer parsing deficiency.

@minrk minrk reopened this
@minrk minrk referenced this issue from a commit in minrk/ipython
@klonuo klonuo add '=' to greedy completer delims
closes #2657

Signed-off-by: MinRK <benjaminrk@gmail.com>
bdd80b5
@jfmoulin

I have a similar problem related to completions in quoted strings, e.g
I like to autocomplete paths: '~/[TAB] expands correctly if greedy is False but fails when active.
This is true for other strings like 'foo/[TAB] which works without greedy while I need ' foo/[TAB] with greedy on.

@mattvonrocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
@klonuo klonuo add '=' to greedy completer delims
closes #2657

Signed-off-by: MinRK <benjaminrk@gmail.com>
3f77c10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.