about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2004-04-20 12:11:13 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2004-04-20 12:11:13 +0000
commitca0deae382e7798eeff829d9b93472cf876574a3 (patch)
treee5d49d22db9e4521ce70fadeaec7dbe4502728b1 /Completion
parent8c890ebe7fb9c9335b2433148dec0588f7fa3f7a (diff)
downloadzsh-ca0deae382e7798eeff829d9b93472cf876574a3.tar.gz
zsh-ca0deae382e7798eeff829d9b93472cf876574a3.tar.xz
zsh-ca0deae382e7798eeff829d9b93472cf876574a3.zip
19767, 19785: store flags for -z and -k options to autoload allowing the
completion system to be used with ksh_autoload set
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Base/Widget/_next_tags12
-rw-r--r--Completion/Zsh/Command/_autoload10
-rw-r--r--Completion/Zsh/Command/_typeset73
-rw-r--r--Completion/Zsh/Type/_functions2
-rw-r--r--Completion/bashcompinit2
-rw-r--r--Completion/compdump8
-rw-r--r--Completion/compinit12
-rw-r--r--Completion/compinstall6
8 files changed, 68 insertions, 57 deletions
diff --git a/Completion/Base/Widget/_next_tags b/Completion/Base/Widget/_next_tags
index e0a70f5b6..8522d7c9a 100644
--- a/Completion/Base/Widget/_next_tags
+++ b/Completion/Base/Widget/_next_tags
@@ -37,7 +37,7 @@ _next_tags() {
       (( $#funcstack > _tags_level )) && _comp_tags="${_comp_tags% * }"
       _tags_level=$#funcstack
       [[ "$_next_tags_not" = *\ ${__spec}\ * ]] && continue
-      _comp_tags="$_comp_tags $__spec "
+      _comp_tags+=" $__spec "
       if [[ "$curtag" = *[^\\]:* ]]; then
         zformat -f __descr "${curtag#*:}" "d:$3"
         _description "$__gopt[@]" "${curtag%:*}" "$2" "$__descr"
@@ -64,7 +64,7 @@ _next_tags() {
       (( $#funcstack > _tags_level )) && _comp_tags="${_comp_tags% * }"
       _tags_level=$#funcstack
       [[ "$_next_tags_not" = *\ ${__spec}\ * ]] && continue
-      _comp_tags="$_comp_tags $__spec "
+      _comp_tags+=" $__spec "
       if [[ "$curtag" = *[^\\]:* ]]; then
         zformat -f __descr "${curtag#*:}" "d:$3"
         _description "$__gopt[@]" "${curtag%:*}" "$2" "$__descr"
@@ -92,7 +92,7 @@ _next_tags() {
     fi
   fi
 
-  _next_tags_not="$_next_tags_not $_lastcomp[tags]"
+  _next_tags_not+=" $_lastcomp[tags]"
   _next_tags_pfx="$PREFIX"
   _next_tags_sfx="$SUFFIX"
 
@@ -107,7 +107,7 @@ _next_tags() {
   compstate[insert]="$ins"
   compstate[list]='list force'
 
-  compprefuncs=( "$compprefuncs[@]" _next_tags_pre )
+  compprefuncs+=( _next_tags_pre )
 }
 
 # Completer, for wrap-around.
@@ -132,9 +132,9 @@ _next_tags_pre() {
     return 0
   elif [[ ${LBUFFER%${PREFIX}} != ${_next_tags_pre}* ]]; then
     unfunction _all_labels _next_label
-    autoload -U _all_labels _next_label
+    autoload -Uz _all_labels _next_label
   else
-    compprefuncs=( "$compprefuncs[@]" _next_tags_pre )
+    compprefuncs+=( _next_tags_pre )
   fi
 }
 
diff --git a/Completion/Zsh/Command/_autoload b/Completion/Zsh/Command/_autoload
deleted file mode 100644
index 50423d51a..000000000
--- a/Completion/Zsh/Command/_autoload
+++ /dev/null
@@ -1,10 +0,0 @@
-#compdef autoload
-
-local expl
-
-if (( $words[(I)[-+]*w*] )); then
-  _description files expl 'zwc file'
-  _files "$expl[@]" -g '*.zwc(-.)'
-else
-  _wanted functions expl 'shell function' compadd - ${^fpath}/*(:t)
-fi
diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset
index 93e773ace..587ce03f9 100644
--- a/Completion/Zsh/Command/_typeset
+++ b/Completion/Zsh/Command/_typeset
@@ -1,27 +1,31 @@
-#compdef declare export integer float local readonly typeset
+#compdef autoload declare export functions integer float local readonly typeset
 
 local expl state line func i use curcontext="$curcontext"
-local -A allargs
+local fopts="-f -k -z"
+local popts="-A -E -F -L -R -T -Z -a -g -h -H -i -l -r -x"
+local -A allargs opt_args
 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[floating point, use engineering notation on output]'
-  F '(-A -E -L -R -T -U -Z -a -f -i -m)-F[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]'
+  A "($fopts -E -F -L -R -T -U -Z -a -i -m)-A[specify that arguments refer to associative arrays]"
+  E "($fopts -A -F -L -R -T -U -Z -a -i -m)-E[floating point, use engineering notation on output]"
+  F "($fopts -A -E -L -R -T -U -Z -a -i -m)-F[floating point, use fixed point decimal on output]"
+  L "($fopts -A -E -F -i)-L+[left justify and remove leading blanks from value]:width"
+  R "($fopts -A -E -F -i)-R+[right justify and fill with leading blanks]:width"
+  T "($fopts -A -E -F -a -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 specialness of parameter]'
-  H '(-T -f)-+H[hide value of parameter in listings]'
-  i '(-A -E -F -T -f)-+i[represent internally as an integer]'
-  l '(-T -f)-l[convert the value to lowercase]'
+  Uf '-U[suppress alias expansion for functions]'
+  Up '(-E -F -i)-+U[keep array values unique]'
+  X '+X[immediately autoload function]'
+  Z "($fopts -A -E -F -i)-Z+[right justify and fill with leading zeros]:width"
+  a "($fopts -A -E -F -T -i)-a[specify that arguments refer to arrays]"
+  f "($popts)-f[specify that arguments refer to functions]"
+  g "($fopts -T)-+g[do not restrict parameter to local scope]"
+  h "($fopts -T)-+h[hide specialness of parameter]"
+  H "($fopts -T)-+H[hide value of parameter in listings]"
+  i "($fopts -A -E -F -T)-+i[represent internally as an integer]"
+  k "($popts -w -z)-+k[mark function for ksh-style autoloading]"
+  l "($popts -T)-l[convert the value to lowercase]"
   m '(-A -E -F -T -i)-m[treat arguments as patterns]'
   p '-p[output parameters in form of calls to typeset]'
   r '(-f)-+r[mark parameters as readonly]'
@@ -31,15 +35,21 @@ allargs=(
   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]'
+  w '(-k -z)-w[specify that arguments refer to files compiled with zcompile]'
+  x "($fopts)-+x[export parameter]"
+  z "($popts -k -w)-+z[mark function for zsh-style autoloading]"
 )
 
-use="AEFHLRTUZafghilmprtux"
+use="AEFHLRTUZafghiklmprtuxz"
 
 case ${service} in
+  autoload)
+    use="UXktwz"
+    func=f
+  ;;
   float) use="EFHghlprtux";;
   functions)
-    use="Umtu"
+    use="Ukmtuz"
     func=f
   ;;
   integer)
@@ -47,28 +57,39 @@ case ${service} in
     allargs[i]='-i[specify arithmetic base for output]' \
   ;;
   readonly) use="${use/r/}" ;;
-  local) use="${use/f/}" ;&
-  export) use="${${use/g/}/x/}" ;;
+  local) use="${use/[fkz]/}" ;&
+  export) use="${${use//[gkz]/}/x/}" ;;
 esac
 
-[[ -z "${words[(r)-*f*]}" ]] || func=f
 [[ -z "${words[(r)-*[aA]*]}" ]] || func=p
+[[ -z "${words[(r)-*f*]}" ]] || func=f
    
 for ((i=1;i<=$#use;++i)); do
   args+=( ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[Uut]]:+$func}]} )
 done
 
-_arguments -C -s -A "-*" -S "${args[@]}" '*:vars:->vars_eq'
+_arguments -C -s -A "-*" -S "${args[@]}" '*::vars:= ->vars_eq'
 
 if [[ "$state" = vars_eq ]]; then
   if [[ $func = f ]]; then
-    _functions
+    if (( $+opt_args[-w] ));then
+      _wanted files expl 'zwc file' _files -g '*.zwc(-.)'
+    elif [[ $service = autoload || -n $opt_args[(i)-[uU]] ]]; then
+      _wanted functions expl 'shell function' compadd - ${^fpath}/*(:t)
+    else
+      _functions
+    fi
   elif [[ "$PREFIX" = *\=* ]]; then
     compstate[parameter]="${PREFIX%%\=*}"
     compset -P 1 '*='
     _value
   elif (( $+opt_args[-a] || $+opt_args[-A] )); then
     _parameters -q
+  elif (( $+opt_args[-T] )); then
+    _arguments \
+      ':scalar parameter:_parameters -g "*scalar*" -q -S "="' \
+      ':array parameter:_parameters -g "*array*"' \
+      ':separator character'
   else
     _parameters -q -S '='
   fi
diff --git a/Completion/Zsh/Type/_functions b/Completion/Zsh/Type/_functions
index 5a4ecfe59..7f818bd66 100644
--- a/Completion/Zsh/Type/_functions
+++ b/Completion/Zsh/Type/_functions
@@ -1,4 +1,4 @@
-#compdef functions unfunction
+#compdef unfunction
 
 local expl
 
diff --git a/Completion/bashcompinit b/Completion/bashcompinit
index 5166b0368..cba436a55 100644
--- a/Completion/bashcompinit
+++ b/Completion/bashcompinit
@@ -168,5 +168,5 @@ complete() {
 }
 
 unfunction bashcompinit
-autoload -U bashcompinit
+autoload -Uz bashcompinit
 return 0
diff --git a/Completion/compdump b/Completion/compdump
index 128cb841c..c762eee51 100644
--- a/Completion/compdump
+++ b/Completion/compdump
@@ -88,7 +88,7 @@ zle -lL |
 	d_complist=yes
       fi
       print -r - ${_d_line}
-      _d_bks=($_d_bks ${_d_line[3]})
+      _d_bks+=(${_d_line[3]})
     fi
   done >> $_d_file
 bindkey |
@@ -108,7 +108,7 @@ _d_als=(${(o)$(typeset +fm '_*')})
 # print them out:  about five to a line looks neat
 
 _i=5
-print -n autoload -U >> $_d_file
+print -n autoload -Uz >> $_d_file
 while (( $#_d_als )); do
   if (( ! $+_compautos[$_d_als[1]] )); then
     print -n " $_d_als[1]"
@@ -123,7 +123,7 @@ done >> $_d_file
 print >> $_d_file
 
 for _i in "${(ok@)_compautos}"; do
-  print "autoload -U $_compautos[$_i] $_i" >> $_d_file
+  print "autoload -Uz $_compautos[$_i] $_i" >> $_d_file
 done
 
 print >> $_d_file
@@ -134,4 +134,4 @@ print "_comp_assocs=( ${(q)_comp_assocs} )" >> $_d_file
 mv $_d_file ${_d_file%.$HOST.$$}
 
 unfunction compdump
-autoload -U compdump
+autoload -Uz compdump
diff --git a/Completion/compinit b/Completion/compinit
index f47739328..332a153ba 100644
--- a/Completion/compinit
+++ b/Completion/compinit
@@ -46,7 +46,7 @@
 #     generate matches, but should automatically be loaded
 #     when they are called. The <options> will be given to the
 #     autoload builtin when making the function autoloaded. Note
-#     that this need not include `-U'.
+#     that this need not include `-U' and `-z'.
 #
 # Note that no white space is allowed between the `#' and the rest of
 # the string.
@@ -292,7 +292,7 @@ compdef() {
     # and probably do autoloading.
 
     func="$1"
-    [[ -n "$autol" ]] && autoload -U "$func"
+    [[ -n "$autol" ]] && autoload -Uz "$func"
     shift
 
     case "$type" in
@@ -406,7 +406,7 @@ typeset _i_wdirs _i_wfiles
 _i_wdirs=()
 _i_wfiles=()
 
-autoload -U compaudit
+autoload -Uz compaudit
 if [[ -n "$_i_check" ]]; then
   typeset _i_q
   if ! eval compaudit; then
@@ -433,7 +433,7 @@ if [[ -n "$_i_check" ]]; then
 fi
 
 # Make sure compdump is available, even if we aren't going to use it.
-autoload -U compdump compinstall
+autoload -Uz compdump compinstall
 
 # If we have a dump file, load it.
 
@@ -473,7 +473,7 @@ if [[ -z "$_i_done" ]]; then
 	fi
 	;;
       (\#autoload)
-	autoload -U "$_i_line[@]" ${_i_name}
+	autoload -Uz "$_i_line[@]" ${_i_name}
 	[[ "$_i_line" != \ # ]] && _compautos[${_i_name}]="$_i_line"
 	;;
       esac
@@ -505,6 +505,6 @@ if [[ ${_i_line[2]} = expand-or-complete ]] &&
 fi
 
 unfunction compinit compaudit
-autoload -U compinit compaudit
+autoload -Uz compinit compaudit
 
 return 0
diff --git a/Completion/compinstall b/Completion/compinstall
index c53d12e34..f3e01043e 100644
--- a/Completion/compinstall
+++ b/Completion/compinstall
@@ -7,7 +7,7 @@ local compcontext=-default-
 __ci_tidyup() {
   unfunction -m __ci_\* 2>/dev/null
   unfunction compinstall
-  autoload -U compinstall
+  autoload -Uz compinstall
 }
 
 __ci_newline() {
@@ -119,7 +119,7 @@ ${match[3]}"
     then
       compinit_args=$match[1]
     elif [[ $line != [[:blank:]]# &&
-      $line != [[:blank:]]#'autoload -U compinit' &&
+      $line != [[:blank:]]#'autoload -Uz compinit' &&
       $line != [[:blank:]]#compinit &&
       $line != [[:blank:]]#zstyle[[:blank:]]#:compinstall* ]]; then
       warn_unknown="${warn_unknown:+$warn_unknown
@@ -1886,7 +1886,7 @@ $output"
   [[ -n $fpath_line ]] && print -r "$fpath_line"
 
   print -r "
-autoload -U compinit
+autoload -Uz compinit
 compinit${compinit_args:+ $compinit_args}"
 
   print -r "$endline"