From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20484 invoked by alias); 6 Dec 2010 17:08:25 -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: 15625 Received: (qmail 11800 invoked from network); 6 Dec 2010 17:08:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Mon, 6 Dec 2010 17:08:12 +0000 From: Peter Stephenson To: Zsh Users Subject: Re: Using the same completion function for various commands Message-ID: <20101206170812.7c53824b@pwslap01u.europe.root.pri> In-Reply-To: <101206084428.ZM2380@torch.brasslantern.com> References: <201012061512.21791.mrichter@theory.phy.tu-dresden.de> <20101206151124.389fd287@pwslap01u.europe.root.pri> <20101206161020.693f3f4a@pwslap01u.europe.root.pri> <20101206162144.58d5b483@pwslap01u.europe.root.pri> <101206084428.ZM2380@torch.brasslantern.com> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 06 Dec 2010 17:08:12.0590 (UTC) FILETIME=[2A1D6CE0:01CB9568] X-Scanned-By: MailControl A_10_80_00 (www.mailcontrol.com) on 10.68.0.131 On Mon, 06 Dec 2010 08:44:28 -0800 Bart Schaefer wrote: > On Dec 6, 4:21pm, Peter Stephenson wrote: > } > } Is the following change to _pick_variant right? Why we would ever > } prefer $words[1] to $service, when this seems to be what $service is > } for? > > My recollection is that $words[1] is always a command, whereas > $service may just be a placeholder name. However, I can't provide an > example where this would introduce a problem for _pick_variant in > particular. Yes, for example in _perforce I use the service as p4-. But, as you imply, in that case there's no question of running _pick_variant, we've already got into the detailed syntax another way. We can just pass -c $service to _pick_variants, it's just that that's yet another variable factor to go wrong, so if we can avoid it that's good. In particular, you don't notice it's gone wrong until a case like the one Mikael noticed --- to put it another way, the service is a parameter that can be set by the user, and until the user tries to map a new command to an existing completion you don't know the completion function needed "-c $service". Of course, if we find a case where this doesn't work, the caller can use "-c $words[1]". Given that I think that's the odd case out, maybe I'll just commit it and see what happens. (Sigh. Good job it's only Monday...) -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom