zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: _pick_variants -b option
@ 2011-10-12 18:18 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2011-10-12 18:18 UTC (permalink / raw)
  To: Zsh Hackers' List

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]}" </dev/null 2>&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 <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-10-12 18:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-12 18:18 PATCH: _pick_variants -b option Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).