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

Re: widget special PREFIX variable and cursor position with complete_in_word



On 02/17/2014 05:50 PM, Oliver Kiddle wrote:
>> By also unquoting and checking for the 'all-files' tag, I can
>> correctly match completions for (path)/files and quoted arguments.
> 
> Have you got an example for that?

$ touch file fjle

$ ls f<TAB>
$ ls ./f<TAB>
$ ls $PWD/t<TAB>

or

$ touch file 'file a' 'file b'

$ ls file<TAB>
$ ls file\ <TAB>
$ ls "file<TAB>

also try with:

$ touch 'file*' 'file *' 'file(' 'file\' 'file\\'

for some fancy ways to break the completion in awesome ways (the last
three fail for me with and without the quote).

> It isn't actually recursive. The intention with it was to cope with
> all situations where a shell word is completed in steps. What you
> have is hard coding / as a separator which is fine for
> paths/filenames. Try completion after, for example, ssh user@host.

The problem is that you don't know exacly what the completer is going to
display. This is why I check $curtag. I'm not sure there's a better way
to handle the situation then this:

    case $curtag in
    all-files) prefix=${prefix##*/} ;;
    hosts) prefix=${prefix#*@} ;;
    esac

Now it works for me, since the ssh <TAB> will first complete for
<users|hosts>, then just a second hosts fragment, then probably a path
(which should be in all-files again). Maybe there's some smarter way to
extract the separator?




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