From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19974 invoked by alias); 12 Oct 2011 18:18:41 -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: 29820 Received: (qmail 13934 invoked from network); 12 Oct 2011 18:18:29 -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 autolearn=ham version=3.3.1 Received-SPF: neutral (ns1.primenet.com.au: 74.125.82.171 is neither permitted nor denied by SPF record at ntlworld.com) X-ProxyUser-IP: 86.6.29.42 Date: Wed, 12 Oct 2011 19:18:18 +0100 From: Peter Stephenson To: Zsh Hackers' List Subject: PATCH: _pick_variants -b option Message-ID: <20111012191818.0ab50ada@pws-pc.ntlworld.com> X-Mailer: Claws Mail 3.7.9 (GTK+ 2.24.4; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit I wrote this some time ago but never got around to posting it. It's only lightly tested. Index: Completion/Base/Utility/_pick_variant =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_pick_variant,v retrieving revision 1.4 diff -p -u -r1.4 _pick_variant --- Completion/Base/Utility/_pick_variant 7 Dec 2010 15:10:48 -0000 1.4 +++ Completion/Base/Utility/_pick_variant 12 Oct 2011 18:16:58 -0000 @@ -6,7 +6,7 @@ local -A opts (( $+_cmd_variant )) || typeset -gA _cmd_variant -zparseopts -D -A opts c: r: +zparseopts -D -A opts b: c: r: : ${opts[-c]:=$words[1]} while [[ $1 = *=* ]]; do @@ -19,6 +19,12 @@ if (( $+_cmd_variant[$opts[-c]] )); then return 0 fi +if [[ $+opts[-b] -eq 1 && -n $builtins[$opts[-c]] ]]; then + _cmd_variant[$opts[-c]]=$opts[-b] + (( $+opts[-r] )) && eval "${opts[-r]}=${_cmd_variant[$opts[-c]]}" + return 0 +fi + output="$(_call_program variant $opts[-c] "${@[2,-1]}" &1)" for cmd pat in "$var[@]"; do Index: Doc/Zsh/compsys.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v retrieving revision 1.242 diff -p -u -r1.242 compsys.yo --- Doc/Zsh/compsys.yo 7 Sep 2011 13:43:38 -0000 1.242 +++ Doc/Zsh/compsys.yo 12 Oct 2011 18:16:58 -0000 @@ -4387,7 +4387,9 @@ tt(ambiguous), tt(special-dirs), tt(list described above. ) findex(_pick_variant) -item(tt(_pick_variant [ tt(-c) var(command) ] [ tt(-r) var(name) ] var(label)tt(=)var(pattern) ... var(label) [ var(args) ... ]))( +xitem(tt(_pick_variant) [ tt(-b) var(builtin-label) ] [ tt(-c) +var(command) ] [ tt(-r) var(name) ]) +item( var(label)tt(=)var(pattern) ... var(label) [ var(args) ... ])( This function is used to resolve situations where a single command name requires more than one type of handling, either because it has more than one variant or because there is a name clash between two @@ -4403,6 +4405,10 @@ tt(...)' contains var(pattern), then tt( for the command variant. If none of the patterns match, the final command label is selected and status 1 is returned. +If the `tt(-b) var(builtin-label)' is given, the command is tested to +see if it is provided as a shell builtin, possibly autoloaded; if so, +the label var(builtin-label) is selected as the label for the variant. + If the `tt(-r) var(name)' is given, the var(label) picked is stored in the parameter named var(name). -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/