Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Filename expansion within a completion widget



    Hi Bart :)

 * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> > >     compset -P '*/'
> > > 
> > >     Well, it handles both relative and absolute directories
> > > correctly, but doesn't handle named directories :(( I don't
> > > understand why because if I type 'cd ~X<TAB>' the named dir should be
> > > expanded, shouldn't it?
> "Expanded" would mean that ~X was replaced by the path it represents.  
> Yet later you say this isn't the behavior you want.

    I didn't explained correctly O:)) I want it expanded within the
completion widget, not in the command line. The problem is that the
compadd call doesn't work if the WORD has '~' as the first character.

    I want this:

    $ cd ~X<TAB><TAB>

    X11/    usr/    bin/    include/

    And after that, insert the completions. If I 'translate' PREFIX
so the named dir is expanded, completion works OK, but then I have
the named dir translated in the command line.

    I want to translate it only in the widget so compadd can
correctly generate the list.

> >     Of course, adding something like 'PREFIX=$~PREFIX' just before
> > the compset call solves the problem, but then the named dir is
> > 'translated', which I don't want
> Just because you're not using zsh's completion system functions doesn't 
> mean you can't look at them for hints.  Completion/Unix/Type/_tilde_files 
> would be a good place to start; note in particular the case statement on
> $PREFIX.

    I'll take a look, but my problem is that I don't understand most
of the code. It is not very readable and is quite complex for me O:)
But I'll take a look at _tilde_files. Thanks for the reference.
 
> > There is surely another way of doing this...
> The short answer is that if there is not a slash in the string yet, you 
> remove the tilde from consideration with compset -P, and then you compadd 
> the userdirs and/or nameddirs arrays from the zsh/parameter module.  If 
> there is a slash in the string, you have to manipulate IPREFIX and then 
> use compadd -W.

    Thanks a lot, Bart, I'll take a look at _tilde_files and try to
get the point. Thanks for coming to the rescue again ;)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/



Messages sorted by: Reverse Date, Date, Thread, Author