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

Re: completion after --



On 26 Jul, Erik Toubro Nielsen wrote:
> Assume a command line, where the option --files mean that at least one
> filename can be given after '--'
> 
>    cmd --files --other-options  ARG1 -- filenames...
> 
> (without --files the command line is
>    cmd --other-options  ARG1 
> )
> 
> The _arguments function does not seem applicable.

_arguments is applicable but it isn't sufficient on it's own.

> Any hints on how to write a completion function _cmd for this?

Check for --files and -- before calling _arguments:

local -a args
if (( ${+words[(r)--files]} && ${+words[(r)--]} && words[(i)--] < CURRENT ))
then
  _wanted files expl file _files
else
  _arguments '--files' '--other-options' ':arg1:(ARG1)'
fi

That also checks that the `--' is before the cursor.

Oliver

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________



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