From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15408 invoked by alias); 14 Mar 2012 17:20:01 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16878 Received: (qmail 10654 invoked from network); 14 Mar 2012 17:19:49 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <120314101917.ZM25639@torch.brasslantern.com> Date: Wed, 14 Mar 2012 10:19:17 -0700 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?= References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Putting options after tasks MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable On Mar 14, 9:53am, Jesper Nyg=E5rds 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.