about summary refs log tree commit diff
path: root/Completion/Unix/Command/_subversion
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2011-01-09 16:57:01 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2011-01-09 16:57:01 +0000
commite72999c092b80b71c5913a52c411a1c7529971f4 (patch)
tree02974c6a4f7a4d73934481f731f12703a682fae7 /Completion/Unix/Command/_subversion
parenta89f0559c210def9a40bfeb9da6b38128a49cb55 (diff)
downloadzsh-e72999c092b80b71c5913a52c411a1c7529971f4.tar.gz
zsh-e72999c092b80b71c5913a52c411a1c7529971f4.tar.xz
zsh-e72999c092b80b71c5913a52c411a1c7529971f4.zip
gi1242+zsh@gmail.com: 28594:
Various new and improved completions
Diffstat (limited to 'Completion/Unix/Command/_subversion')
-rw-r--r--Completion/Unix/Command/_subversion42
1 files changed, 35 insertions, 7 deletions
diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion
index f0dbb5fc2..44d83b7fe 100644
--- a/Completion/Unix/Command/_subversion
+++ b/Completion/Unix/Command/_subversion
@@ -4,6 +4,12 @@ _svn () {
   local curcontext="$curcontext" state line expl ret=1
   typeset -A opt_args
 
+  local update_policy
+  zstyle -s ":completion:*:*:$service:*" cache-policy update_policy
+  if [[ -z "$update_policy" ]]; then
+    zstyle ":completion:*:*:$service:*" cache-policy _svn_caching_policy
+  fi
+
   _arguments -C \
     '(-)--help[print help information]' \
     '(- *)--version[print client version information]' \
@@ -12,9 +18,12 @@ _svn () {
 
   if [[ -n $state ]] && (( ! $+_svn_cmds )); then
     typeset -gHA _svn_cmds
-    _svn_cmds=(
-      ${=${(f)${${"$(LC_ALL=C _call_program commands svn help)"#l#*Available subcommands:}%%Subversion is a tool*}}/(#s)[[:space:]]#(#b)([a-z]##)[[:space:]]#(\([a-z, ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:}
-    )
+    if ! _cache_invalid svn_cmds && ! _retrieve_cache svn_cmds; then 
+      _svn_cmds=(
+	${=${(f)${${"$(LC_ALL=C _call_program commands svn help)"#l#*Available subcommands:}%%Subversion is a tool*}}/(#s)[[:space:]]#(#b)([a-z]##)[[:space:]]#(\([a-z, ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:}
+      )
+      _store_cache svn_cmds _svn_cmds
+    fi
   fi
 
   case $state in
@@ -29,10 +38,20 @@ _svn () {
       if (( $#cmd )); then
         curcontext="${curcontext%:*:*}:svn-${cmd}:"
 
-        usage=${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"}:#usage:*}#usage:*$cmd] }
-        args=(
-          ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
-        )
+	if ! _cache_invalid svn-${cmd}-usage && \
+	    ! _retrieve_cache svn-${cmd}-usage;
+	then
+	  usage=${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"}:#usage:*}#usage:*$cmd] }
+	  _store_cache svn-${cmd}-usage usage
+	fi
+	if ! _cache_invalid svn-${cmd}-usage && \
+	    ! _retrieve_cache svn-${cmd}-args;
+	then
+	  args=(
+	    ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
+	  )
+	  _store_cache svn-${cmd}-args args
+	fi
 
         case $cmd in;
           (add)
@@ -297,4 +316,13 @@ _subversion () {
   esac
 }
 
+_svn_caching_policy() {
+  # Rebuild every week
+  local -a oldp
+
+  oldp=( "$1"(Nmw+1) )
+  (( $#oldp ))
+}
+
+
 _subversion "$@"