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

Re: PATCH: zstyle to control completion of functions/parameters beginning with underscore



>>>>> On March 6, 2011 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:

> It's fine.

Well, maybe not :-(

I've noticed some bugginess with this:

| zsh -f
| phl% autoload -U compinit
| phl% compinit -u
| phl% function foobar () { echo foobar }

OK, now hit <tab> to complete after 'foobar':
| phl% foobar<tab>
and it adds a space.

now,
| phl% zstyle ':completion:*' prefix-needed true
and try completing 'foobar' again:
| phl% foobar<tab>
and it just beeps.

If I change _command_names to instead declare a local 'funcnames' and
change the prefix-needed logic to:

| if zstyle -t ":completion:${curcontext}:functions" prefix-needed && \
|    [[ $PREFIX != [_.]* ]] ; then
|   funcnames=(${(k)functions[(I)[^_.]*]})
| else
|   funcnames=(${(k)functions})
| fi

and change the compadd in defs for functions to 'compadd -a funcnames',
then it works fine.

Completion of 'foobar' after 'unfunction' (i.e. using the equivalent
change made to _functions) however works fine.

So it seems like compadd's handling of the -k with subscript is not
always working properly.

My parameter completion change seems to be unaffected; which makes
sense since it's directly adding the completions to the compadd
invocation.

thanks,
Greg



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