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

Re: command completion

On Aug 15,  1:07am, Vincent Lefevre wrote:
} Subject: Re: command completion
} On 2011-08-14 15:14:53 -0700, Bart Schaefer wrote:
} > Here we have the key.  In order to stop "remaining tags" from being tried,
} > the value "-" must appear somewhere in the completion style.  So your
} > problem is solved by:
} > 
} >     zstyle ':completion:*:complete:-command-:*' tag-order 'commands' -
} Not really. I still wish to generate a completion for directories in
} the cdpath if there are no matches.

Ah, I see.

As I said before, it's really got to do with how _autocd insinuates itself
into the process.

Autocd makes itself the handler for -command-.  It then calls both
_command_names and _cd, each of which takes a spin through _alternative,
so it goes around the _tags loop twice as well.

If there were only one pass through _alternative, I think you'd get what
you're looking for; but because there are two passes and there are no
*additional* completions for the "command" tag added inside _cd, all
the defaults for _cd get added as well.

So, unfortunately, I don't believe you can get what you want with
zstyles.  You'll have to rewrite _autocd, something like so:

#compdef -command-
_command_names && return 0
[[ -o autocd ]] && _cd && return 0
return 1

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