about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2000-05-09 16:53:34 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2000-05-09 16:53:34 +0000
commitf9938ba951ea09cea250eab05f596c081e6eed8a (patch)
tree6fbdc6857931ee40bbacfde2cbc92e1483731a80 /Completion
parentdff7eff11b037d508e3c4b683c35954a29b416b0 (diff)
downloadzsh-f9938ba951ea09cea250eab05f596c081e6eed8a.tar.gz
zsh-f9938ba951ea09cea250eab05f596c081e6eed8a.tar.xz
zsh-f9938ba951ea09cea250eab05f596c081e6eed8a.zip
complete using _arguments for typeset and its variants (11282)
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Builtins/_vars_eq77
1 files changed, 69 insertions, 8 deletions
diff --git a/Completion/Builtins/_vars_eq b/Completion/Builtins/_vars_eq
index 1e8fa6d2b..4c2f6ae7c 100644
--- a/Completion/Builtins/_vars_eq
+++ b/Completion/Builtins/_vars_eq
@@ -1,9 +1,70 @@
-#compdef declare export integer local readonly typeset
-
-if [[ "$PREFIX" = *\=* ]]; then
-  compstate[parameter]="${PREFIX%%\=*}"
-  compset -P 1 '*='
-  _value
-else
-  _parameters -q -S '='
+#compdef declare export integer float local readonly typeset
+
+local expl state line func i use curcontext="$curcontext"
+local -A allargs
+local -a args
+
+allargs=( \
+  A '(-E -F -L -R -T -U -Z -a -f -i -m)-A[specify that arguments refer to associative arrays]' \
+  E '(-A -F -L -R -T -U -Z -a -f -i -m)-E[represent internally as floating point, use engineering notation on output]' \
+  F '(-A -E -L -R -T -U -Z -a -f -i -m)-F[represent internally as floating point, use fixed point decimal on output]' \
+  L '(-A -E -F -f -i)-L+[left justify and remove leading blanks from value]:width' \
+  R '(-A -E -F -f -i)-R+[right justify and fill with leading blanks]:width' \
+  T '(-A -E -F -a -f -g -h -i -l -m -t)-T[tie scalar to array]' \
+  U '(-A -E -F -i)-U[keep array values unique and suppress alias expansion for functions]' \
+  Uf '(-E -F -i)-U[suppress alias expansion for functions]' \
+  Up '(-E -F -i)-U[keep array values unique]' \
+  Z '(-A -E -F -f -i)-Z+[right justify and fill with leading zeros]:width' \
+  a '(-A -E -F -T -f -i)-a[specify that arguments refer to arrays]' \
+  f '(-A -E -F -L -R -T -Z -a -g -h -i -l -r -x)-f[specify that arguments refer to functions]' \
+  g '(-T -f)-g[do not restrict parameter to local scope]' \
+  h '(-T -f)-h[hide parameter]' \
+  i '(-A -E -F -T -f)-i[represent internally as an integer]' \
+  l '(-T -f)-l[convert the value to lowercase]' \
+  m '(-A -E -F -T -i)-m[treat arguments as patterns]' \
+  r '(-f)-r[mark parameters as readonly]' \
+  t '(-T)-t[tag parameters and turn on execution tracing for functions]' \
+  tf '(-T)-t[turn on execution tracing for functions]' \
+  tp '(-T)-t[tag parameters]' \
+  u '-u[convert the value to uppercase or mark function for autoloading]' \
+  uf '-u[mark function for autoloadling]' \
+  up '-u[convert the value to uppercase]' \
+  x '(-f)-x[export parameter]' )
+
+use="AEFLRTUZafghilmrtux"
+
+case ${words[1]} in
+  float) use="EFghlrtux";;
+  functions)
+    use="Umtu"
+    func=f
+  ;;
+  integer) use="ghlrtux" ;;
+  readonly) use="${use/r/}" ;;
+  local) use="${use/f/}" ;&
+  export) use="${${use/g/}/x/}" ;;
+esac
+
+[[ -z "${words[(r)-*f*]]}" ]] || func=f
+[[ -z "${words[(r)-*[aA]*]}" ]] || func=p
+   
+for ((i=1;i<=$#use;++i)); do
+  args=( "${args[@]}" \
+      ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[Uut]]:+$func}]} )
+done
+
+_arguments -C -s "${args[@]}" '*:vars:->vars_eq'
+
+if [[ "$state" = vars_eq ]]; then
+  if [[ $func = f ]]; then
+    _functions
+  elif [[ "$PREFIX" = *\=* ]]; then
+    compstate[parameter]="${PREFIX%%\=*}"
+    compset -P 1 '*='
+    _value
+  elif (( $+opt_args[-a] || $+opt_args[-A] )); then
+    _parameters -q
+  else
+    _parameters -q -S '='
+  fi
 fi