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

Re: Using the same completion function for various commands



On Mon, 6 Dec 2010 16:10:20 +0000
Peter Stephenson <Peter.Stephenson@xxxxxxx> wrote:
> On Mon, 6 Dec 2010 16:18:47 +0100
> Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> > Ah, er, right. But. Is there any way to combine -p and saying
> > foo=du ? When I tried compdef _du -p 'foo_*=du' nothing happened.

Yes, I know, it *still* doesn't work, and you were about complain.

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? Am I missing cases where you definitely don't want the basic
service run in order to check a variant?

Index: Completion/Base/Utility/_pick_variant
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_pick_variant,v
retrieving revision 1.2
diff -p -u -r1.2 _pick_variant
--- Completion/Base/Utility/_pick_variant	28 Feb 2009 07:11:31 -0000	1.2
+++ Completion/Base/Utility/_pick_variant	6 Dec 2010 16:18:54 -0000
@@ -7,7 +7,7 @@ local -A opts
 (( $+_cmd_variant )) || typeset -gA _cmd_variant
 
 zparseopts -D -A opts c: r:
-: ${opts[-c]:=$words[1]}
+: ${opts[-c]:=${service:-$words[1]}}
 
 while [[ $1 = *=* ]]; do
   var+=( "${1%%\=*}" "${1#*=}" )

-- 
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