zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh Hackers List <zsh-workers@sunsite.dk>
Subject: Re: matcher-list question
Date: Tue, 27 Nov 2007 21:58:45 +0000	[thread overview]
Message-ID: <20071127215845.bda5b747.p.w.stephenson@ntlworld.com> (raw)
In-Reply-To: <200711270956.lAR9ur36020646@news01.csr.com>

On Tue, 27 Nov 2007 09:56:53 +0000
Peter Stephenson <pws@csr.com> 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@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


       reply	other threads:[~2007-11-27 21:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20071119160702.GB29766@spiegl.de>
     [not found] ` <20071127084203.GA4034@spiegl.de>
     [not found]   ` <200711270956.lAR9ur36020646@news01.csr.com>
2007-11-27 21:58     ` Peter Stephenson [this message]
2007-11-28 20:47       ` Peter Stephenson
2007-11-28 21:28         ` Peter Stephenson
2007-12-11 17:44         ` Andy Spiegl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071127215845.bda5b747.p.w.stephenson@ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).