Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Using the same completion function for various commands
- X-seq: zsh-users 15625
- From: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Using the same completion function for various commands
- Date: Mon, 6 Dec 2010 17:08:12 +0000
- In-reply-to: <101206084428.ZM2380@xxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Organization: Cambridge Silicon Radio
- References: <201012061512.21791.mrichter@xxxxxxxxxxxxxxxxxxxxxxxx> <AANLkTimY=rEETn1uOdkDJ33kGE=YUDAvevsBvvvMU7YL@xxxxxxxxxxxxxx> <AANLkTim1Ac1-VOkRQ1NXn_qL6-EV06bagVkK7y_UThwB@xxxxxxxxxxxxxx> <AANLkTin+NCoBRzx90fo+s0z7urCCoTA6T3cXTYdt_VD2@xxxxxxxxxxxxxx> <20101206151124.389fd287@xxxxxxxxxxxxxxxxxxxxxxxxx> <AANLkTin8Kn88NXsK4V4Toos0-ZB2hj4RvhX5QxLarq1N@xxxxxxxxxxxxxx> <20101206161020.693f3f4a@xxxxxxxxxxxxxxxxxxxxxxxxx> <20101206162144.58d5b483@xxxxxxxxxxxxxxxxxxxxxxxxx> <101206084428.ZM2380@xxxxxxxxxxxxxxxxxxxxxx>
On Mon, 06 Dec 2010 08:44:28 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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-<subcommand>.
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 <pws@xxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author