zsh-users
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: "Ronan Pigott" <rpigott314@gmail.com>
Cc: zsh-users@zsh.org
Subject: Re: Possible to use _arguments with _regex_arguments?
Date: Wed, 18 Sep 2019 23:32:14 +0200	[thread overview]
Message-ID: <55899-1568842334.485890@bhzt.wnOj.CiXC> (raw)
In-Reply-To: <BX3EOWYQ1AY8.LBR42DF8EFH7@rxps>

"Ronan Pigott" wrote:
> I've since found that _arguments itself has the ability to transform the
> words and CURRENT special parameters by specifying the argument like:
> '*::message:action', but unfortunately it still does not produce the
> desired result when 'action' is a function generated by
> _regex_arguments. Can anyone explain the behavior I see?

Both _arguments and _regex_arguments like the words array to start with
an initial element for the command. With '*:message:action', the -o
options get left in $words. With the '*::... form, they are stripped but
there is no initial element left. Try using
    '*::positional arguments:= _myfunc'

More specifically:

  _regex_arguments _myfunc /$'*\0[ \t\n]#'/ \
    '/[]/' ':args:arg:(one two three)'

  _arguments -S -s \
    {-o+,--option}'[an option]:tag:(some values)' \
    '*::positional arguments:= _myfunc'

The = causes it to add back an initial element in $words.
_regex_arguments is then ignoring this with the /$'*\0[ \t\n]#'/ pattern
so this is all fairly pointless but _regex_arguments was somehow
designed for handling the whole command-line.

If you'd like to see a real example that combines _arguments with
_regex_arguments see _sed from a relatively recent zsh. 

Oliver

      parent reply	other threads:[~2019-09-18 21:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-18  2:31 Ronan Pigott
2019-09-18 20:21 ` Ronan Pigott
2019-09-18 21:07   ` Bart Schaefer
2019-09-18 21:36     ` Ronan Pigott
2019-09-18 21:32   ` Oliver Kiddle [this message]

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=55899-1568842334.485890@bhzt.wnOj.CiXC \
    --to=okiddle@yahoo.co.uk \
    --cc=rpigott314@gmail.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).