about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2010-10-01 18:27:58 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2010-10-01 18:27:58 +0000
commit30d6deb355e662c97d82db30b02031b67e09458e (patch)
treec1fc69f20a525e0e6c520b095ded529a01de00fa
parent5ca08eccd00de6664ef461e0dfbb40757d21b637 (diff)
downloadzsh-30d6deb355e662c97d82db30b02031b67e09458e.tar.gz
zsh-30d6deb355e662c97d82db30b02031b67e09458e.tar.xz
zsh-30d6deb355e662c97d82db30b02031b67e09458e.zip
28307: support new styles esp. vcs_info ones and allow quoted contexts again
-rw-r--r--ChangeLog7
-rw-r--r--Completion/Zsh/Command/_zstyle127
2 files changed, 124 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index a27f9a308..ca479c203 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-10-01  Oliver Kiddle  <opk@zsh.org>
+
+	* 28307: Completion/Zsh/Command/_zstyle: support new styles
+	especially vcs_info ones and allow quoted contexts again
+
 2010-09-25  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* 28295 plus tweak for failure case: use lexer to split words
@@ -13677,5 +13682,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5087 $
+* $Revision: 1.5088 $
 *****************************************************
diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle
index dcf30c083..708c0fddf 100644
--- a/Completion/Zsh/Command/_zstyle
+++ b/Completion/Zsh/Command/_zstyle
@@ -1,7 +1,7 @@
 #compdef zstyle
 
 local state context ostate line expl ctop suf
-local nm=$compstate[nmatches] taglist patterns pstyles
+local nm=$compstate[nmatches] taglist patterns pstyles contexts
 typeset -A opt_args styles
 
 (( $+functions[_completers] )) ||
