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

Re: "fake" style requires at least one real match?

On Nov 4, 10:02pm, Bart Schaefer wrote:
} -- then it ignores tag-order entirely:

OK, not entirely because it does construct the named-directories-mine
tag and use its description -- but it doesn't apply the ordering, it
populates all the tags.

Really long diagnosis follows, working sort of backwards up the call
stack.  Skip to the last three paragraphs if you don't want to know
all the details.

This happens because _tilde calls _users and _directory_stack as
well as passing compadd down to _requested for the named-directories
tag.  So users and directory stack entries look up ignored-patterns
entirely separately from the named-directories context.  There's no
other context for _tilde when it is called from _cd (as opposed to
when there is actually a tilde on the line, and you get -tilde- as
the context), so you can't apply ignored-patterns to all of it in
one go unless you apply it to :cd:*:*.

There are probably other cases like this that selectively break the
"supplemented context" usage of tag-order, it's just difficult to see
unless you're also trying to use ignored-patterns in such a context.

The next question is why "_requested users" etc. succeded even though
the tag-order style does not include "users".

Looking at _complete_debug output, we enter _tilde and it calls

    _tags users named-directories directory-stack

It then does

    while _tags

and tries _requested for all three tags in the first pass of the loop.
None of these work because only named-directories-mine is being sought
as the current tag in _all_labels.

So the loop goes around again, comptags -N moves on to the next tag
group, _requested calls "comptags -R" which succeeds, but now $# -eq 1
so neither _all_labels nor _description is called, and _requested
returns 0.  Therefore both _users and _directory_stack get called,
no ignored-patterns are applied, and too much stuff ends up getting
passed to compadd.

This all bubbles up to _alternative, which is calling

    while _next_label

and inside _next_label is where the supplemented context is built.

_tilde gets called, _all_labels reconstructs named-directories-mine,
we do one pass that does the right thing with fake and fake-always,
but then compadd ($4) on line 35 of _all_labels fails so _all_labels
itself fails even though matches were added by _description on line
32; and _alternative goes around the _next_labels loop another time
resulting in all the aforementioned breakage in _tilde.

The upshot of all this is that _description is never expected to
*call* compadd, it's only supposed to generate arguments for compadd
that its caller can pass to compadd; but fake and fake-always are in 
fact compadd-ed directly in _description.  _all_labels (in this case)
doesn't know they are there, and tells *its* caller to keep looking.

I have no immediate idea what to do about this.  We can't rewrite
every caller of _description to delta $compstate[nmatches] just
in case a fake style was used.  And in fact it only matters when
ONLY the fake matches are added, as the Subject: says ... except:

As an additional complication, there's a comment in _describe about
bad things happening if _describe is called more than once for the
same completion, but that's what may happen if fake or fake-always
use the value:description format and there are also descriptions
for the other matches in the context.

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