Zsh Mailing List Archive
Messages sorted by:
Re: [PATCH v2] Correct completion of 'tmux new <TAB>'.
- X-seq: zsh-workers 41449
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [PATCH v2] Correct completion of 'tmux new <TAB>'.
- Date: Sun, 23 Jul 2017 14:01:27 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=cNak6+ 4EmKIi0UxOANklmwY/kIKFVZnaOec6tes9Xfc=; b=D6nA7uehQBt12oP4vDGlrx D6QzJp/JMPD74fSQaT2L6VcMVVTxrtXeafPLmQepmc57LNhe61qa98Dl5YeRvDd0 r/miLqpErcMMdvlhom9ohAdN1uTSCmdovPsQWe86EnbQSZgk0QfrYSeh8WgQacys LOWdRutYs9Ff38uuNblhmJyEjDVNAOCfpCjnKuwYWGHvAv9GXJLTOM3cEQ3DmRXq dE90gsL5fwS64YlAzy9SwDQPS+XGkj8tqW40h4oARv6T8tynwRogFj4mbDMkxjxF ywIR2Vz8LhF8fuvwXEPqA3IV4MO4+1bVfSXdPXLwXRCsDYON3d59KRl3EpKqCIcQ ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=cNak6+ 4EmKIi0UxOANklmwY/kIKFVZnaOec6tes9Xfc=; b=hYONW6EWiY1GVTnI/0B7LW gBQhFDPZbqsIuU431J/c4tjZAAHmIecpsh9oqWaDR3x/Upa6Y4nhYlj3WcdXf5Ah yvv0TVNTNR/Z4JtoPd/XOZm1Y0TVk+iqxjkbY7i6Lpww9da9wYbZg7mcXRvt/3fo 0kSJRxftsUv3qxNW8q4slYxv9JKzx5T/LJB62J2mkdbquVW2ITK9EcoLP3jh6v31 n5BkqIHVJcCo4JaUBVNCPhNzQRbPiPo79OCdy4xUgVm4vY71XqnDMPBIc65ay1CC HE/9AzYzcB4rYhDBKVXyyfP/ykZ2kwBm/kRSOWchlytMGtyWnrU2QPF5SrcKb0LQ ==
- In-reply-to: <email@example.com>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <firstname.lastname@example.org> <CAH+w=7ZNhO+C33_o21ZiuDiu_c2zf4rMHSh6PdgGtCXWJ7HPpw@mail.gmail.com> <1500659163.916799.1048510048.293AC92C@webmail.messagingengine.com> <email@example.com>
Oliver Kiddle wrote on Sun, 23 Jul 2017 09:48 +0200:
> 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!
> > +item(tt(_cmdambivalent))(
> > +Completes an external command.
> > +If there is more than one word in argument position on the command line, complete the command in a single word, like tt(_cmdstring);
> > +otherwise, complete the command in word-separated arguments, like tt(_precommand).
> > +)
> 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
Completes the remaining positional arguments as an external command.
The external command is completed as word-separated arguments (in the manner of tt(/usr/bin/env))
if there are two or more remaining positional arguments on the command line,
and as a quoted command string (in the manner of tt(system+LPAR()...+RPAR())) othrewise.
See also tt(_cmdstring), tt(_cmdrest), and tt(_precommand).
This function takes no arguments.
> 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.
Makes sense. In addition to checking for spaces, we could also check
for an opening quote. (An opening quote is more likely to signify a
quoted shell command than an argv with spaces.)
> 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.
Why not document _precommand? Firstly, documenting it would help
clarify that completes not only external commands but also functions and
aliases. Secondly, it could easily be useful to users. (I generally
write completion functions for my custom zshrc functions; I can easily
imagine myself writing some precommandish thing and wanting to have
completion after it.)
> 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.
Not quite what you meant to say, I think, but having that section of the
documentation grouped by logical function would make a lot of sense.
Right now, anyone who tries to understand _tags by RTFM'ing needs to
scroll back and forth between _tags, _requested, _wanted, and I forget
what else; they're pages away from each other.
Messages sorted by: