zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Putting options after tasks
Date: Wed, 14 Mar 2012 10:19:17 -0700	[thread overview]
Message-ID: <120314101917.ZM25639@torch.brasslantern.com> (raw)
In-Reply-To: =?iso-8859-1?Q?=3CCABZhJg9sya0JmRYG+2OYw6nb=3DeX_ZBj37fFXn_Ji?= =?iso-8859-1?Q?t1fTK8zrDw=40mail=2Egmail=2Ecom=3E?= =?iso-8859-1?Q?Comments=3A_In_reply_to_Jesper_Nyg=E5rds_=3Cjesper=2Enygar?= =?iso-8859-1?Q?ds=40gmail=2Ecom=3E?= =?iso-8859-1?Q?________=22Putting_options_after_tasks=22_=28Mar_14=2C__9?= =?iso-8859-1?Q?=3A53am=29?=

On Mar 14,  9:53am, Jesper Nygårds wrote:
}
} What do I have to do to make it possible to complete options after tasks?

_arguments is designed to assume that programs accept all options first
and all other arguments after them.  If you have a program that doesn't
follow that convention, you may be able to use _regex_arguments (good
luck there, I'm not sure there's anyone still reading this list who has
any experience with it) or will need to write your own loop over the
$words array.

Given that the tasks and options can be freely mixed in this way, I
presume that none of the options take a following argument (that is,
"--foobar zoom" never means that "zoom" must appear immediately after
"--foobar").

If that's true, then one possibility is to make a first loop over the
$words array and insert a "+" sign in front of all the task names (but
stop before, or skip over, $words[CURRENT]), so that _arguments can
interpret as options the words you are NOT completing.  In that same
loop over the words, build up a a list of dummy option specs to pass
to _arguments so it knows to skip them.  Then add those dummy specs to
the real specs when making the _arguments call.

At the end, loop over $words again and remove the "+" signs you added
before returning $ret.  This may not be necessary but will avoid conflict
with other completers later.


  reply	other threads:[~2012-03-14 17:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-14  8:53 Jesper Nygårds
2012-03-14 17:19 ` Bart Schaefer [this message]
2012-03-15  7:31   ` Jesper Nygårds
2012-03-14 18:30 ` Mikael Magnusson
2012-03-15  7:33   ` Jesper Nygårds

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=120314101917.ZM25639@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).