Fixing tab-completion of filenames

Judah Jacobson judah.jacobson at gmail.com
Thu Feb 8 03:23:02 EST 2007


Hi,

Apologies if this email is a duplicate; a previous version may have
been bounced by the mailing list.

I've been looking into ghc bug #998 (Tab-completion of filenames
doesn't work in ghci-6.6), and have isolated the problem:  Since ghci
now expands Haskell names, it tells readline that several extra
symbols (such as '+', '-' or '/') are word boundaries; thus tabbing
after "foo+len" expands "len" to "length".  However, tabbing after ":l
folder/file" tries to expand just "file" instead of the full path
"folder/file", since readline now thinks that "/" is a word boundary.

There's a few possible solutions:

1) As a workaround, you can add the following 3 lines to your .ghci
file, removing '/' from the list of word boundaries:

:m +System.Console.Readline Data.List
getCompleterWordBreakCharacters >>= setCompleterWordBreakCharacters . delete '/'
:m -System.Console.Readline Data.List

2) Change the code (in InteractiveUI.hs) to eliminate "/" from the
list of word break characters.  This is a one-character diff, but not
really the "right" way to do things.

3) A better solution is to use rl_completion_word_break_hook from the
readline library, which lets us change the set of word break
characters based on the context of the line.  This way, "/" would be a
word break if we're expanding a Haskell name, but not if we're
expanding a filename.  However, that hook isn't currently exported
from System.Console.Readline, so this would also require a patch to
the Haskell readline package.

Since #3 requires an API change, I assume it can't happen until 6.8?
If so, should #2 be made to the 6.6.1 branch, or should we recommend
#1 in the meantime?  I have written up and tested patches for #2 and
#3, as well as the necessary changes to the readline package; but
since I'm new to ghc development, I figured I'd ask what other people
thought before darcs sending any patches.

Thanks,
-Judah



More information about the Cvs-ghc mailing list