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

Re: Q: _regex_arguments problem



On Fri, 2 Dec 2011 17:14:18 +0400
"Alexey I. Froloff" <raorn@xxxxxxxxxxxx> 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@xxxxxxx>            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



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