[IPython-dev] cd a little hyper

John Hunter jdh2358 at gmail.com
Fri Jun 6 01:05:05 EDT 2008


On Thu, Jun 5, 2008 at 11:41 PM, Ville M. Vainio <vivainio at gmail.com> wrote:
> On Fri, Jun 6, 2008 at 1:30 AM, John Hunter <jdh2358 at gmail.com> wrote:
>
>> To due a readline bug on solaris, cd ~/somedTAB used to insert extra
>> white space after completing directories, which was a major headache
>> when navigating deeply nested directories since I had to backspace
>> after every directory completion.   Using the latest ipython rom bzr,
>> this appears to be fixed.  I don't know how it was fixed, but it is
>> great.  (thanks).
>
> Yes, I fixed that by introducing the pseudo-annoying behaviour you
> mention (I noticed the same thing on linux + scratchbox). It's the
> single_dir_expand call in ipy_completers.py (cd completer)
>
> Perhaps we should "special case" the .svn / dot-something thing.

Oh, I see.  I initially thought I wasn't seeing it on bic (fernando's
linux machine on which I have an acct) because I wasn't using a recent
bzr ipython there.  After I did an update to::

    > bzr branch lp:ipython

I see the same behavior as I described on my work machine.

I don't think this is the behavior you want.  *Certainly* you do not
want to be completing on hidden dirs unless a user has explicitly
requested to do so in your rc file (regardless of whether it is a
".svn" hidden dir).  But I don't think you want to (by default)
complete on single dirs either, at least not if other nondir files are
around.

Eg, if as in the original post, I have something like::

    In [3]: !mkdir -p somedir/subdir1

    In [4]: !touch somedir/file1

    In [5]: !touch somedir/file2

    In [6]: cd somedi<TAB>

we do not want to go to somedir/subdir1 by default (unless it is an rc
choice) because somedir is a perfectly reasonable place to go.   On
the bzr HEAD (what do you call HEAD in bzr?) I am being taken to
subdir1.   Ie,

    In [6]: cd some<TAB>

takes me to::

    In [6]: cd somedir/subdir1
    /home/jdhunter/somedir/subdir1

Now in the case of somedir containing only a *single* non-hidden dir
and *no* plain files, I think the current hyper-completion is a
feature.  But if there are files and/or dirs in the target dir, I
don't think you want to assume a subdir for completion.

But many thanks for fixing my trailing space completion bug, however you did it.

JDH



More information about the IPython-dev mailing list