zsh: cache hg help output
authorBrendan Cully <brendan@kublai.com>
Tue, 24 Oct 2006 13:17:41 -0700
changeset 3498 776c317566b6
parent 3497 459e7cd943d4
child 3499 e0db0b7934f2
zsh: cache hg help output
contrib/zsh_completion
--- a/contrib/zsh_completion	Tue Oct 24 13:09:09 2006 -0700
+++ b/contrib/zsh_completion	Tue Oct 24 13:17:41 2006 -0700
@@ -14,7 +14,7 @@
 
 local curcontext="$curcontext" state line
 typeset -A opt_args
-local subcmds repos newFiles addedFiles includeExclude commitMessage
+local repos newFiles addedFiles includeExclude commitMessage
 local ridx _hgroot
 
 # FIXME: why isn't opt_args available?
@@ -44,7 +44,8 @@
   esac
 }
 
-subcmds=($(hg -v help | sed -e '1,/^list of commands:/d' \
+(( $+_hg_commands )) ||
+_hg_commands=($(hg -v help | sed -e '1,/^list of commands:/d' \
       -e '/^global options:/,$d' -e '/^ [^ ]/!d; s/[,:].*//g;'))
 
 # A lot of commands have these arguments
@@ -88,7 +89,7 @@
     '*::command:->subcmd' && return 0
 
     if (( CURRENT == 1 )); then
-        _wanted commands expl 'hg command' compadd -a subcmds
+        _wanted commands expl 'hg command' compadd -a _hg_commands
         return
     fi
     service="$words[1]"
@@ -429,7 +430,7 @@
     ;;
 
     (help)
-        _wanted commands expl 'hg command' compadd -a subcmds
+        _wanted commands expl 'hg command' compadd -a _hg_commands
     ;;
 
     (heads)