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

Re: [PATCH v2] Correct completion of 'tmux new <TAB>'.

Daniel Shahaf wrote:
> > I believe I understand what this is doing, but "if there is a single
> > argument" isn't entirely clear.  It does NOT mean "if there is a
> > single positional parameter in the call to this function" (which is
> > how I first read it, before I actually looked at the function
> > definition); rather it means "if there is more than one word in
> > argument position on the command line".
> > 
> I'll change to your wording before committing.  Thanks for the
> blind review!

For the documentation wouldn't it perhaps be better to describe the
basic use first. i.e. it is for commands that are ambivalent about
taking either a quoted command-string or a command and series of

Your implementation will favour the _cmdstring variant in the sense that
completing a command-name will give you a quoted space as the suffix.
I think it would be preferable to check if the first and only argument
contains any spaces before switching to the _cmdstring variant and so
avoid unnecessary quoting.

We might also want to consider the many cases where we use the following
_arguments idiom:

  '(-):command:_command_names -e' \

This also appears in if .. then .. else form in _strace and _socket.
It might be good to cover this with a single helper - _cmdrest perhaps
- but note that _precommand is not for this purpose: it completes
functions and aliases. I'm not convinced that _precommand should be
documented in this section at all. It wasn't really meant as a helper
but as a as a catch-all handler for the zsh precommand modifiers. Note
that it is in Zsh/Command.

I see a precommands array was added around 2009 in _precommand to
facilitate _calendar's check to see if it was run with command. What
do we want to include in this. It might be useful to collect all the
wrapper commands and not just zsh precommand modifiers. It is somewhat
similar to the _comp_priv_prefix that we added more recently.


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