@@ -9,7 +9,7 @@ _completers() {
   # option: -p - needs a `_' prefix
   local us
   local -a disp list expl
-  
+
   list=( complete approximate correct match expand list menu oldlist
          ignored prefix history )
   zparseopts -D -K -E 'p=us'
@@ -25,6 +25,7 @@ _completers() {
 #   c   completion
 #   d   chpwd
 #   e   line editor
+#   v   vcs_info
 #   z   zftp
 # or any combination of the above,
 # followed by a colon, followed by a state to enter, empty if none.
@@ -41,14 +42,21 @@ styles=(
   cache-policy           c:_functions
   call-command           c:bool
   command                c:command
+  command-path		 c:_dir_list
   commands               c:
   complete               c:bool
+  complete-options	 c:bool
   completer		 c:completer
   condition		 c:bool
   cursor		 c:cursor
+  delimiters		 c:
   disabled               c:bool
   domains                c:
+  environ		 c:environ
   expand		 c:
+  extra-verbose		 c:bool
+  fake			 c:
+  fake-always            c:
   fake-files		 c:fake-files
   fake-parameters	 c:fake-params
   file-list              c:bool
@@ -94,11 +102,12 @@ styles=(
   numbers		 c:bool
   old-list		 c:bool
   old-matches            c:oldmatches
-  old-menu		 c:bool 
+  old-menu		 c:bool
   original		 c:bool
   packageset		 c:packageset
   path			 c:_directories
   pager			 c:_command_names
+  path-completion	 c:bool
   pine-directory         c:_directories
   ports			 c:_ports
   prefix-hidden		 c:bool
@@ -107,17 +116,18 @@ styles=(
   range                  c:
   recent-dirs-insert     c:recent-dirs-insert
   regular                c:bool
+  rehash		 c:bool
   remote-access		 c:bool
   remove-all-dups	 c:bool
   select-prompt          c:
   select-scroll          c:
   separate-sections      c:bool
+  show-completer	 c:bool
   single-ignored         c:single-ignored
   sort			 c:bool
   special-dirs		 c:sdirs
   squeeze-slashes	 c:bool
   stop			 c:stop
-  stop-keys		 c:
   strip-comments	 c:bool
   subst-globs-only       c:bool
   substitute		 c:bool
@@ -127,6 +137,8 @@ styles=(
   urls                   c:_urls
   use-cache		 c:bool
   use-compctl		 c:urgh
+  use-ip		 c:bool
+  use-perl		 c:bool
   users			 c:_users
   users-hosts		 c:user-host
   users-hosts-ports	 c:user-host-port
@@ -160,6 +172,24 @@ styles=(
   word-style             e:word-style
   word-context           e:
 
+  formats                v:vcs-format
+  actionformats          v:vcs-format
+  branchformat           v:branch-format
+  nvcsformats            v:
+  stgitformat            v:stg-format
+  max-exports            v:
+  enable                 v:vcs
+  disable                v:vcs
+  disable-patterns       v:
+  check-for-changes      v:bool
+  stagedstr              v:
+  unstagedstr            v:
+  command                v:_command_names
+  use-server             v:bool
+  use-simple             v:bool
+  get-revision           v:bool
+  use-prompt-escapes     v:bool
+
   chpwd			 z:bool
   progress		 z:progress
   remote-glob		 z:bool
@@ -193,14 +223,19 @@ while (( $#state )); do
   case "$state[1]" in
     (contexts)
       if [[ ! -prefix :*: ]]; then
-	_wanted contexts expl context compadd -P : -qS : completion zftp
+	_wanted contexts expl context compadd -P : -qS : completion vcs_info zftp
       elif compset -P :completion:; then
-        for ostate in functions _completers cmdorcont argument tag; do
+        contexts=( functions _completers cmdorcont argument tag )
+      elif compset -P :vcs_info:; then
+        contexts=( vcs-string user-context repo-root-name )
+      fi
+      if (( $#contexts )); then
+        for ostate in $contexts; do
 	  compset -P '[^:]#:' || break
 	done
 	suf=()
 	compset -S ':*' || suf=( -qS: )
-	[[ $ostate = tag ]] && suf=()
+	[[ $ostate = $contexts[-1] ]] && suf=()
 	if compset -P '(|\\)\((*\||)'; then  # handle (x|y) patterns
 	  suf=()
 	  compset -S '(|\\)[)|]*' ||
@@ -222,7 +257,7 @@ while (( $#state )); do
 
     (styles)
       # Get the top-level context we're completing for, if any.
-      case $line[1] in
+      case ${(Q)line[1]} in
 	(:completion:*)
 	ctop=c
 	;;
@@ -235,6 +270,10 @@ while (( $#state )); do
 	ctop=z
 	;;
 
+        (:vcs_info:*)
+        ctop=v
+        ;;
+
 	(:zle:*)
 	ctop=e
 	;;
@@ -248,7 +287,7 @@ while (( $#state )); do
       ;;
 
     (style-arg)
-      state+=( "${styles[$line[2]]#*:}" )
+      state+=( "${styles[${(Q)line[2]}]#*:}" )
       ;;
 
     (argument)
@@ -278,6 +317,18 @@ while (( $#state )); do
       _wanted values expl completer _completers -p
       ;;
 
+    (environ)
+      if [[ "$PREFIX" = *\=* ]]; then
+	compstate[parameter]="${PREFIX%%\=*}"
+	compset -P 1 '*='
+	_value
+      else
+        suf=()
+	compset -S '=*' || suf=(-S '=')
+	_parameters -q $suf
+      fi
+      ;;
+
     (fsort)
       _wanted values expl 'how to sort files' \
 	compadd name size links time date modification access inode change reverse
@@ -455,6 +506,64 @@ while (( $#state )); do
       _wanted word-styles expl 'word style' compadd normal shell space
       ;;
 
+    (vcs-string)
+      _wanted vcs expl vcs compadd $suf - \
+          ${${(f)"$(_call_program vcs vcs_info_printsys 2>/dev/null)"}:#\#*}
+      ;;
+
+    (vcs)
+      _wanted vcs expl vcs compadd \
+          ${${(f)"$(_call_program vcs vcs_info_printsys 2>/dev/null)"}:#(\#|*-)*}
+      ;;
+
+    (user-context)
+      _wanted user-contexts expl 'user context' compadd $suf default command
+      ;;
+
+    (repo-root-name)
+      _message -e names 'repository root name'
+      ;;
+
+    (vcs-format)
+      if [[ $PREFIX = *% ]]; then
+        compset -P '*%'
+        _values -s '' 'format replacement' \
+          's[the vcs in use]' \
+          'b[the current branch]' \
+          'a[an identifier describing the action]' \
+          'i[current revision no/id]' \
+          'c[details of staged changes]' \
+          'u[details of unstaged changes]' \
+          'r[repository name]' \
+          'S[subdirectory within repository]' \
+          'm[misc replacement - backend specific]'
+      else
+        _message -e formats 'vcs format'
+      fi
+      ;;
+
+    (branch-format)
+      if [[ $PREFIX = *% ]]; then
+        compset -P '*%'
+        _values -s '' 'format replacement' \
+          'b[the current branch]' \
+          'r[current revision number]' \
+      else
+        _message -e formats 'vcs format'
+      fi
+      ;;
+
+    (stg-format)
+      if [[ $PREFIX = *% ]]; then
+        compset -P '*%'
+        _values -s '' 'format replacement' \
+          'p[patch currently on top of the stack]' \
+          'c[the number of unapplied patches]'
+      else
+        _message -e formats 'vcs format'
+      fi
+      ;;
+
     (_*)
       ${=state[1]} $suf
       ;;