Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: matcher-list question
- X-seq: zsh-workers 24125
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Zsh Hackers List <zsh-workers@xxxxxxxxxx>
- Subject: Re: matcher-list question
- Date: Tue, 27 Nov 2007 21:58:45 +0000
- In-reply-to: <200711270956.lAR9ur36020646@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20071119160702.GB29766@xxxxxxxxx> <20071127084203.GA4034@xxxxxxxxx> <200711270956.lAR9ur36020646@xxxxxxxxxxxxxx>
On Tue, 27 Nov 2007 09:56:53 +0000
Peter Stephenson <pws@xxxxxxx> wrote:
> Andy Spiegl wrote:
> lama:~>zsh -f
> lama% autoload -U compinit; compinit -C
> lama% zstyle ":completion:*" matcher-list 'r:|[-./_]=* r:|=*' '+l:|=*'
Note that
zstyle ":completion:*" matcher-list 'r:|[-./_]=* r:|=* l:|=*'
shows the same problem slightly more simply.
> lama% ls
> foo-bar-abc foo-bar-def foo-bar-geh
> lama% ls bar<TAB>
> lama% ls -foobar-
>
> There's a bug somewhere in the code that assembles partial lines using
> matching in this fashion (the code that generates the lists seems to be
> OK, or at least the list of matches is correct).
I've got at least somewhere...
This is mostly for my benefit, in case I forget. I can't imagine
anyone else taking the slightest bit of interest.
add_match_part() in compatch.c is responsible for assembling the bits of
the match ("cline" structures), including prefixes, anchors, and
suffixes. In the case in question, "-" is the anchor with "foo"
as a prefix. However, the code at line 352,
if (m && (m->flags & CMF_LEFT)) {
lp->flags |= CLF_SUF;
lp->suffix = lp->prefix;
lp->prefix = NULL;
}
kicks in because this is a left anchor, which swaps the suffix and the
prefix. I confirmed that commenting out this code gets the completion
right in this particular case (with no obvious side effectis, though it
presumably screws up in other completions or with other matchers).
Still to understand: where left anchoring is actually coming in seeing
as the "-" in the matcher in use is in an expression which is marked as
a right anchor (yes, I checked that even in Svenland an 'l' in the
matcher is associated with CMF_LEFT). The only left anchor is the
'l:|=*', which anchors to the start of the command line; it should be
this that's matching the "foo" because it's only matched by virtue of
the wildcard at the start of the line, but I don't see why it's handling
the first "-". If I could understand why the "-" appeared here instead
of associated with a matcher with CMF_RIGHT, I might get further.
However, that's quite enough for one night.
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author