From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12988 invoked by alias); 23 Jul 2017 14:01:39 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41449 Received: (qmail 10202 invoked from network); 23 Jul 2017 14:01:39 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-0.7/5.0):. Processed in 2.337915 secs); 23 Jul 2017 14:01:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) 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 == X-ME-Sender: Message-Id: <1500818487.2639605.1049794664.32ABA0EF@webmail.messagingengine.com> From: Daniel Shahaf To: zsh-workers@zsh.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-095ee039 References: <20170720210607.16753-1-danielsh@tarpaulin.shahaf.local2> <1500659163.916799.1048510048.293AC92C@webmail.messagingengine.com> <19454.1500796085@thecus.kiddle.eu> Subject: Re: [PATCH v2] Correct completion of 'tmux new '. Date: Sun, 23 Jul 2017 14:01:27 +0000 In-Reply-To: <19454.1500796085@thecus.kiddle.eu> 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 > arguments. How about: item(tt(_cmdambivalent))( 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[0] with spaces.) > We might also want to consider the many cases where we use the following > _arguments idiom: > > '(-):command:_command_names -e' \ > '*::args:_normal' > > 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. > Oliver Cheers, Daniel