zsh: cache hg help output
authorBrendan Cully <brendan@kublai.com>
Tue, 24 Oct 2006 13:17:41 -0700
changeset 3492 776c317566b6
parent 3491 459e7cd943d4
child 3493 e0db0b7934f2
zsh: cache hg help output
contrib/zsh_completion
--- a/contrib/zsh_completion
+++ b/contrib/zsh_completion
@@ -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 @@ ridx=$words[(i)-R]
   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 @@ if [[ $service == "hg" ]]; then
     '*::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 @@ case $service in
     ;;
 
     (help)
-        _wanted commands expl 'hg command' compadd -a subcmds
+        _wanted commands expl 'hg command' compadd -a _hg_commands
     ;;
 
     (heads)