[IPython-dev] Code Indentation and Tab Completion

Fernando Perez Fernando.Perez at colorado.edu
Wed Nov 10 03:02:23 CST 2004


Donny Viszneki wrote:
> Here's a theory:
> 
> What if to the tab-completion list we were to add a one character 
> string that just consisted of Tab? Would this hack be sufficient to 
> allow me to press tab on a blank line for the proper indentation?

You'd still have the problem of having readline asking you about 634 possible 
completions on any blank line (which would include your hypothetical tab 
entry).  So I don't see how this would solve anything: if you have to hit tab, 
then 'yes', then tab again, might as well just type one or two spaces (or use 
Ctrl-O, or whatever you want to rebind in readline as I indicated).

Note that hitting tab to indent an existing line where you've already started 
typing, like for example Xemacs can do, is simply beyond the capabilities of 
readline.  So the only place for tab to work as you'd want is at the very 
beginning, while the line is still blank (and hence open to the problem of a 
zillion alternate completions).

And even if you wanted to do this, I doubt it could work at all, as I think 
that readline simply traps the tab key event immediately, and you could never 
'complete' the fake <tab> entry you suggest.  But I don't have the time to 
test this hack (which I dislike on technical grounds, and suspect will fail). 
  If you find that it works, post a patch on the list and I'll gladly have a 
look at it.

Best,

f




More information about the IPython-dev mailing list