zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <Peter.Stephenson@csr.com>
To: <zsh-users@zsh.org>
Subject: Re: Q: _regex_arguments problem
Date: Fri, 2 Dec 2011 16:15:19 +0000	[thread overview]
Message-ID: <20111202161519.3adb17bf@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20111202131418.GA18623@altlinux.org>

On Fri, 2 Dec 2011 17:14:18 +0400
"Alexey I. Froloff" <raorn@altlinux.org> wrote:
> I want to complete --variants option argument as a
> comma-separated list of variants, like
> 
> fubar --variants one,two,four
> 
> The only example of _regex_words/_regex_arguments usage is ip(8)
> completion, but it doesn't use such syntax.

Even though I didn't use this in _ip I don't think it's too hard if you
approach it the right way...

The key point is that in this case you are given the whole command line
at once, joined with NULLs --- you are not matching against individual
words, you are partially matching bits of the command line until you get
to the command position, at which point it tries to complete whatever
the possible matches are at that point.  (That's why you tend to get all
those $'\0' strings around --- they're specifying the end of a word.)

So the idea is that when you have matched up to "fubar --variants one",
you need to tell it that at this point either you get end of word and a
new argument, or you get a "," and another variant.  If I'm right, that
ought to be fairly straightforward (but I've completely forgotten about
the details).

If I'm wrong, the may be some special fact about matching the end
of a word that I haven't twigged.  But I *think* it's general enough
to cope.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


  parent reply	other threads:[~2011-12-02 16:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-02 13:14 Alexey I. Froloff
2011-12-02 15:45 ` Bart Schaefer
2011-12-02 16:15 ` Peter Stephenson [this message]
2011-12-02 17:37   ` Alexey I. Froloff
2011-12-02 18:14     ` Bart Schaefer
2011-12-02 20:25       ` Peter Stephenson

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=20111202161519.3adb17bf@pwslap01u.europe.root.pri \
    --to=peter.stephenson@csr.com \
    --cc=zsh-users@zsh.org \
    /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).