Magic to toggle tab completion #2837

Open
lebigot opened this Issue Jan 23, 2013 · 15 comments

Projects

None yet

5 participants

@lebigot
lebigot commented Jan 23, 2013

Was Allow string to contain tabulation characters?

When opening a string (with simple or double quotes), typing or pasting the tabulation character displays completion options.

I would prefer if it pasted the tabulation character directly: I would think that it is rare to need to have completion in this case (Python identifier or file name), and more common to want to, say, paste copied data that contains tabulations (like cells from Excel!).

Could tabulations be entered as raw tabulation characters in literal strings?

@minrk
Member
minrk commented Jan 23, 2013

I was going to say that we would need to add scope information to the completer, but I'm not sure it is even possible to do that with readline.

@takluyver
Member

Tab completion of filenames is a feature that I'd definitely like to keep. Maybe we could be smarter about where it completes (e.g. only if you're near the start of the string), but a) interfaces that try to be too smart are annoying, because you don't have a good mental model of what they'll do, and b) it's probably hard to do with readline, as Min says.

In the terminal, as far as I know, we can't distinguish between the user pressing the tab key and pasting text that contains tab characters. As a workaround, you can do %paste foo to dump the clipboard to a variable foo (note that that's designed for Python code, so it will strip things like >>> prompts). If you're working with data from a spreadsheet, pandas also has a read_clipboard function to load it straight into a DataFrame.

@takluyver
Member

P.S. I'm inclined to close this, because I don't think there's any improvement we can really make in the terminal. Thoughts?

@lebigot
lebigot commented Jan 25, 2013

Good points, about completion at the beginning of a string being useful for file names. And also about tools that are too smart to be less than annoying. :)

The "%paste variable" workaround can be quite handy, indeed, thanks!

Having a special "don't tab-autocomplete when pasting" mode would be great, if at all possible.

@takluyver
Member

In the terminal, pasting looks just like code being typed in. But it might be possible to have a magic command to toggle tab completion on and off.

@lebigot
lebigot commented Jan 25, 2013

Yeah, a magic command would be a clean solution to the problem of pasting tabs.

@takluyver
Member

Would you like to make a pull request? :)

@lebigot
lebigot commented Jan 25, 2013

I wish I could quickly write a patch. Since this is not the case, I will pass on this. :)

@rmcgibbo

Is this feature still desired? It actually would be possible to toggle whether the tab completion system is invoked or the literal tab key is entered based on whether you're inside of a string literal, but that doesn't necessarily make it a wise feature.

A magic that turns on or off the tab completion system would also be possible, and a little easier.

@lebigot
lebigot commented Mar 19, 2013

Yeah, being able to turn off tab completion would make pasting text with tabulations into strings easier. Such an option is easy to understand; I also guess that it is easier to remember than the existence of the %paste var_name feature (despite having gone through IPython's documentation quite a few times, I had missed it, and did not realize it could solve the problem of pasting text with tabulations).

It does not seem that detecting pasting inside a string in a terminal is doable (or easily done): an automatic solution to the "paste tabulations" problem does not seem simple.

So, a big +1 vote from me for a simple-to-remember "tab completion switch".

@rmcgibbo

Okay. I'm working on the reference implementation for IPEP11 now, and I will definitely keep this in mind.

I probably won't write the magic now, but I will make the sure that the CompletionManager has the ability to be "toggled off" so that implementing the magic will be trivial.

@lebigot
lebigot commented Mar 19, 2013

Great! Thank you. And good luck. :)

@rmcgibbo

p.s. If you have any other feature requests w.r.t the tab completion system, now is a really good time :).

@Carreau
Member
Carreau commented Mar 19, 2013

I'm not 100% sure magic is (always) the way to do it.
Part of the code that trigger completion are frontend specific when those are ZMQShell, and I think this would be better as a frontend option. Not sure about the classical IPython interpreter though, but I would probably not try to disable completion deep inside the core.

@takluyver
Member

The flipside is that we don't really have any good way to change frontend
config while it's running. And there's no really good way to configure the
notebook frontend at all.

On 19 March 2013 10:23, Matthias Bussonnier notifications@github.comwrote:

I'm not 100% sure magic is (always) the way to do it.
Part of the code that trigger completion are frontend specific when those
are ZMQShell, and I think this would be better as a frontend option. Not
sure about the classical IPython interpreter though, but I would probably
not try to disable completion deep inside the core.


Reply to this email directly or view it on GitHubhttps://github.com/ipython/ipython/issues/2837#issuecomment-15106778
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment