summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog36
-rw-r--r--Completion/Base/_combination63
-rw-r--r--Completion/Base/_command_names32
-rw-r--r--Completion/Base/_describe4
-rw-r--r--Completion/Base/_equal10
-rw-r--r--Completion/Base/_subscript6
-rw-r--r--Completion/Base/_tilde6
-rw-r--r--Completion/Base/_value2
-rw-r--r--Completion/Builtins/_aliases8
-rw-r--r--Completion/Builtins/_bindkey4
-rw-r--r--Completion/Builtins/_builtin12
-rw-r--r--Completion/Builtins/_cd2
-rw-r--r--Completion/Builtins/_command11
-rw-r--r--Completion/Builtins/_compdef6
-rw-r--r--Completion/Builtins/_functions6
-rw-r--r--Completion/Builtins/_hash4
-rw-r--r--Completion/Builtins/_popd2
-rw-r--r--Completion/Builtins/_unhash4
-rw-r--r--Completion/Builtins/_vars2
-rw-r--r--Completion/Builtins/_which10
-rw-r--r--Completion/Builtins/_zcompile2
-rw-r--r--Completion/Builtins/_zle11
-rw-r--r--Completion/Builtins/_zmodload14
-rw-r--r--Completion/Builtins/_zpty4
-rw-r--r--Completion/Builtins/_zstyle4
-rw-r--r--Completion/Commands/_bash_completions5
-rw-r--r--Completion/Commands/_history_complete_word5
-rw-r--r--Completion/Core/_all_labels42
-rw-r--r--Completion/Core/_expand6
-rw-r--r--Completion/Core/_file_descriptors4
-rw-r--r--Completion/Core/_history6
-rw-r--r--Completion/Core/_multi_parts4
-rw-r--r--Completion/Core/_next_label14
-rw-r--r--Completion/Core/_options5
-rw-r--r--Completion/Core/_path_files8
-rw-r--r--Completion/Core/_requested8
-rw-r--r--Completion/Core/_sep_parts14
-rw-r--r--Completion/Core/_set_options5
-rw-r--r--Completion/Core/_unset_options5
-rw-r--r--Completion/Core/_wanted14
-rw-r--r--Completion/User/_archie2
-rw-r--r--Completion/User/_cvs10
-rw-r--r--Completion/User/_domains8
-rw-r--r--Completion/User/_gprof2
-rw-r--r--Completion/User/_groups2
-rw-r--r--Completion/User/_hosts14
-rw-r--r--Completion/User/_lp4
-rw-r--r--Completion/User/_mailboxes174
-rw-r--r--Completion/User/_make2
-rw-r--r--Completion/User/_mount6
-rw-r--r--Completion/User/_mysql_utils6
-rw-r--r--Completion/User/_netscape4
-rw-r--r--Completion/User/_perl2
-rw-r--r--Completion/User/_perl_basepods2
-rw-r--r--Completion/User/_perl_builtin_funcs8
-rw-r--r--Completion/User/_perl_modules2
-rw-r--r--Completion/User/_ports12
-rw-r--r--Completion/User/_rcs2
-rw-r--r--Completion/User/_urls2
-rw-r--r--Completion/User/_users4
-rw-r--r--Completion/User/_yp6
-rw-r--r--Completion/X/_x_color4
-rw-r--r--Completion/X/_x_cursor4
-rw-r--r--Completion/X/_x_extension2
-rw-r--r--Completion/X/_x_font2
-rw-r--r--Completion/X/_x_keysym2
-rw-r--r--Completion/X/_xutils2
67 files changed, 473 insertions, 227 deletions
diff --git a/ChangeLog b/ChangeLog
index f7c0c1e17..7163043bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,41 @@
2000-05-31 Sven Wischnowsky <wischnow@zsh.org>
+ * 11549: Completion/Base/_combination, Completion/Base/_command_names,
+ Completion/Base/_describe, Completion/Base/_equal,
+ Completion/Base/_subscript, Completion/Base/_tilde,
+ Completion/Base/_value, Completion/Builtins/_aliases,
+ Completion/Builtins/_bindkey, Completion/Builtins/_builtin,
+ Completion/Builtins/_cd, Completion/Builtins/_command,
+ Completion/Builtins/_compdef, Completion/Builtins/_functions,
+ Completion/Builtins/_hash, Completion/Builtins/_popd,
+ Completion/Builtins/_unhash, Completion/Builtins/_vars,
+ Completion/Builtins/_which, Completion/Builtins/_zcompile,
+ Completion/Builtins/_zle, Completion/Builtins/_zmodload,
+ Completion/Builtins/_zpty, Completion/Builtins/_zstyle,
+ Completion/Commands/_bash_completions,
+ Completion/Commands/_history_complete_word,
+ Completion/Core/_all_labels, Completion/Core/_expand,
+ Completion/Core/_file_descriptors, Completion/Core/_history,
+ Completion/Core/_multi_parts, Completion/Core/_next_label,
+ Completion/Core/_options, Completion/Core/_path_files,
+ Completion/Core/_requested, Completion/Core/_sep_parts,
+ Completion/Core/_set_options, Completion/Core/_unset_options,
+ Completion/Core/_wanted, Completion/User/_archie,
+ Completion/User/_cvs, Completion/User/_domains,
+ Completion/User/_gprof, Completion/User/_groups,
+ Completion/User/_hosts, Completion/User/_lp,
+ Completion/User/_mailboxes, Completion/User/_make,
+ Completion/User/_mount, Completion/User/_mysql_utils,
+ Completion/User/_netscape, Completion/User/_perl,
+ Completion/User/_perl_basepods,
+ Completion/User/_perl_builtin_funcs,
+ Completion/User/_perl_modules, Completion/User/_ports,
+ Completion/User/_rcs, Completion/User/_urls,
+ Completion/User/_users, Completion/User/_yp,
+ Completion/X/_x_color, Completion/X/_x_cursor,
+ Completion/X/_x_extension, Completion/X/_x_font,
+ Completion/X/_x_keysym, Completion/X/_xutils: use compadd -[ak]
+
* Andrej: 11660: Completion/User/_man: fix for ${..//..} with % in
search string
diff --git a/Completion/Base/_combination b/Completion/Base/_combination
index 631547311..dcb3269cd 100644
--- a/Completion/Base/_combination
+++ b/Completion/Base/_combination
@@ -1,25 +1,27 @@
#autoload
# Usage:
-# _combination [-s S] V[:K1:...] Ki1[:Ni1]=Pi1 Ki2[:Ni2]=Pi2 ... Kim[:Nim]=Pim Kj[:Nj] EXPL...
+# _combination [-s S] TAG STYLE \
+# Ki1[:Ni1]=Pi1 Ki2[:Ni2]=Pi2 ... Kim[:Nim]=Pim Kj[:Nj] EXPL...
#
-# It is assumed that V is formed as PRE_K1_..._Kn if `:K1:...' is not specified.
+# STYLE should be of the form K1-K2-...-Kn.
#
# Example: telnet
#
-# Assume an user sets the variable `telnet_hosts_ports_users' as:
+# Assume an user sets the style `users-hosts-ports' as for the my-accounts
+# tag:
#
-# telnet_hosts_ports_users=(
-# host0:: host1::user1 host2::user2
-# mail-server:{smtp,pop3}:
-# news-server:nntp:
-# proxy-server:8000:
-# )
+# zstyle ':completion:*:*:telnet:*:my-accounts' users-hosts-ports \
+# @host0: user1@host1: user2@host2:
+# @mail-server:{smtp,pop3}
+# @news-server:nntp
+# @proxy-server:8000
+#
#
-# `_telnet completes' hosts as:
+# `_telnet' completes hosts as:
#
-# _combination telnet_hosts_ports_users \
-# ${options[-l]:+users=${options[-l]:q}} \
+# _combination my-accounts users-hosts-ports \
+# ${opt_args[-l]:+users=${opt_args[-l]:q}} \
# hosts "$expl[@]"
#
# This completes `host1', `host2', `mail-server', `news-server' and
@@ -28,8 +30,8 @@
#
# `_telnet' completes ports as:
#
-# _combination telnet_hosts_ports_users \
-# ${options[-l]:+users=${options[-l]:q}} \
+# _combination my-accounts users-hosts-ports \
+# ${opt_args[-l]:+users=${opt_args[-l]:q}} \
# hosts="${line[2]:q}" \
# ports "$expl[@]"
#
@@ -39,7 +41,7 @@
#
# `_telnet' completes users for an argument of option `-l' as:
#
-# _combination telnet_hosts_ports_users \
+# _combination my-accounts users-hosts-ports \
# ${line[2]:+hosts="${line[2]:q}"} \
# ${line[3]:+ports="${line[3]:q}"} \
# users "$expl[@]"
@@ -48,25 +50,23 @@
# the port argument if they are exist. And if it is failed, `_users' is
# called.
-local sep var keys pats key num tmp
+local sep tag style keys pats key num tmp
if [[ "$1" = -s ]]; then
sep="$2"
shift 2
+elif [[ "$1" = -s* ]]; then
+ sep="${1[3,-1]}"
+ shift
else
sep=:
fi
-var=$1
-shift
+tag="$1"
+style="$2"
+shift 2
-if [[ $var = *:* ]]; then
- keys=( ${(s/:/)var} )
- shift keys
- var="${var%%:*}"
-else
- keys=( "${(@s:_:)${var#*_}}" )
-fi
+keys=( ${(s/-/)style} )
pats=( "${(@)keys/*/*}" )
while [[ "$1" = *=* ]]; do
@@ -81,15 +81,14 @@ key="${1%:*}"
num="${${1##*:}:-1}"
shift
-if (( ${(P)+${var}} )); then
- eval "tmp=( \"\${(@M)${var}:#\${(j($sep))~pats}}\" )"
+if zstyle -a ":completion:${curcontext}:$tag" "$style" tmp; then
+ eval "tmp=( \"\${(@M)tmp:#\${(j($sep))~pats}}\" )"
if (( keys[(in:num:)$key] != 1 )); then
- eval "tmp=( \${tmp#\${(j(${sep}))~\${(@)\${(@)keys[2,(rn:num:)\$key]}/*/*}}$sep} )"
+ eval "tmp=( \${tmp#\${(j(${sep}))~\${(@)\${(@)keys[2,(rn:num:)\$key]}/*/*}}${~sep}} )"
fi
- tmp=( ${tmp%%$sep*} )
+ tmp=( ${tmp%%${~sep}*} )
- compadd "$@" - $tmp || { builtin functions _$key >&- && _$key "$@" }
+ compadd "$@" -a tmp || { (( $+functions[_$key] )) && "_$key" "$@" }
else
- builtin functions _$key >&- && _$key "$@"
+ (( $+functions[_$key] )) && "_$key" "$@"
fi
-
diff --git a/Completion/Base/_command_names b/Completion/Base/_command_names
index d3b8a109a..844f190a6 100644
--- a/Completion/Base/_command_names
+++ b/Completion/Base/_command_names
@@ -1,3 +1,31 @@
-#defcomp -command-
+#compdef -command-
-complist -c
+# The option `-e' if given as the first argument says that we should
+# complete only external commands and executable files. This and a
+# `-' as the first argument is then removed from the arguments.
+
+local args defs
+
+defs=(
+ 'commands:external command:compadd -k commands'
+ 'executables:executable file or directory:_path_files -/g \*\(-\*\)'
+)
+
+if [[ "$1" = -e ]]; then
+ shift
+else
+ [[ "$1" = - ]] && shift
+
+ defs=( "$defs[@]"
+ 'builtins:builtin command:compadd -k builtins'
+ 'functions:shell function:compadd -k functions'
+ 'aliases:alias:compadd -k aliases'
+ 'reserved-words:reserved word:compadd -k reswords'
+ 'jobs:: _jobs -t'
+ 'parameters:: _parameters -qS= -r "\n\t\- =["'
+ )
+fi
+
+args=( "$@" )
+
+_alternative -O args "$defs[@]"
diff --git a/Completion/Base/_describe b/Completion/Base/_describe
index 5aeeadf10..a658d16df 100644
--- a/Completion/Base/_describe
+++ b/Completion/Base/_describe
@@ -52,8 +52,8 @@ while _tags; do
fi
fi
- compadd "$_args[@]" "$_expl[@]" -ld _tmpd - "$_tmpmd[@]" && _ret=0
- compadd "$_args[@]" "$_expl[@]" -d _tmps - "$_tmpms[@]" && _ret=0
+ compadd "$_args[@]" "$_expl[@]" -ld _tmpd -a _tmpmd && _ret=0
+ compadd "$_args[@]" "$_expl[@]" -d _tmps -a _tmpms && _ret=0
done
done
(( _ret )) || return 0
diff --git a/Completion/Base/_equal b/Completion/Base/_equal
index f407014fe..4150fe629 100644
--- a/Completion/Base/_equal
+++ b/Completion/Base/_equal
@@ -1,3 +1,9 @@
-#defcomp -equal-
+#compdef -equal-
-compgen -am
+local args
+
+args=( "$@" )
+
+_alternative -O args \
+ 'commands:command:compadd -k commands' \
+ 'aliases:alias:compadd -k aliases'
diff --git a/Completion/Base/_subscript b/Completion/Base/_subscript
index 60d45370b..e3bde552a 100644
--- a/Completion/Base/_subscript
+++ b/Completion/Base/_subscript
@@ -12,7 +12,7 @@ elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
[[ "$RBUFFER" != \]* ]] && suf=']'
_wanted association-keys expl 'association key' \
- compadd -S "$suf" - "${(@kP)${compstate[parameter]}}"
+ compadd -S "$suf" -k "$compstate[parameter]"
elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then
local list i j ret=1 disp
@@ -39,10 +39,10 @@ elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then
if [[ "$RBUFFER" = \]* ]]; then
_all_labels -V indexes expl 'array index' \
- compadd -S '' "$disp[@]" - "$ind[@]" && ret=0
+ compadd -S '' "$disp[@]" -a ind && ret=0
else
_all_labels -V indexes expl 'array index' \
- compadd -S ']' "$disp[@]" - "$ind[@]" && ret=0
+ compadd -S ']' "$disp[@]" -a ind && ret=0
fi
fi
_requested parameters && _parameters && ret=0
diff --git a/Completion/Base/_tilde b/Completion/Base/_tilde
index 59ac8d0f6..43c9b3ea4 100644
--- a/Completion/Base/_tilde
+++ b/Completion/Base/_tilde
@@ -2,7 +2,7 @@
# We use all named directories and user names here. If this is too slow
# for you or if there are too many of them, you may want to use
-# `compadd -qS/ - "$friends[@]"' or something like that.
+# `compadd -qS/ -a friends' or something like that.
[[ -n "$compstate[quote]" ]] && return 1
@@ -22,7 +22,7 @@ while _tags; do
_requested users && _users "$suf[@]" "$@" && ret=0
_requested named-directories expl 'named directory' \
- compadd "$suf[@]" "$@" - "${(@k)nameddirs}"
+ compadd "$suf[@]" "$@" -k nameddirs
if _requested directory-stack &&
{ ! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed ||
@@ -50,7 +50,7 @@ while _tags; do
disp=()
fi
_all_labels -V directory-stack expl 'directory stack' \
- compadd "$suf[@]" "$disp[@]" -Q - "$list[@]" && ret=0
+ compadd "$suf[@]" "$disp[@]" -Q -a list && ret=0
fi
(( ret )) || return 0
done
diff --git a/Completion/Base/_value b/Completion/Base/_value
index 9df71fdd4..402bab236 100644
--- a/Completion/Base/_value
+++ b/Completion/Base/_value
@@ -10,7 +10,7 @@ _value () {
"${(Pt)${compstate[parameter]}}" = assoc* ]]; then
if (( CURRENT & 1 )); then
_wanted association-keys expl 'association key' \
- compadd - "${(@kP)${compstate[parameter]}}"
+ compadd -k "$compstate[parameter]"
else
compstate[parameter]="${compstate[parameter]}-${words[CURRENT-1]}"
_value "$@"
diff --git a/Completion/Builtins/_aliases b/Completion/Builtins/_aliases
index 1038a726e..07e5dc5cb 100644
--- a/Completion/Builtins/_aliases
+++ b/Completion/Builtins/_aliases
@@ -1,3 +1,7 @@
-#defcomp unalias
+#compdef alias unalias
-complist -a
+local expl
+
+_alternative \
+ 'aliases:regular alias:compadd -k aliases' \
+ 'global-aliases:global alias:compadd -k galiases'
diff --git a/Completion/Builtins/_bindkey b/Completion/Builtins/_bindkey
index cca4f7e64..048d517f2 100644
--- a/Completion/Builtins/_bindkey
+++ b/Completion/Builtins/_bindkey
@@ -29,9 +29,9 @@ _arguments -C -s \
case $state in
keymap)
- _wanted -C -M keymaps expl keymap compadd - "$keymaps[@]"
+ _wanted -C -M keymaps expl keymap compadd -a keymaps
;;
widget)
- _wanted widgets expl widget compadd -M 'r:|-=* r:|=*' - "${(@k)widgets}"
+ _wanted widgets expl widget compadd -M 'r:|-=* r:|=*' -k widgets
;;
esac
diff --git a/Completion/Builtins/_builtin b/Completion/Builtins/_builtin
index a967932ee..9fb6acf7b 100644
--- a/Completion/Builtins/_builtin
+++ b/Completion/Builtins/_builtin
@@ -1,7 +1,11 @@
-#defcomp builtin
+#compdef builtin
-if [[ -position 2 -1 ]]; then
- _normal "$@"
+if (( $CURRENT > 2 )); then
+ shift words
+ (( CURRENT -- ))
+ _normal
else
- complist -eB
+ local expl
+
+ _wanted commands expl 'builtin command' compadd "$@" -k builtins
fi
diff --git a/Completion/Builtins/_cd b/Completion/Builtins/_cd
index 803bcbda5..634a62c66 100644
--- a/Completion/Builtins/_cd
+++ b/Completion/Builtins/_cd
@@ -22,7 +22,7 @@ if [[ CURRENT -eq 3 ]]; then
rep=(${~PWD/$words[2]/*}~$PWD(-/N))
# Now remove all the common parts of $PWD and the completions from this
rep=(${${rep#${PWD%%$words[2]*}}%${PWD#*$words[2]}})
- (( $#rep )) && _wanted -C replacement strings expl replacement compadd $rep
+ (( $#rep )) && _wanted -C replacement strings expl replacement compadd -a rep
elif _popd || [[ $PREFIX != (\~|/|./|../)* && $#cdpath -ne 0 ]]; then
local tdir tdir2
diff --git a/Completion/Builtins/_command b/Completion/Builtins/_command
index b2812de25..b90ec933e 100644
--- a/Completion/Builtins/_command
+++ b/Completion/Builtins/_command
@@ -1,7 +1,10 @@
-#defcomp command
+#compdef command
-if [[ -position 2 -1 ]]; then
- _normal "$@"
+if [[ CURRENT -ge 3 ]]; then
+ compset -n 2
+ _normal
else
- complist -em
+ local expl
+
+ _wanted commands expl 'external command' compadd "$@" -k commands
fi
diff --git a/Completion/Builtins/_compdef b/Completion/Builtins/_compdef
index 23c6d3a3d..636004af2 100644
--- a/Completion/Builtins/_compdef
+++ b/Completion/Builtins/_compdef
@@ -30,16 +30,16 @@ fi
case $state in
ccom)
- _wanted commands expl 'completed command' compadd - ${(k)_comps}
+ _wanted commands expl 'completed command' compadd -k _comps
;;
cfun)
list=( ${^fpath:/.}/_(|*[^~])(N:t) )
if zstyle -T ":completion:${curcontext}:functions" prefix-hidden; then
disp=( ${list[@]#_} )
_wanted functions expl 'completion function' \
- compadd -d disp - "$list[@]"
+ compadd -d disp -a list
else
- _wanted functions expl 'completion function' compadd - "$list[@]"
+ _wanted functions expl 'completion function' compadd -a list
fi
;;
style)
diff --git a/Completion/Builtins/_functions b/Completion/Builtins/_functions
index 8a352ea08..5a4ecfe59 100644
--- a/Completion/Builtins/_functions
+++ b/Completion/Builtins/_functions
@@ -1,3 +1,5 @@
-#defcomp unfunction
+#compdef functions unfunction
-complist -F
+local expl
+
+_wanted functions expl 'shell function' compadd "$@" -k functions
diff --git a/Completion/Builtins/_hash b/Completion/Builtins/_hash
index de8c1887c..250e119b9 100644
--- a/Completion/Builtins/_hash
+++ b/Completion/Builtins/_hash
@@ -28,11 +28,11 @@ if [[ $state = hashval ]]; then
_wanted -C value files expl directories _path_files -/
else
_wanted -C name named-directories expl 'named directory' \
- compadd -q -S '=' - "${(@k)nameddirs}"
+ compadd -q -S '=' -k nameddirs
fi
elif compset -P 1 '*='; then
_wanted -C value values expl 'executable file' _files -g '*(-*)'
else
- _wanted -C name commands expl command compadd -q -S '=' - "${(@k)commands}"
+ _wanted -C name commands expl command compadd -q -S '=' -k commands
fi
fi
diff --git a/Completion/Builtins/_popd b/Completion/Builtins/_popd
index 19b773173..ff9ede12e 100644
--- a/Completion/Builtins/_popd
+++ b/Completion/Builtins/_popd
@@ -38,4 +38,4 @@ else
fi
_wanted -V directory-stack expl 'directory stack' \
- compadd "$@" "$disp[@]" -Q - "$list[@]"
+ compadd "$@" "$disp[@]" -Q -a list
diff --git a/Completion/Builtins/_unhash b/Completion/Builtins/_unhash
index b99c00ad3..a8f366180 100644
--- a/Completion/Builtins/_unhash
+++ b/Completion/Builtins/_unhash
@@ -7,8 +7,8 @@ _arguments -C -s \
'(-d -f *)-a[remove aliases]:*:aliases:_aliases' \
'(-d -a *)-f[remove functions]:*:functions:_functions' \
'-m[treat arguments as patterns]' \
- '*:commands:_command_names -e' && return 0
+ '*:commands: _command_names -e' && return 0
if [[ "$state" = nameddir ]]; then
- _wanted nameddir expl 'named directory' compadd - ${(@k)nameddirs}
+ _wanted nameddir expl 'named directory' compadd -k nameddirs
fi
diff --git a/Completion/Builtins/_vars b/Completion/Builtins/_vars
index 711a0a1f2..6444c68fe 100644
--- a/Completion/Builtins/_vars
+++ b/Completion/Builtins/_vars
@@ -17,7 +17,7 @@ if [[ $PREFIX = *\[* ]]; then
local expl
_wanted -C subscript association-keys expl 'association key' \
- compadd $addclose - ${(kP)var}
+ compadd $addclose -k "$var"
fi
else
_parameters
diff --git a/Completion/Builtins/_which b/Completion/Builtins/_which
index 3dc785f0f..aceec85a0 100644
--- a/Completion/Builtins/_which
+++ b/Completion/Builtins/_which
@@ -28,10 +28,10 @@ if [[ "$state" = command ]]; then
args=( "$@" )
_alternative -O args \
- 'commands:external command:compadd - ${(k@)commands}' \
- 'builtins:builtin command:compadd - ${(k@)builtins}' \
- 'functions:shell function:compadd - ${(k@)functions}' \
- 'aliases:alias:compadd - ${(k@)aliases}' \
- 'reserved-words:reserved word:compadd - ${(k@)reswords}'
+ 'commands:external command:compadd -k commands' \
+ 'builtins:builtin command:compadd -k builtins' \
+ 'functions:shell function:compadd -k functions' \
+ 'aliases:alias:compadd -k aliases' \
+ 'reserved-words:reserved word:compadd -k reswords'
fi
diff --git a/Completion/Builtins/_zcompile b/Completion/Builtins/_zcompile
index b4428e019..e9b9c60eb 100644
--- a/Completion/Builtins/_zcompile
+++ b/Completion/Builtins/_zcompile
@@ -17,7 +17,7 @@ _arguments -C -s \
'*:function:->function' && return 0
if (( $+opt_args[-c] )); then
- _wanted functions expl 'function to write' compadd - ${(k)functions}
+ _wanted functions expl 'function to write' compadd -k functions
else
_description files expl 'zsh source file'
_files "$expl[@]"
diff --git a/Completion/Builtins/_zle b/Completion/Builtins/_zle
index bb1102e74..e390382d4 100644
--- a/Completion/Builtins/_zle
+++ b/Completion/Builtins/_zle
@@ -1,7 +1,10 @@
-#defcomp zle
+#compdef zle
-if [[ -word 1 -N && -position 3 ]]; then
- complist -F
+local expl
+
+if [[ "$words[2]" = -N && CURRENT -eq 3 ]]; then
+ _wanted -C -N functions expl 'widget shell function' \
+ compadd "$@" -k functions
else
- complist -b
+ _wanted widgets expl widget compadd -k widgets
fi
diff --git a/Completion/Builtins/_zmodload b/Completion/Builtins/_zmodload
index 112acb57c..5ca167152 100644
--- a/Completion/Builtins/_zmodload
+++ b/Completion/Builtins/_zmodload
@@ -1,9 +1,11 @@
-#defcomp zmodload
+#compdef zmodload
-if [[ -mword 1 -*(a*u|u*a)* || -mword 1 -*a* && -position 3 -1 ]]; then
- complist -B
-elif [[ -mword 1 -*u* ]]; then
- complist -s '$(zmodload)'
+local fl="$words[2]" expl
+
+if [[ "$fl" = -*(a*u|u*a)* || "$fl" = -*a* && CURRENT -ge 4 ]]; then
+ _wanted builtins expl 'builtin command' compadd "$@" -k builtins
+elif [[ "$fl" = -*u* ]]; then
+ _wanted modules expl module compadd -k modules
else
- complist -s '${^module_path}/*(N:t:r)'
+ _wanted files expl 'module file' _files -W module_path -/g '*.s[ol](:r)'
fi
diff --git a/Completion/Builtins/_zpty b/Completion/Builtins/_zpty
index dd551ab97..f1de3d11d 100644
--- a/Completion/Builtins/_zpty
+++ b/Completion/Builtins/_zpty
@@ -49,9 +49,9 @@ if [[ $state = name ]]; then
names=( ${list%%:*} )
if zstyle -T ":completion:${curcontext}" verbose; then
zformat -a list ' --' ${${(f)"$(zpty)"}#*\) }
- _wanted names expl 'zpty command name' compadd -d list - "$names[@]"
+ _wanted names expl 'zpty command name' compadd -d list -a names
else
- _wanted names expl 'zpty command name' compadd - "$names[@]"
+ _wanted names expl 'zpty command name' compadd -a names
fi
else
return 1
diff --git a/Completion/Builtins/_zstyle b/Completion/Builtins/_zstyle
index 5ce45c795..db86829ec 100644
--- a/Completion/Builtins/_zstyle
+++ b/Completion/Builtins/_zstyle
@@ -151,7 +151,7 @@ while [[ -n $state ]]; do
completer)
_wanted values expl completer \
compadd _complete _approximate _correct _match \
- _expand _list _menu _oldlist _next_tags
+ _expand _list _menu _oldlist _ignored _prefix _history
;;
fsort)
@@ -212,7 +212,7 @@ while [[ -n $state ]]; do
elif compset -P '*:'; then
_message 'tag alias'
else
- _wanted tags expl tag compadd - $taglist
+ _wanted tags expl tag compadd -a taglist
fi
;;
diff --git a/Completion/Commands/_bash_completions b/Completion/Commands/_bash_completions
index 548888138..50600290d 100644
--- a/Completion/Commands/_bash_completions
+++ b/Completion/Commands/_bash_completions
@@ -28,12 +28,13 @@
setopt localoptions nullglob rcexpandparam extendedglob
unsetopt markdirs globsubst shwordsplit nounset ksharrays
-local key=$KEYS[-1]
+local key=$KEYS[-1] expl
case $key in
'!') _main_complete _command_names
;;
- '$') compadd - "${(@k)parameters[(R)*export*]}"
+ '$') _main_complete - _wanted parameters expl 'exported parameters' \
+ compadd - "${(@k)parameters[(R)*export*]}"
;;
'@') _main_complete _hosts
;;
diff --git a/Completion/Commands/_history_complete_word b/Completion/Commands/_history_complete_word
index bb7e44200..00d7ba369 100644
--- a/Completion/Commands/_history_complete_word
+++ b/Completion/Commands/_history_complete_word
@@ -70,7 +70,7 @@ _history_complete_word () {
}
_history_complete_word_gen_matches () {
- local opt
+ local opt h_words
[[ -n "$_hist_stop" ]] && PREFIX="$_hist_old_prefix"
@@ -85,8 +85,9 @@ _history_complete_word_gen_matches () {
opt="${opt}V"
fi
+ h_words=( "${(@)historywords[2,-1]}" )
_wanted "$opt" history-words expl 'history word' \
- compadd -Q - "$historywords[@]"
+ compadd -Q -a h_words
zstyle -t ":completion:${curcontext}:history-words" list ||
compstate[list]=
diff --git a/Completion/Core/_all_labels b/Completion/Core/_all_labels
index f85478cb5..cdb89e7fa 100644
--- a/Completion/Core/_all_labels
+++ b/Completion/Core/_all_labels
@@ -1,43 +1,43 @@
#autoload
-local gopt=-J len tmp pre suf ret=1 descr spec prev
+local __gopt=-J __len __tmp __pre __suf __ret=1 __descr __spec __prev
if [[ "$1" = - ]]; then
- prev=-
+ __prev=-
shift
fi
if [[ "$1" = -([12]|)[VJ] ]]; then
- gopt="$1"
+ __gopt="$1"
shift
fi
-tmp=${argv[(ib:4:)-]}
-len=$#
-if [[ tmp -lt len ]]; then
- pre=$(( tmp-1 ))
- suf=$tmp
-elif [[ tmp -eq $# ]]; then
- pre=-2
- suf=$(( len+1 ))
+__tmp=${argv[(ib:4:)-]}
+__len=$#
+if [[ __tmp -lt __len ]]; then
+ __pre=$(( __tmp-1 ))
+ __suf=$__tmp
+elif [[ __tmp -eq $# ]]; then
+ __pre=-2
+ __suf=$(( __len+1 ))
else
- pre=4
- suf=5
+ __pre=4
+ __suf=5
fi
-while comptags "-A$prev" "$1" curtag spec; do
- _comp_tags="$_comp_tags $spec "
+while comptags "-A$__prev" "$1" curtag __spec; do
+ _comp_tags="$_comp_tags $__spec "
if [[ "$curtag" = *:* ]]; then
- zformat -f descr "${curtag#*:}" "d:$3"
- _description "$gopt" "${curtag%:*}" "$2" "$descr"
+ zformat -f __descr "${curtag#*:}" "d:$3"
+ _description "$__gopt" "${curtag%:*}" "$2" "$__descr"
curtag="${curtag%:*}"
- "$4" "${(P@)2}" "${(@)argv[5,-1]}" && ret=0
+ "$4" "${(P@)2}" "${(@)argv[5,-1]}" && __ret=0
else
- _description "$gopt" "$curtag" "$2" "$3"
+ _description "$__gopt" "$curtag" "$2" "$3"
- "${(@)argv[4,pre]}" "${(P@)2}" "${(@)argv[suf,-1]}" && ret=0
+ "${(@)argv[4,__pre]}" "${(P@)2}" "${(@)argv[__suf,-1]}" && __ret=0
fi
done
-return ret
+return __ret
diff --git a/Completion/Core/_expand b/Completion/Core/_expand
index 869c9c843..fb146e0de 100644
--- a/Completion/Core/_expand
+++ b/Completion/Core/_expand
@@ -104,7 +104,7 @@ if [[ -z "$compstate[insert]" ]] ;then
_description -V expansions expl expansions "o:$word"
fi
- compadd "$expl[@]" -UQ -qS "$suf" - "$exp[@]"
+ compadd "$expl[@]" -UQ -qS "$suf" -a exp
else
_tags all-expansions expansions original
@@ -142,8 +142,8 @@ else
normal=( "$normal[@]" "$i" )
fi
done
- (( $#dir )) && compadd "$expl[@]" -UQ -qS/ - "$dir[@]"
- (( $#normal )) && compadd "$expl[@]" -UQ -qS "$suf" - "$normal[@]"
+ (( $#dir )) && compadd "$expl[@]" -UQ -qS/ -a dir
+ (( $#normal )) && compadd "$expl[@]" -UQ -qS "$suf" -a normal
fi
_requested original expl original && compadd "$expl[@]" -UQ - "$word"
diff --git a/Completion/Core/_file_descriptors b/Completion/Core/_file_descriptors
index 37e44c068..56f6905c6 100644
--- a/Completion/Core/_file_descriptors
+++ b/Completion/Core/_file_descriptors
@@ -17,7 +17,7 @@ if zstyle -T ":completion:${curcontext}" verbose && [[ -e /proc/$$/fd ]]; then
list=( ${list[@]} "$i -- $(ls -l /proc/$$/fd/$i|sed 's/.*-> //' )" )
done
fi
- _wanted file-descriptors expl 'file descriptors' compadd "$@" -d list - "$fds[@]"
+ _wanted file-descriptors expl 'file descriptors' compadd "$@" -d list -a fds
else
- _wanted file-descriptors expl 'file descriptors' compadd "$@" - "$fds[@]"
+ _wanted file-descriptors expl 'file descriptors' compadd "$@" -a fds
fi
diff --git a/Completion/Core/_history b/Completion/Core/_history
index 978a75400..86fd9efc5 100644
--- a/Completion/Core/_history
+++ b/Completion/Core/_history
@@ -16,7 +16,7 @@
# remove /all/ duplicate matches rather than just
# consecutives
-local opt expl
+local opt expl h_words
if zstyle -t ":completion:${curcontext}:" remove-all-dups; then
opt=-
@@ -32,5 +32,5 @@ fi
# We skip the first element of historywords so the current word doesn't
# interfere with the completion
-_wanted "$opt" history-words expl 'history word' \
- compadd -Q - "${(@)historywords[2,-1]}"
+h_words=( "${(@)historywords[2,-1]}" )
+_wanted "$opt" history-words expl 'history word' compadd -Q -a h_words
diff --git a/Completion/Core/_multi_parts b/Completion/Core/_multi_parts
index bdfa26fc3..9f70534fc 100644
--- a/Completion/Core/_multi_parts
+++ b/Completion/Core/_multi_parts
@@ -59,7 +59,7 @@ pref=''
# If the string from the line matches at least one of the strings,
# we use only the matching strings.
-compadd -O tmp1 -M "r:|${sep}=* r:|=* $matcher" - "$matches[@]"
+compadd -O tmp1 -M "r:|${sep}=* r:|=* $matcher" -a matches
(( $#tmp1 )) && matches=( "$tmp1[@]" )
@@ -138,7 +138,7 @@ while true; do
PREFIX="$pre"
SUFFIX="$suf"
- compadd -O matches -M "r:|${sep}=* r:|=* $matcher" - "$matches[@]"
+ compadd -O matches -M "r:|${sep}=* r:|=* $matcher" -a matches
if [[ "$pre" = *${sep}* ]]; then
PREFIX="${cpre}${pre%%${sep}*}"
diff --git a/Completion/Core/_next_label b/Completion/Core/_next_label
index 95569df3b..ca40d9a33 100644
--- a/Completion/Core/_next_label
+++ b/Completion/Core/_next_label
@@ -1,21 +1,21 @@
#autoload
-local gopt=-J descr spec
+local __gopt=-J __descr __spec
if [[ "$1" = -([12]|)[VJ] ]]; then
- gopt="$1"
+ __gopt="$1"
shift
fi
-if comptags -A "$1" curtag spec; then
- _comp_tags="$_comp_tags $spec "
+if comptags -A "$1" curtag __spec; then
+ _comp_tags="$_comp_tags $__spec "
if [[ "$curtag" = *:* ]]; then
- zformat -f descr "${curtag#*:}" "d:$3"
- _description "$gopt" "${curtag%:*}" "$2" "$descr"
+ zformat -f __descr "${curtag#*:}" "d:$3"
+ _description "$__gopt" "${curtag%:*}" "$2" "$__descr"
curtag="${curtag%:*}"
set -A $2 "${(P@)2}" "${(@)argv[4,-1]}"
else
- _description "$gopt" "$curtag" "$2" "$3"
+ _description "$__gopt" "$curtag" "$2" "$3"
set -A $2 "${(@)argv[4,-1]}" "${(P@)2}"
fi
diff --git a/Completion/Core/_options b/Completion/Core/_options
index 0a852e6ce..f86ec42a3 100644
--- a/Completion/Core/_options
+++ b/Completion/Core/_options
@@ -2,4 +2,7 @@
# This should be used to complete all option names.
-compgen "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' -o
+local expl
+
+_wanted zsh-options expl 'zsh option' \
+ compadd "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' -k options
diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files
index 807172bbb..be7eaff85 100644
--- a/Completion/Core/_path_files
+++ b/Completion/Core/_path_files
@@ -515,7 +515,7 @@ for prepath in "$prepaths[@]"; do
compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \
-W "$prepath$realpath$testpath" \
"$pfxsfx[@]" -M "r:|/=* r:|=*" \
- - "$tmp1[@]"
+ -a tmp1
fi
else
if [[ "$tmp3" = */* ]]; then
@@ -529,7 +529,7 @@ for prepath in "$prepaths[@]"; do
compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \
-W "$prepath$realpath$testpath" \
"$pfxsfx[@]" -M "r:|/=* r:|=*" \
- - "$tmp1[@]"
+ -a tmp1
fi
fi
tmp4=-
@@ -591,7 +591,7 @@ for prepath in "$prepaths[@]"; do
tmp4="$testpath"
compquote tmp4 tmp1
compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -W "$prepath$realpath$testpath" \
- "$pfxsfx[@]" -M "r:|/=* r:|=*" - "$tmp1[@]"
+ "$pfxsfx[@]" -M "r:|/=* r:|=*" -a tmp1
fi
fi
done
@@ -605,7 +605,7 @@ if zstyle -t ":completion:${curcontext}:paths" expand prefix &&
"$exppaths" != "$eorig" ]]; then
PREFIX="${opre}"
SUFFIX="${osuf}"
- compadd -Q "$mopts[@]" -S '' -M "r:|/=* r:|=*" -p "$linepath" - "$exppaths[@]"
+ compadd -Q "$mopts[@]" -S '' -M "r:|/=* r:|=*" -p "$linepath" -a exppaths
fi
[[ nm -ne compstate[nmatches] ]]
diff --git a/Completion/Core/_requested b/Completion/Core/_requested
index 2772b1bd7..5614098bc 100644
--- a/Completion/Core/_requested
+++ b/Completion/Core/_requested
@@ -1,17 +1,17 @@
#autoload
-local gopt=-J
+local __gopt=-J
if [[ "$1" = -([12]|)[VJ] ]]; then
- gopt="$1"
+ __gopt="$1"
shift
fi
if comptags -R "$1"; then
if [[ $# -gt 3 ]]; then
- _all_labels - "$gopt" "$@" || return 1
+ _all_labels - "$__gopt" "$@" || return 1
elif [[ $# -gt 1 ]]; then
- _description "$gopt" "$@"
+ _description "$__gopt" "$@"
fi
return 0
else
diff --git a/Completion/Core/_sep_parts b/Completion/Core/_sep_parts
index 0f9ef0fc4..4e505dd64 100644
--- a/Completion/Core/_sep_parts
+++ b/Completion/Core/_sep_parts
@@ -58,9 +58,9 @@ while [[ $# -gt 1 ]]; do
# Get the matching array elements.
PREFIX="${str%%(|\\)${sep}*}"
- builtin compadd -O testarr - "${(@P)arr}"
+ builtin compadd -O testarr -a "$arr"
[[ $#testarr -eq 0 && -n "$_comp_correct" ]] &&
- compadd -O testarr - "${(@P)arr}"
+ compadd -O testarr -a "$arr"
# If there are no matches we give up. If there is more than one
# match, this is the part we will complete.
@@ -88,9 +88,9 @@ if [[ $# -le 1 || "$str" != *${2}* ]]; then
# No more separators, build the matches.
PREFIX="$str"
- builtin compadd -O testarr - "${(@P)arr}"
+ builtin compadd -O testarr -a "$arr"
[[ $#testarr -eq 0 && -n "$_comp_correct" ]] &&
- compadd -O testarr - "${(@P)arr}"
+ compadd -O testarr -a "$arr"
fi
[[ $#testarr -eq 0 || ${#testarr[1]} -eq 0 ]] && return 1
@@ -125,9 +125,9 @@ while [[ $# -gt 0 && "$str" == *${1}* ]]; do
arr=tmparr
fi
- builtin compadd -O tmparr - "${(@P)arr}"
+ builtin compadd -O tmparr -a "$arr"
[[ $#tmparr -eq 0 && -n "$_comp_correct" ]] &&
- compadd -O tmparr - "${(@P)arr}"
+ compadd -O tmparr - "$arr"
suffixes=("${(@)^suffixes[@]}${(q)1}${(@)^tmparr}")
@@ -155,7 +155,7 @@ PREFIX="$pre"
SUFFIX="$suf"
for i in "$suffixes[@]"; do
compadd -U "$group[@]" "$expl[@]" "$matchers[@]" "$autosuffix[@]" "$opts[@]" \
- -i "$IPREFIX" -I "$ISUFFIX" -p "$prefix" -s "$i" - "$testarr[@]"
+ -i "$IPREFIX" -I "$ISUFFIX" -p "$prefix" -s "$i" -a testarr
done
# This sets the return value to indicate that we added matches (or not).
diff --git a/Completion/Core/_set_options b/Completion/Core/_set_options
index 5f634a2cd..37de45cd0 100644
--- a/Completion/Core/_set_options
+++ b/Completion/Core/_set_options
@@ -4,4 +4,7 @@
# names of the options that were set when it was called in the array
# `_set_options'.
-compadd "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' - $=_set_options
+local expl
+
+_wanted zsh-options expl 'set zsh option' \
+ compadd "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' -a _set_options
diff --git a/Completion/Core/_unset_options b/Completion/Core/_unset_options
index c5150c2e5..49cf70598 100644
--- a/Completion/Core/_unset_options
+++ b/Completion/Core/_unset_options
@@ -4,4 +4,7 @@
# names of the options that were set when it was called in the array
# `_set_options'.
-compadd "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' - $=_unset_options
+local expl
+
+_wanted zsh-options expl 'unset zsh option' \
+ compadd "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' -a _unset_options
diff --git a/Completion/Core/_wanted b/Completion/Core/_wanted
index 958f9e18e..3e25fdbbc 100644
--- a/Completion/Core/_wanted
+++ b/Completion/Core/_wanted
@@ -1,26 +1,26 @@
#autoload
-local targs gopt=-J
+local __targs __gopt=-J
if [[ "$1" = -C?* ]]; then
- targs=( -C "${1[3,-1]}" )
+ __targs=( -C "${1[3,-1]}" )
shift
elif [[ "$1" = -C ]]; then
- targs=( -C "$2" )
+ __targs=( -C "$2" )
shift 2
else
- targs=()
+ __targs=()
fi
if [[ "$1" = -([12]|)[VJ] ]]; then
- gopt="$1"
+ __gopt="$1"
shift
fi
-_tags "$targs[@]" "$1"
+_tags "$__targs[@]" "$1"
while _tags; do
- _all_labels "$gopt" "$@" && return 0
+ _all_labels "$__gopt" "$@" && return 0
done
return 1
diff --git a/Completion/User/_archie b/Completion/User/_archie
index 103fd881a..96e628189 100644
--- a/Completion/User/_archie
+++ b/Completion/User/_archie
@@ -26,7 +26,7 @@ case "$state" in
serverhost)
: ${(A)archie_servers:=${(M)$(_call hosts archie -L):#archie.*}}
- _wanted hosts expl 'archie servers' compadd - $archie_servers && return 0
+ _wanted hosts expl 'archie servers' compadd -a archie_servers && return 0
;;
esac
diff --git a/Completion/User/_cvs b/Completion/User/_cvs
index 341bbcb54..476f2d755 100644
--- a/Completion/User/_cvs
+++ b/Completion/User/_cvs
@@ -49,7 +49,7 @@ _cvs_command () {
watchers "")
if (( CURRENT == 1 )); then
- _tags commands && { compadd "$@" ${(k)cmds} || compadd "$@" ${(kv)=cmds} }
+ _tags commands && { compadd "$@" -k cmds || compadd "$@" ${(kv)=cmds} }
else
local curcontext="$curcontext"
@@ -584,7 +584,7 @@ _cvs_root () {
fi
_tags files && {
- compadd -M 'r:|[:@./]=** r:|=**' "$@" $_cvs_roots || _files "$@" -/
+ compadd -M 'r:|[:@./]=** r:|=**' "$@" -a _cvs_roots || _files "$@" -/
}
}
@@ -652,7 +652,7 @@ _cvs_modules () {
fi
fi
if (( $#_cvs_modules_cache )); then
- _wanted modules expl 'module name' compadd - $_cvs_modules_cache
+ _wanted modules expl 'module name' compadd -a _cvs_modules_cache
else
_message 'module name'
fi
@@ -683,7 +683,7 @@ _cvs_revisions () {
fi
if (( $#_cvs_revisions_cache )); then
- _wanted values expl revision compadd - $_cvs_revisions_cache
+ _wanted values expl revision compadd -a _cvs_revisions_cache
else
_message revision
fi
@@ -813,7 +813,7 @@ _cvs_nonexisting_entries () {
${${${${(M)${(f)"$(<"$realdir"CVS/Entries)"}:#(D|)/*}#(D|)/}%%/*}:#${(j:|:)~${files//(#m)[][*?()<|^~#\\]/\\$MATCH}}}
)
compquote files
- _wanted files expl file compadd -Qp "$linedir" $files
+ _wanted files expl file compadd -Qp -a linedir files
}
}
diff --git a/Completion/User/_domains b/Completion/User/_domains
index 9bd94a4fd..42a0966dd 100644
--- a/Completion/User/_domains
+++ b/Completion/User/_domains
@@ -2,7 +2,7 @@
local expl domains tmp
-if ! zstyle -a ":completion${curcontext}:domains" domains domains; then
+if ! zstyle -a ":completion:${curcontext}:domains" domains domains; then
if (( ! $+_cache_domains )); then
_cache_domains=()
if [[ -f /etc/resolv.conf ]]; then
@@ -10,11 +10,11 @@ if ! zstyle -a ":completion${curcontext}:domains" domains domains; then
[[ "$tmp" = (domain|search)* ]] &&
_cache_domains=( "$_cache_domains[@]" "${=${tmp%%[ ]#}#*[ ]}" )
done < /etc/resolv.conf
- _cache_domains=( "${(@)_nslookup_domains:#[ ]#}" )
+ _cache_domains=( "${(@)_cache_domains:#[ ]#}" )
fi
fi
domains=( "$_cache_domains[@]" )
fi
-_wanted domains expl domain &&
- compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" "$expl[@]" - "$domains[@]"
+_wanted domains expl domain \
+ compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" -a domains
diff --git a/Completion/User/_gprof b/Completion/User/_gprof
index f261ff700..fe7f1fdac 100644
--- a/Completion/User/_gprof
+++ b/Completion/User/_gprof
@@ -49,7 +49,7 @@ if [[ -n "$state" ]]; then
expl=function
fi
_wanted functions expl "$expl" \
- compadd -M 'r:|_=* r:|=*' - "$_gprof_funcs[@]" && ret=0
+ compadd -M 'r:|_=* r:|=*' -a _gprof_funcs && ret=0
else
return 1
fi
diff --git a/Completion/User/_groups b/Completion/User/_groups
index d1475b857..673c44688 100644
--- a/Completion/User/_groups
+++ b/Completion/User/_groups
@@ -16,4 +16,4 @@ if ! zstyle -a ":completion:${curcontext}:" groups groups; then
groups=( "$_cache_groups[@]" )
fi
-_wanted groups expl group compadd "$@" - "$groups[@]"
+_wanted groups expl group compadd "$@" -a groups
diff --git a/Completion/User/_hosts b/Completion/User/_hosts
index 3acc327ac..30c3b2357 100644
--- a/Completion/User/_hosts
+++ b/Completion/User/_hosts
@@ -1,3 +1,13 @@
-#defcomp ftp ncftp ping rwho rup xping traceroute nslookup
+#compdef ftp ncftp ping rwho rup xping traceroute host
-complist -k hosts
+local expl hosts
+
+if ! zstyle -a ":completion:${curcontext}:hosts" hosts hosts; then
+ (( $+_cache_hosts )) ||
+ : ${(A)_cache_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
+
+ hosts=( "$_cache_hosts[@]" )
+fi
+
+_wanted hosts expl host \
+ compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" -a hosts
diff --git a/Completion/User/_lp b/Completion/User/_lp
index 844178169..a81d348bb 100644
--- a/Completion/User/_lp
+++ b/Completion/User/_lp
@@ -26,7 +26,7 @@ else
else
disp=()
fi
- _all_labels users expl user compadd "$disp[@]" - "$strs[@]" ||
+ _all_labels users expl user compadd "$disp[@]" -a strs ||
_users && ret=0
fi
if _requested jobs; then
@@ -38,7 +38,7 @@ else
else
disp=()
fi
- _all_labels jobs expl job compadd "$disp[@]" - "$strs[@]" && ret=0
+ _all_labels jobs expl job compadd "$disp[@]" -a strs && ret=0
fi
(( ret )) || return 0
done
diff --git a/Completion/User/_mailboxes b/Completion/User/_mailboxes
index c49aa8185..e2b4b5289 100644
--- a/Completion/User/_mailboxes
+++ b/Completion/User/_mailboxes
@@ -1,32 +1,164 @@
#autoload
-# This is needlessly mutt-biased and should be fixed.
+_mailboxes() {
+ #emulate -L zsh
+ local expl ret=1
+ local pinedirectory="${pinedirectory:-~/mail}"
+ local maildirectory="${maildirectory:-~/Mail}"
-local expl muttboxes mboxes dirboxes MHboxes maildirboxes muttrc="~/.muttrc" maildirectory="~/Mail"
+ if (( ! $+_mailbox_cache )) then
+ _mailbox_cache "$@"
+ fi
-test -f "$compconfig[muttrc_path]" && muttrc=$compconfig[muttrc_path]
-test -f "$compconfig[maildirectory]" && maildirectory=$compconfig[maildirectory]
+ case "${curcontext}" in
+ (*:mail:*)
+ if [[ "$PREFIX" == +* ]]; then
+ _tags mailboxes
+ else
+ _tags mailboxes files
+ fi;;
+ (*:(mush|zmail|zmlite):*)
+ if [[ "$PREFIX" == [%+]* ]]; then
+ _tags mailboxes
+ else
+ _tags mailboxes files
+ fi;;
+ (*:pine:*)
+ # Files for pine must be absolute paths.
+ if [[ "$PREFIX" == (|-f)[/\~]* ]]; then
+ pinedirectory=''
+ _tags mailboxes files
+ else
+ _tags mailboxes
+ fi;;
+ (*)
+ if [[ "$PREFIX" == (|-f)+* ]]; then
+ _tags mailboxes
+ else
+ _tags mailboxes files
+ fi;;
+ esac
-if (( ! $+_mailbox_cache )) then
+ while _tags; do
+ _requested mailboxes expl 'mailbox specification' _mua_mailboxes && ret=0
-test ${muttrc} || test -f ${~muttrc} && muttboxes=( ${(@)$(grep mailboxes ${~muttrc})[2,-1]} )
+ if _requested files expl 'mailbox file'; then
+ [[ "${curcontext}" != *:(mail|mush|zmail|zmlite):* ]] &&
+ compset -P -f
+ _files "$expl[@]" && ret=0
+ fi
+ (( ret )) || return 0
+ done
-mboxes=(${~maildirectory}/*(^/))
-dirboxes=(${~maildirectory}/*(/))
+ return 1
+}
-for i in $dirboxes
-do
-if test -d "${i}/cur"
-then
-maildirboxes=($maildirboxes $i)
-else
-MHboxes=($MHboxes $i)
-fi
-done
+_mailbox_cache () {
+ # Depends on $maildirectory and $pinedirectory from _mailboxes!
-_mailbox_cache=(\! \< \> $muttboxes $mboxes $maildirboxes $MHboxes)
+ local i j muttrc="${muttrc:-~/.muttrc}"
+ local -aU dirboxes
+ typeset -aU -g _mailbox_cache
+ typeset -aU -g _maildir_cache _mbox_cache _mh_cache _mutt_cache _pine_cache
-fi
+ setopt localoptions nullglob
-_description expl 'mailbox specification'
-compadd "$@" "$expl[@]" - "$_mailbox_cache[@]"
+
+ [[ -f ${~muttrc:-.} ]] &&
+ _mutt_cache=( ${$(grep mailboxes ${~muttrc})[2,-1]} )
+
+ _mbox_cache=( ${~maildirectory}/*(^/) )
+ _pine_cache=( ${~pinedirectory}/**/*(.) )
+
+ dirboxes=( ${~maildirectory}/*(/) )
+
+ while (( $#dirboxes )); do
+ i=${dirboxes[1]}
+ shift dirboxes
+ if [[ -d "$i/cur" ]]; then
+ _maildir_cache=( "${_maildir_cache[@]}" "$i" )
+ elif j=( "$i"/<1-> ) && [[ -n "$j" ]]; then
+ _mh_cache=( "${_mh_cache[@]}" "$i" )
+ else
+ _mbox_cache=( "${_mbox_cache[@]}" "$i"/*(.) )
+ dirboxes=( $dirboxes "$i"/*(/) )
+ fi
+ done
+
+ [[ -n "$mailpath" ]] &&
+ _mailbox_cache=( "${_mailbox_cache[@]}" "${(@)mailpath%%\?*}" )
+
+ [[ -n "$MAIL" ]] && _mailbox_cache=( "${_mailbox_cache[@]}" $MAIL )
+}
+
+_mua_mailboxes() {
+ # Depends on $maildirectory and $pinedirectory from _mailboxes!
+
+ local -a mbox_short
+ local -aU mbox_names
+ local ret=1
+
+ case "${curcontext}" in
+ (*:elm:*) # I've probably got this wrong, or at least incomplete
+ mbox_names=( "${_mbox_cache[@]}" "${_mailbox_cache[@]}" )
+ mbox_short=( \! \< \> )
+ ;;
+ (*:mail:*)
+ if compset -P +; then
+ mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
+ else
+ mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}"
+ "${_mailbox_cache[@]}" )
+ fi
+ ;;
+ (*:mh:*) # I've probably got this wrong, or at least incomplete
+ (( $#_mh_cache )) && _multi_parts "${expl[@]}" / _mh_cache && ret=0
+ ;;
+ (*:mush:*)
+ if compset -P %; then
+ mbox_short=( "${(@k)userdirs}" )
+ elif compset -P +; then
+ mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
+ else
+ mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}"
+ "${_mailbox_cache[@]}" )
+ mbox_short=( \& % %"${(@k)^userdirs}" )
+ fi
+ ;;
+ (*:mutt:*)
+ mbox_names=( "${_mutt_cache[@]}" "${_mailbox_cache[@]}"
+ "${_maildir_cache[@]}" )
+ mbox_short=( \! \< \> );;
+ (*:pine:*)
+ # Pine is like mail but with no leading `+' to disambiguate;
+ # any files not in $pinedirectory must be absolute paths.
+ mbox_names=( "${(@)_pine_cache#$~pinedirectory/}" "${_mbox_cache[@]}"
+ "${_mailbox_cache[@]}" "${_mh_cache[@]}" )
+ ;;
+ (*:tkrat:*) # Has a couple of custom formats I haven't programmed for.
+ mbox_names=( "${_mbox_cache[@]}"
+ "${_mailbox_cache[@]}" "${_mh_cache[@]}" )
+ ;;
+ (*:(zmail|zmlite):*)
+ if compset -P %; then
+ mbox_short=( "${(@k)userdirs}" )
+ elif compset -P +; then
+ mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
+ else
+ mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}"
+ "${_mailbox_cache[@]}" "${_mh_cache[@]}" )
+ mbox_short=( \& % %"${(@k)^userdirs}" )
+ fi
+ ;;
+ (*) # Some other program wants mailbox names? Use them all?
+ mbox_names=( "${_mailbox_cache[@]}" "${_mbox_cache[@]}"
+ "${_mh_cache[@]}" "${_mutt_cache[@]}" "${_pine_cache[@]}" )
+ ;;
+ esac
+
+ (( $#mbox_names )) && _multi_parts "$@" / mbox_names && ret=0
+ (( $#mbox_short )) && compadd "$@" -a mbox_short && ret=0
+ return ret
+}
+
+[[ -o kshautoload ]] || _mailboxes "$@"
diff --git a/Completion/User/_make b/Completion/User/_make
index 09e4e4f89..b13224c06 100644
--- a/Completion/User/_make
+++ b/Completion/User/_make
@@ -42,7 +42,7 @@ else
FS=: $file)
)
fi
- _wanted targets expl 'make target' compadd "$tmp[@]" && return 0
+ _wanted targets expl 'make target' compadd -a tmp && return 0
fi
compset -P 1 '*='
_files
diff --git a/Completion/User/_mount b/Completion/User/_mount
index b0d20ca98..50fa769b2 100644
--- a/Completion/User/_mount
+++ b/Completion/User/_mount
@@ -540,7 +540,7 @@ fstype)
compset -P '*,'
_wanted types expl 'file system type' \
- compadd -qS, -M 'L:|no=' - "$fss[@]" && ret=0
+ compadd -qS, -M 'L:|no=' -a fss && ret=0
;;
fsopt)
_tags options || return 1
@@ -569,8 +569,8 @@ udevordir)
mp_tmp=( "${(@)${(@)tmp#* }%% *}" )
_alternative \
- 'devices:device:compadd - $dev_tmp[@]' \
- 'directories:mount point:compadd - $mp_tmp[@]' && ret=0
+ 'devices:device:compadd -a dev_tmp' \
+ 'directories:mount point:compadd -a mp_tmp' && ret=0
fi
;;
esac
diff --git a/Completion/User/_mysql_utils b/Completion/User/_mysql_utils
index c696f774b..c4648c818 100644
--- a/Completion/User/_mysql_utils
+++ b/Completion/User/_mysql_utils
@@ -64,7 +64,7 @@ _mysql_databases () {
)
shift _mysql_databases
- compadd "$expl[@]" - $_mysql_databases
+ compadd "$expl[@]" -a _mysql_databases
}
_mysql_tables () {
@@ -79,7 +79,7 @@ _mysql_tables () {
# remove header
shift _mysql_tables
- compadd "$expl[@]" - $_mysql_tables
+ compadd "$expl[@]" -a _mysql_tables
}
_mysql_variables () {
@@ -205,7 +205,7 @@ _mysqladmin_commands () {
)
if (( CURRENT == 1 )); then
- _wanted commands expl command compadd "$@" - $cmds
+ _wanted commands expl command compadd "$@" -a cmds
else
local curcontext="$curcontext"
diff --git a/Completion/User/_netscape b/Completion/User/_netscape
index c6fd084cc..2aba6750d 100644
--- a/Completion/User/_netscape
+++ b/Completion/User/_netscape
@@ -62,8 +62,8 @@ if [[ "$state" = "remote" ]]; then
*)
compset -S '(|\\)\(*' || suf="${${QIPREFIX:+(}:-\(}"
_wanted commands expl 'remote commands' \
- compadd -qS "$suf" -M 'm:{a-zA-Z}={A-Za-z}' - \
- $remote_commands && ret=0
+ compadd -qS "$suf" -M 'm:{a-zA-Z}={A-Za-z}' -a \
+ remote_commands && ret=0
;;
esac
fi
diff --git a/Completion/User/_perl b/Completion/User/_perl
index 848118431..af94961cc 100644
--- a/Completion/User/_perl
+++ b/Completion/User/_perl
@@ -59,7 +59,7 @@ _perl_config_vars () {
(( compstate[quoting] )) && delimiter=' '
compset -P '* ' && compset -q
- compadd "$expl[@]" $add_colon -S$delimiter -q - $_perl_config_vars
+ compadd "$expl[@]" $add_colon -S$delimiter -q -a _perl_config_vars
}
_perl "$@"
diff --git a/Completion/User/_perl_basepods b/Completion/User/_perl_basepods
index 4478c5263..5c8034a96 100644
--- a/Completion/User/_perl_basepods
+++ b/Completion/User/_perl_basepods
@@ -29,4 +29,4 @@ fi
local expl
-_wanted pods expl 'Perl base pods' compadd - $_perl_basepods
+_wanted pods expl 'Perl base pods' compadd -a _perl_basepods
diff --git a/Completion/User/_perl_builtin_funcs b/Completion/User/_perl_builtin_funcs
index a8facda08..f5538c9e4 100644
--- a/Completion/User/_perl_builtin_funcs
+++ b/Completion/User/_perl_builtin_funcs
@@ -12,13 +12,13 @@ if [[ ${+_perl_builtin_funcs} -eq 0 ]]; then
typeset -agU _perl_builtin_funcs
local perlfunc
- if perlfunc=`man -w perlfunc 2>&1`; then
+ if [[ -n "${perlfunc:=$(man -w perlfunc 2>/dev/null; print -l ${^manpath}/man1/perlfunc.1(N) {/usr/man,/usr/local/man}/man1/perlfunc.1(N))}" ]]; then
_perl_builtin_funcs=( `perl -lne '
$in_funcs++, next if /Alphabetical/; \
next unless $in_funcs; \
if (/^\.Ip "(\w+)/) { \
print $1 unless $func{$1}; $func{$1}++ \
- }' $perlfunc`
+ }' $=perlfunc`
)
else
echo "Couldn't find perlfunc man page; giving up."
@@ -26,4 +26,6 @@ if [[ ${+_perl_builtin_funcs} -eq 0 ]]; then
fi
fi
-compadd - $_perl_builtin_funcs
+local expl
+
+_wanted functions expl 'Perl built-in functions' compadd -a _perl_builtin_funcs
diff --git a/Completion/User/_perl_modules b/Completion/User/_perl_modules
index f28fc3ecc..88efdd395 100644
--- a/Completion/User/_perl_modules
+++ b/Completion/User/_perl_modules
@@ -62,4 +62,4 @@ fi
local expl
-_wanted modules expl 'Perl modules' compadd "$opts[@]" - $_perl_modules
+_wanted modules expl 'Perl modules' compadd "$opts[@]" -a _perl_modules
diff --git a/Completion/User/_ports b/Completion/User/_ports
index 950212832..958917bd6 100644
--- a/Completion/User/_ports
+++ b/Completion/User/_ports
@@ -1,8 +1,12 @@
#autoload
-local expl
+local expl ports
-: ${(A)ports:=${${(M)${${(f)"$(</etc/services)"}:#\#*}#*/tcp}%%[ ]*}}
+if ! zstyle -a ":completion:${curcontext}:" ports ports; then
+ (( $+_cache_ports )) ||
+ : ${(A)_cache_ports:=${${(M)${${(f)"$(</etc/services)"}:#\#*}#*/tcp}%%[ ]*}}
-_description expl port
-compadd "$@" "$expl[@]" - "$ports[@]"
+ ports=( "$_cache_ports[@]" )
+fi
+
+_wanted ports expl port compadd "$@" -a ports
diff --git a/Completion/User/_rcs b/Completion/User/_rcs
index 1792179d7..d9280b11f 100644
--- a/Completion/User/_rcs
+++ b/Completion/User/_rcs
@@ -8,5 +8,5 @@ if [[ $compstate[nmatches] -eq nm && -d RCS && $cmd != ci ]]; then
local rep expl
rep=(RCS/$PREFIX*$SUFFIX,v(:t:s/\,v//))
- (( $#rep )) && _wanted files expl 'RCS file' compadd - $rep
+ (( $#rep )) && _wanted files expl 'RCS file' compadd -a rep
fi
diff --git a/Completion/User/_urls b/Completion/User/_urls
index 7fa120d2c..0d1845754 100644
--- a/Completion/User/_urls
+++ b/Completion/User/_urls
@@ -124,7 +124,7 @@ if ! compset -P '(#b)([^/]#)/'; then
compset -S '/*' || suf="/"
(( $#uhosts )) || _hosts -S "$suf" "$expl[@]" && ret=0
[[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername)
- compadd -S "$suf" "$expl[@]" - $uhosts && ret=0
+ compadd -S "$suf" "$expl[@]" -a uhosts && ret=0
done
(( ret )) || return 0
done
diff --git a/Completion/User/_users b/Completion/User/_users
index dce0fd584..a7ea8b714 100644
--- a/Completion/User/_users
+++ b/Completion/User/_users
@@ -3,6 +3,6 @@
local expl users
zstyle -a ":completion:${curcontext}:" users users &&
- _wanted users expl user compadd "$@" - "$users[@]" && return 0
+ _wanted users expl user compadd "$@" -a users && return 0
-_wanted users expl user compadd "$@" - "${(@k)userdirs}"
+_wanted users expl user compadd "$@" -k userdirs
diff --git a/Completion/User/_yp b/Completion/User/_yp
index 5b0c86143..d25533e35 100644
--- a/Completion/User/_yp
+++ b/Completion/User/_yp
@@ -96,10 +96,10 @@ if [[ "$state" = map* ]]; then
while _tags; do
# The `-M ...' allows `pa.n<TAB>' to complete to `passwd.byname'.
_requested maps expl 'map name' \
- compadd -M 'l:.|by=by l:.|=by r:|.=* r:|=*' - \
- "$_yp_cache_maps[@]" && ret=0
+ compadd -M 'l:.|by=by l:.|=by r:|.=* r:|=*' -a \
+ _yp_cache_maps && ret=0
_requested nicknames expl nicknames \
- compadd - "$_yp_cache_nicks[@]" && ret=0
+ compadd -a _yp_cache_nicks && ret=0
(( ret )) || return 0
done
elif [[ "$state" = servers ]]; then
diff --git a/Completion/X/_x_color b/Completion/X/_x_color
index 8df656fe1..c4e54363d 100644
--- a/Completion/X/_x_color
+++ b/Completion/X/_x_color
@@ -31,5 +31,5 @@ if (( ! $+_color_cache )); then
fi
_wanted colors expl 'color specification' \
- compadd "$@" -M 'm:{a-z}={A-Z} m:-=\ r:[^ A-Z0-9]||[ A-Z0-9]=* r:|=*' - \
- "$_color_cache[@]"
+ compadd "$@" -M 'm:{a-z}={A-Z} m:-=\ r:[^ A-Z0-9]||[ A-Z0-9]=* r:|=*' -a \
+ _color_cache
diff --git a/Completion/X/_x_cursor b/Completion/X/_x_cursor
index 59ecb5976..5346710d7 100644
--- a/Completion/X/_x_cursor
+++ b/Completion/X/_x_cursor
@@ -14,5 +14,5 @@ if (( ! $+_cursor_cache )); then
fi
fi
-_description expl 'cursor name'
-compadd "$@" "$expl[@]" -M 'm:-=_ r:|_=*' - "$_cursor_cache[@]"
+_wanted cursors expl 'cursor name' \
+ compadd "$@" -M 'm:-=_ r:|_=*' -a _cursor_cache
diff --git a/Completion/X/_x_extension b/Completion/X/_x_extension
index 5b742a78c..690226975 100644
--- a/Completion/X/_x_extension
+++ b/Completion/X/_x_extension
@@ -15,5 +15,5 @@ else
[[ "$1" = - ]] && shift
_wanted extensions expl 'X extensions' \
- compadd "$@" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - "$_xe_cache[@]"
+ compadd "$@" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - _xe_cache
fi
diff --git a/Completion/X/_x_font b/Completion/X/_x_font
index 228542bd2..92dc1ade4 100644
--- a/Completion/X/_x_font
+++ b/Completion/X/_x_font
@@ -13,4 +13,4 @@ if (( ! $+_font_cache )); then
fi
_wanted fonts expl font \
- compadd -M 'r:|-=* r:|=*' "$@" -S '' - "$_font_cache[@]"
+ compadd -M 'r:|-=* r:|=*' "$@" -S '' -a _font_cache
diff --git a/Completion/X/_x_keysym b/Completion/X/_x_keysym
index 8d4cfa1f8..39fbaebdd 100644
--- a/Completion/X/_x_keysym
+++ b/Completion/X/_x_keysym
@@ -19,4 +19,4 @@ if (( ! $+_keysym_cache )); then
fi
_wanted keysyms expl 'key symbol' \
- compadd "$@" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - $_keysym_cache
+ compadd "$@" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' -a _keysym_cache
diff --git a/Completion/X/_xutils b/Completion/X/_xutils
index 09fafd5d4..bba73a3ee 100644
--- a/Completion/X/_xutils
+++ b/Completion/X/_xutils
@@ -73,7 +73,7 @@ xhost)
_tags displays
while _tags; do
while _next_label displays expl 'disallow access'; do
- { compadd "$expl[@]" -M 'm:{a-z}={A-Z} r:|[:.]=* r:|=*' - $tmp ||
+ { compadd "$expl[@]" -M 'm:{a-z}={A-Z} r:|[:.]=* r:|=*' -a tmp ||
_hosts "$expl[@]" } && ret=0
done
(( ret )) || return 0