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

Re: Completion for cd



On Wed, Mar 15, 2017 at 4:56 AM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
wrote:

> The clue is at the very end of each file:  In the first case [that
> ignores parents as expected], the _complete function generated the
> matches, but in the second case the _approximate function generated
> them.
>
> The path search correctly excludes "zaa" but then _approximate puts it
> back because it is similar enough to the string on the command line.
>

Thanks to your help, I managed to find a working solution, changing the
critical lines to this:
zstyle ':completion:*:complete:cd:*:*' tag-order local-directories
directories -
zstyle ':completion:*:withpath:cd:*:*' tag-order path-directories

In other words,  I have added 'directories' to the first line.

However, I still don't fully understand what is going on. As per your
findings, it's the _approximate function that adds 'zaa'. But that must
mean that none of the previous completers have found any match, doesn't it?
If _complete or  _complete:withpath had found even _one_ match,
_approximate would never have been called, right?

The documentation for the local-directories tag says that it and
path-directories are used if cdpath is set, instead of the 'directories'
tag. I had interpreted this to mean that the 'directories' tag does not
come into play when doing cd completion whenever cdpath is set, as in my
case.

Furthermore, as I read the documentation of tag-order, all tags are in play
after the explicitly mentioned tags, _unless_ the list ends with a hyphen.
However, the tag-order of the second completer, 'withpath', doesn't end
with a hyphen, and I would thus have expected the 'directories' tag to be
tried even though it is not explicitly mentioned.

In short, I would have thought that 'directories' was uninteresting tag
when cdpath was set, and when it actually was in play, I would have thought
it would be tried by the withpath-completer since there is no hyphen at the
end of the tag-order. But obviously I have misunderstood something here,
since it works. I'm just curious to know where the fault in my
understanding is.


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