1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-11 00:51:05 +02:00

use compadd -[ak] (11549)

This commit is contained in:
Sven Wischnowsky 2000-05-31 09:38:25 +00:00
parent 4629133ad3
commit fd25b24df6
67 changed files with 473 additions and 227 deletions

View file

@ -1,5 +1,41 @@
2000-05-31 Sven Wischnowsky <wischnow@zsh.org> 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 * Andrej: 11660: Completion/User/_man: fix for ${..//..} with % in
search string search string

View file

@ -1,25 +1,27 @@
#autoload #autoload
# Usage: # 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 # 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=( # zstyle ':completion:*:*:telnet:*:my-accounts' users-hosts-ports \
# host0:: host1::user1 host2::user2 # @host0: user1@host1: user2@host2:
# mail-server:{smtp,pop3}: # @mail-server:{smtp,pop3}
# news-server:nntp: # @news-server:nntp
# proxy-server:8000: # @proxy-server:8000
# ) #
# #
# `_telnet completes' hosts as: # `_telnet' completes hosts as:
# #
# _combination telnet_hosts_ports_users \ # _combination my-accounts users-hosts-ports \
# ${options[-l]:+users=${options[-l]:q}} \ # ${opt_args[-l]:+users=${opt_args[-l]:q}} \
# hosts "$expl[@]" # hosts "$expl[@]"
# #
# This completes `host1', `host2', `mail-server', `news-server' and # This completes `host1', `host2', `mail-server', `news-server' and
@ -28,8 +30,8 @@
# #
# `_telnet' completes ports as: # `_telnet' completes ports as:
# #
# _combination telnet_hosts_ports_users \ # _combination my-accounts users-hosts-ports \
# ${options[-l]:+users=${options[-l]:q}} \ # ${opt_args[-l]:+users=${opt_args[-l]:q}} \
# hosts="${line[2]:q}" \ # hosts="${line[2]:q}" \
# ports "$expl[@]" # ports "$expl[@]"
# #
@ -39,7 +41,7 @@
# #
# `_telnet' completes users for an argument of option `-l' as: # `_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[2]:+hosts="${line[2]:q}"} \
# ${line[3]:+ports="${line[3]:q}"} \ # ${line[3]:+ports="${line[3]:q}"} \
# users "$expl[@]" # users "$expl[@]"
@ -48,25 +50,23 @@
# the port argument if they are exist. And if it is failed, `_users' is # the port argument if they are exist. And if it is failed, `_users' is
# called. # called.
local sep var keys pats key num tmp local sep tag style keys pats key num tmp
if [[ "$1" = -s ]]; then if [[ "$1" = -s ]]; then
sep="$2" sep="$2"
shift 2 shift 2
elif [[ "$1" = -s* ]]; then
sep="${1[3,-1]}"
shift
else else
sep=: sep=:
fi fi
var=$1 tag="$1"
shift style="$2"
shift 2
if [[ $var = *:* ]]; then keys=( ${(s/-/)style} )
keys=( ${(s/:/)var} )
shift keys
var="${var%%:*}"
else
keys=( "${(@s:_:)${var#*_}}" )
fi
pats=( "${(@)keys/*/*}" ) pats=( "${(@)keys/*/*}" )
while [[ "$1" = *=* ]]; do while [[ "$1" = *=* ]]; do
@ -81,15 +81,14 @@ key="${1%:*}"
num="${${1##*:}:-1}" num="${${1##*:}:-1}"
shift shift
if (( ${(P)+${var}} )); then if zstyle -a ":completion:${curcontext}:$tag" "$style" tmp; then
eval "tmp=( \"\${(@M)${var}:#\${(j($sep))~pats}}\" )" eval "tmp=( \"\${(@M)tmp:#\${(j($sep))~pats}}\" )"
if (( keys[(in:num:)$key] != 1 )); then 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 fi
tmp=( ${tmp%%$sep*} ) tmp=( ${tmp%%${~sep}*} )
compadd "$@" - $tmp || { builtin functions _$key >&- && _$key "$@" } compadd "$@" -a tmp || { (( $+functions[_$key] )) && "_$key" "$@" }
else else
builtin functions _$key >&- && _$key "$@" (( $+functions[_$key] )) && "_$key" "$@"
fi fi

View file

@ -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[@]"

View file

@ -52,8 +52,8 @@ while _tags; do
fi fi
fi fi
compadd "$_args[@]" "$_expl[@]" -ld _tmpd - "$_tmpmd[@]" && _ret=0 compadd "$_args[@]" "$_expl[@]" -ld _tmpd -a _tmpmd && _ret=0
compadd "$_args[@]" "$_expl[@]" -d _tmps - "$_tmpms[@]" && _ret=0 compadd "$_args[@]" "$_expl[@]" -d _tmps -a _tmpms && _ret=0
done done
done done
(( _ret )) || return 0 (( _ret )) || return 0

View file

@ -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'

View file

@ -12,7 +12,7 @@ elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
[[ "$RBUFFER" != \]* ]] && suf=']' [[ "$RBUFFER" != \]* ]] && suf=']'
_wanted association-keys expl 'association key' \ _wanted association-keys expl 'association key' \
compadd -S "$suf" - "${(@kP)${compstate[parameter]}}" compadd -S "$suf" -k "$compstate[parameter]"
elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then
local list i j ret=1 disp local list i j ret=1 disp
@ -39,10 +39,10 @@ elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then
if [[ "$RBUFFER" = \]* ]]; then if [[ "$RBUFFER" = \]* ]]; then
_all_labels -V indexes expl 'array index' \ _all_labels -V indexes expl 'array index' \
compadd -S '' "$disp[@]" - "$ind[@]" && ret=0 compadd -S '' "$disp[@]" -a ind && ret=0
else else
_all_labels -V indexes expl 'array index' \ _all_labels -V indexes expl 'array index' \
compadd -S ']' "$disp[@]" - "$ind[@]" && ret=0 compadd -S ']' "$disp[@]" -a ind && ret=0
fi fi
fi fi
_requested parameters && _parameters && ret=0 _requested parameters && _parameters && ret=0

View file

@ -2,7 +2,7 @@
# We use all named directories and user names here. If this is too slow # 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 # 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 [[ -n "$compstate[quote]" ]] && return 1
@ -22,7 +22,7 @@ while _tags; do
_requested users && _users "$suf[@]" "$@" && ret=0 _requested users && _users "$suf[@]" "$@" && ret=0
_requested named-directories expl 'named directory' \ _requested named-directories expl 'named directory' \
compadd "$suf[@]" "$@" - "${(@k)nameddirs}" compadd "$suf[@]" "$@" -k nameddirs
if _requested directory-stack && if _requested directory-stack &&
{ ! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed || { ! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed ||
@ -50,7 +50,7 @@ while _tags; do
disp=() disp=()
fi fi
_all_labels -V directory-stack expl 'directory stack' \ _all_labels -V directory-stack expl 'directory stack' \
compadd "$suf[@]" "$disp[@]" -Q - "$list[@]" && ret=0 compadd "$suf[@]" "$disp[@]" -Q -a list && ret=0
fi fi
(( ret )) || return 0 (( ret )) || return 0
done done

View file

@ -10,7 +10,7 @@ _value () {
"${(Pt)${compstate[parameter]}}" = assoc* ]]; then "${(Pt)${compstate[parameter]}}" = assoc* ]]; then
if (( CURRENT & 1 )); then if (( CURRENT & 1 )); then
_wanted association-keys expl 'association key' \ _wanted association-keys expl 'association key' \
compadd - "${(@kP)${compstate[parameter]}}" compadd -k "$compstate[parameter]"
else else
compstate[parameter]="${compstate[parameter]}-${words[CURRENT-1]}" compstate[parameter]="${compstate[parameter]}-${words[CURRENT-1]}"
_value "$@" _value "$@"

View file

@ -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'

View file

@ -29,9 +29,9 @@ _arguments -C -s \
case $state in case $state in
keymap) keymap)
_wanted -C -M keymaps expl keymap compadd - "$keymaps[@]" _wanted -C -M keymaps expl keymap compadd -a keymaps
;; ;;
widget) widget)
_wanted widgets expl widget compadd -M 'r:|-=* r:|=*' - "${(@k)widgets}" _wanted widgets expl widget compadd -M 'r:|-=* r:|=*' -k widgets
;; ;;
esac esac

View file

@ -1,7 +1,11 @@
#defcomp builtin #compdef builtin
if [[ -position 2 -1 ]]; then if (( $CURRENT > 2 )); then
_normal "$@" shift words
(( CURRENT -- ))
_normal
else else
complist -eB local expl
_wanted commands expl 'builtin command' compadd "$@" -k builtins
fi fi

View file

@ -22,7 +22,7 @@ if [[ CURRENT -eq 3 ]]; then
rep=(${~PWD/$words[2]/*}~$PWD(-/N)) rep=(${~PWD/$words[2]/*}~$PWD(-/N))
# Now remove all the common parts of $PWD and the completions from this # Now remove all the common parts of $PWD and the completions from this
rep=(${${rep#${PWD%%$words[2]*}}%${PWD#*$words[2]}}) 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 elif _popd || [[ $PREFIX != (\~|/|./|../)* && $#cdpath -ne 0 ]]; then
local tdir tdir2 local tdir tdir2

View file

@ -1,7 +1,10 @@
#defcomp command #compdef command
if [[ -position 2 -1 ]]; then if [[ CURRENT -ge 3 ]]; then
_normal "$@" compset -n 2
_normal
else else
complist -em local expl
_wanted commands expl 'external command' compadd "$@" -k commands
fi fi

View file

@ -30,16 +30,16 @@ fi
case $state in case $state in
ccom) ccom)
_wanted commands expl 'completed command' compadd - ${(k)_comps} _wanted commands expl 'completed command' compadd -k _comps
;; ;;
cfun) cfun)
list=( ${^fpath:/.}/_(|*[^~])(N:t) ) list=( ${^fpath:/.}/_(|*[^~])(N:t) )
if zstyle -T ":completion:${curcontext}:functions" prefix-hidden; then if zstyle -T ":completion:${curcontext}:functions" prefix-hidden; then
disp=( ${list[@]#_} ) disp=( ${list[@]#_} )
_wanted functions expl 'completion function' \ _wanted functions expl 'completion function' \
compadd -d disp - "$list[@]" compadd -d disp -a list
else else
_wanted functions expl 'completion function' compadd - "$list[@]" _wanted functions expl 'completion function' compadd -a list
fi fi
;; ;;
style) style)

View file

@ -1,3 +1,5 @@
#defcomp unfunction #compdef functions unfunction
complist -F local expl
_wanted functions expl 'shell function' compadd "$@" -k functions

View file

@ -28,11 +28,11 @@ if [[ $state = hashval ]]; then
_wanted -C value files expl directories _path_files -/ _wanted -C value files expl directories _path_files -/
else else
_wanted -C name named-directories expl 'named directory' \ _wanted -C name named-directories expl 'named directory' \
compadd -q -S '=' - "${(@k)nameddirs}" compadd -q -S '=' -k nameddirs
fi fi
elif compset -P 1 '*='; then elif compset -P 1 '*='; then
_wanted -C value values expl 'executable file' _files -g '*(-*)' _wanted -C value values expl 'executable file' _files -g '*(-*)'
else 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
fi fi

View file

@ -38,4 +38,4 @@ else
fi fi
_wanted -V directory-stack expl 'directory stack' \ _wanted -V directory-stack expl 'directory stack' \
compadd "$@" "$disp[@]" -Q - "$list[@]" compadd "$@" "$disp[@]" -Q -a list

View file

@ -7,8 +7,8 @@ _arguments -C -s \
'(-d -f *)-a[remove aliases]:*:aliases:_aliases' \ '(-d -f *)-a[remove aliases]:*:aliases:_aliases' \
'(-d -a *)-f[remove functions]:*:functions:_functions' \ '(-d -a *)-f[remove functions]:*:functions:_functions' \
'-m[treat arguments as patterns]' \ '-m[treat arguments as patterns]' \
'*:commands:_command_names -e' && return 0 '*:commands: _command_names -e' && return 0
if [[ "$state" = nameddir ]]; then if [[ "$state" = nameddir ]]; then
_wanted nameddir expl 'named directory' compadd - ${(@k)nameddirs} _wanted nameddir expl 'named directory' compadd -k nameddirs
fi fi

View file

@ -17,7 +17,7 @@ if [[ $PREFIX = *\[* ]]; then
local expl local expl
_wanted -C subscript association-keys expl 'association key' \ _wanted -C subscript association-keys expl 'association key' \
compadd $addclose - ${(kP)var} compadd $addclose -k "$var"
fi fi
else else
_parameters _parameters

View file

@ -28,10 +28,10 @@ if [[ "$state" = command ]]; then
args=( "$@" ) args=( "$@" )
_alternative -O args \ _alternative -O args \
'commands:external command:compadd - ${(k@)commands}' \ 'commands:external command:compadd -k commands' \
'builtins:builtin command:compadd - ${(k@)builtins}' \ 'builtins:builtin command:compadd -k builtins' \
'functions:shell function:compadd - ${(k@)functions}' \ 'functions:shell function:compadd -k functions' \
'aliases:alias:compadd - ${(k@)aliases}' \ 'aliases:alias:compadd -k aliases' \
'reserved-words:reserved word:compadd - ${(k@)reswords}' 'reserved-words:reserved word:compadd -k reswords'
fi fi

View file

@ -17,7 +17,7 @@ _arguments -C -s \
'*:function:->function' && return 0 '*:function:->function' && return 0
if (( $+opt_args[-c] )); then if (( $+opt_args[-c] )); then
_wanted functions expl 'function to write' compadd - ${(k)functions} _wanted functions expl 'function to write' compadd -k functions
else else
_description files expl 'zsh source file' _description files expl 'zsh source file'
_files "$expl[@]" _files "$expl[@]"

View file

@ -1,7 +1,10 @@
#defcomp zle #compdef zle
if [[ -word 1 -N && -position 3 ]]; then local expl
complist -F
if [[ "$words[2]" = -N && CURRENT -eq 3 ]]; then
_wanted -C -N functions expl 'widget shell function' \
compadd "$@" -k functions
else else
complist -b _wanted widgets expl widget compadd -k widgets
fi fi

View file

@ -1,9 +1,11 @@
#defcomp zmodload #compdef zmodload
if [[ -mword 1 -*(a*u|u*a)* || -mword 1 -*a* && -position 3 -1 ]]; then local fl="$words[2]" expl
complist -B
elif [[ -mword 1 -*u* ]]; then if [[ "$fl" = -*(a*u|u*a)* || "$fl" = -*a* && CURRENT -ge 4 ]]; then
complist -s '$(zmodload)' _wanted builtins expl 'builtin command' compadd "$@" -k builtins
elif [[ "$fl" = -*u* ]]; then
_wanted modules expl module compadd -k modules
else else
complist -s '${^module_path}/*(N:t:r)' _wanted files expl 'module file' _files -W module_path -/g '*.s[ol](:r)'
fi fi

View file

@ -49,9 +49,9 @@ if [[ $state = name ]]; then
names=( ${list%%:*} ) names=( ${list%%:*} )
if zstyle -T ":completion:${curcontext}" verbose; then if zstyle -T ":completion:${curcontext}" verbose; then
zformat -a list ' --' ${${(f)"$(zpty)"}#*\) } 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 else
_wanted names expl 'zpty command name' compadd - "$names[@]" _wanted names expl 'zpty command name' compadd -a names
fi fi
else else
return 1 return 1

View file

@ -151,7 +151,7 @@ while [[ -n $state ]]; do
completer) completer)
_wanted values expl completer \ _wanted values expl completer \
compadd _complete _approximate _correct _match \ compadd _complete _approximate _correct _match \
_expand _list _menu _oldlist _next_tags _expand _list _menu _oldlist _ignored _prefix _history
;; ;;
fsort) fsort)
@ -212,7 +212,7 @@ while [[ -n $state ]]; do
elif compset -P '*:'; then elif compset -P '*:'; then
_message 'tag alias' _message 'tag alias'
else else
_wanted tags expl tag compadd - $taglist _wanted tags expl tag compadd -a taglist
fi fi
;; ;;

View file

@ -28,12 +28,13 @@
setopt localoptions nullglob rcexpandparam extendedglob setopt localoptions nullglob rcexpandparam extendedglob
unsetopt markdirs globsubst shwordsplit nounset ksharrays unsetopt markdirs globsubst shwordsplit nounset ksharrays
local key=$KEYS[-1] local key=$KEYS[-1] expl
case $key in case $key in
'!') _main_complete _command_names '!') _main_complete _command_names
;; ;;
'$') compadd - "${(@k)parameters[(R)*export*]}" '$') _main_complete - _wanted parameters expl 'exported parameters' \
compadd - "${(@k)parameters[(R)*export*]}"
;; ;;
'@') _main_complete _hosts '@') _main_complete _hosts
;; ;;

View file

@ -70,7 +70,7 @@ _history_complete_word () {
} }
_history_complete_word_gen_matches () { _history_complete_word_gen_matches () {
local opt local opt h_words
[[ -n "$_hist_stop" ]] && PREFIX="$_hist_old_prefix" [[ -n "$_hist_stop" ]] && PREFIX="$_hist_old_prefix"
@ -85,8 +85,9 @@ _history_complete_word_gen_matches () {
opt="${opt}V" opt="${opt}V"
fi fi
h_words=( "${(@)historywords[2,-1]}" )
_wanted "$opt" history-words expl 'history word' \ _wanted "$opt" history-words expl 'history word' \
compadd -Q - "$historywords[@]" compadd -Q -a h_words
zstyle -t ":completion:${curcontext}:history-words" list || zstyle -t ":completion:${curcontext}:history-words" list ||
compstate[list]= compstate[list]=

View file

@ -1,43 +1,43 @@
#autoload #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 if [[ "$1" = - ]]; then
prev=- __prev=-
shift shift
fi fi
if [[ "$1" = -([12]|)[VJ] ]]; then if [[ "$1" = -([12]|)[VJ] ]]; then
gopt="$1" __gopt="$1"
shift shift
fi fi
tmp=${argv[(ib:4:)-]} __tmp=${argv[(ib:4:)-]}
len=$# __len=$#
if [[ tmp -lt len ]]; then if [[ __tmp -lt __len ]]; then
pre=$(( tmp-1 )) __pre=$(( __tmp-1 ))
suf=$tmp __suf=$__tmp
elif [[ tmp -eq $# ]]; then elif [[ __tmp -eq $# ]]; then
pre=-2 __pre=-2
suf=$(( len+1 )) __suf=$(( __len+1 ))
else else
pre=4 __pre=4
suf=5 __suf=5
fi fi
while comptags "-A$prev" "$1" curtag spec; do while comptags "-A$__prev" "$1" curtag __spec; do
_comp_tags="$_comp_tags $spec " _comp_tags="$_comp_tags $__spec "
if [[ "$curtag" = *:* ]]; then if [[ "$curtag" = *:* ]]; then
zformat -f descr "${curtag#*:}" "d:$3" zformat -f __descr "${curtag#*:}" "d:$3"
_description "$gopt" "${curtag%:*}" "$2" "$descr" _description "$__gopt" "${curtag%:*}" "$2" "$__descr"
curtag="${curtag%:*}" curtag="${curtag%:*}"
"$4" "${(P@)2}" "${(@)argv[5,-1]}" && ret=0 "$4" "${(P@)2}" "${(@)argv[5,-1]}" && __ret=0
else 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 fi
done done
return ret return __ret

View file

@ -104,7 +104,7 @@ if [[ -z "$compstate[insert]" ]] ;then
_description -V expansions expl expansions "o:$word" _description -V expansions expl expansions "o:$word"
fi fi
compadd "$expl[@]" -UQ -qS "$suf" - "$exp[@]" compadd "$expl[@]" -UQ -qS "$suf" -a exp
else else
_tags all-expansions expansions original _tags all-expansions expansions original
@ -142,8 +142,8 @@ else
normal=( "$normal[@]" "$i" ) normal=( "$normal[@]" "$i" )
fi fi
done done
(( $#dir )) && compadd "$expl[@]" -UQ -qS/ - "$dir[@]" (( $#dir )) && compadd "$expl[@]" -UQ -qS/ -a dir
(( $#normal )) && compadd "$expl[@]" -UQ -qS "$suf" - "$normal[@]" (( $#normal )) && compadd "$expl[@]" -UQ -qS "$suf" -a normal
fi fi
_requested original expl original && compadd "$expl[@]" -UQ - "$word" _requested original expl original && compadd "$expl[@]" -UQ - "$word"

View file

@ -17,7 +17,7 @@ if zstyle -T ":completion:${curcontext}" verbose && [[ -e /proc/$$/fd ]]; then
list=( ${list[@]} "$i -- $(ls -l /proc/$$/fd/$i|sed 's/.*-> //' )" ) list=( ${list[@]} "$i -- $(ls -l /proc/$$/fd/$i|sed 's/.*-> //' )" )
done done
fi fi
_wanted file-descriptors expl 'file descriptors' compadd "$@" -d list - "$fds[@]" _wanted file-descriptors expl 'file descriptors' compadd "$@" -d list -a fds
else else
_wanted file-descriptors expl 'file descriptors' compadd "$@" - "$fds[@]" _wanted file-descriptors expl 'file descriptors' compadd "$@" -a fds
fi fi

View file

@ -16,7 +16,7 @@
# remove /all/ duplicate matches rather than just # remove /all/ duplicate matches rather than just
# consecutives # consecutives
local opt expl local opt expl h_words
if zstyle -t ":completion:${curcontext}:" remove-all-dups; then if zstyle -t ":completion:${curcontext}:" remove-all-dups; then
opt=- opt=-
@ -32,5 +32,5 @@ fi
# We skip the first element of historywords so the current word doesn't # We skip the first element of historywords so the current word doesn't
# interfere with the completion # interfere with the completion
_wanted "$opt" history-words expl 'history word' \ h_words=( "${(@)historywords[2,-1]}" )
compadd -Q - "${(@)historywords[2,-1]}" _wanted "$opt" history-words expl 'history word' compadd -Q -a h_words

View file

@ -59,7 +59,7 @@ pref=''
# If the string from the line matches at least one of the strings, # If the string from the line matches at least one of the strings,
# we use only the matching 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[@]" ) (( $#tmp1 )) && matches=( "$tmp1[@]" )
@ -138,7 +138,7 @@ while true; do
PREFIX="$pre" PREFIX="$pre"
SUFFIX="$suf" 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 if [[ "$pre" = *${sep}* ]]; then
PREFIX="${cpre}${pre%%${sep}*}" PREFIX="${cpre}${pre%%${sep}*}"

View file

@ -1,21 +1,21 @@
#autoload #autoload
local gopt=-J descr spec local __gopt=-J __descr __spec
if [[ "$1" = -([12]|)[VJ] ]]; then if [[ "$1" = -([12]|)[VJ] ]]; then
gopt="$1" __gopt="$1"
shift shift
fi fi
if comptags -A "$1" curtag spec; then if comptags -A "$1" curtag __spec; then
_comp_tags="$_comp_tags $spec " _comp_tags="$_comp_tags $__spec "
if [[ "$curtag" = *:* ]]; then if [[ "$curtag" = *:* ]]; then
zformat -f descr "${curtag#*:}" "d:$3" zformat -f __descr "${curtag#*:}" "d:$3"
_description "$gopt" "${curtag%:*}" "$2" "$descr" _description "$__gopt" "${curtag%:*}" "$2" "$__descr"
curtag="${curtag%:*}" curtag="${curtag%:*}"
set -A $2 "${(P@)2}" "${(@)argv[4,-1]}" set -A $2 "${(P@)2}" "${(@)argv[4,-1]}"
else else
_description "$gopt" "$curtag" "$2" "$3" _description "$__gopt" "$curtag" "$2" "$3"
set -A $2 "${(@)argv[4,-1]}" "${(P@)2}" set -A $2 "${(@)argv[4,-1]}" "${(P@)2}"
fi fi

View file

@ -2,4 +2,7 @@
# This should be used to complete all option names. # 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

View file

@ -515,7 +515,7 @@ for prepath in "$prepaths[@]"; do
compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \ compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \
-W "$prepath$realpath$testpath" \ -W "$prepath$realpath$testpath" \
"$pfxsfx[@]" -M "r:|/=* r:|=*" \ "$pfxsfx[@]" -M "r:|/=* r:|=*" \
- "$tmp1[@]" -a tmp1
fi fi
else else
if [[ "$tmp3" = */* ]]; then if [[ "$tmp3" = */* ]]; then
@ -529,7 +529,7 @@ for prepath in "$prepaths[@]"; do
compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \ compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \
-W "$prepath$realpath$testpath" \ -W "$prepath$realpath$testpath" \
"$pfxsfx[@]" -M "r:|/=* r:|=*" \ "$pfxsfx[@]" -M "r:|/=* r:|=*" \
- "$tmp1[@]" -a tmp1
fi fi
fi fi
tmp4=- tmp4=-
@ -591,7 +591,7 @@ for prepath in "$prepaths[@]"; do
tmp4="$testpath" tmp4="$testpath"
compquote tmp4 tmp1 compquote tmp4 tmp1
compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -W "$prepath$realpath$testpath" \ compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -W "$prepath$realpath$testpath" \
"$pfxsfx[@]" -M "r:|/=* r:|=*" - "$tmp1[@]" "$pfxsfx[@]" -M "r:|/=* r:|=*" -a tmp1
fi fi
fi fi
done done
@ -605,7 +605,7 @@ if zstyle -t ":completion:${curcontext}:paths" expand prefix &&
"$exppaths" != "$eorig" ]]; then "$exppaths" != "$eorig" ]]; then
PREFIX="${opre}" PREFIX="${opre}"
SUFFIX="${osuf}" SUFFIX="${osuf}"
compadd -Q "$mopts[@]" -S '' -M "r:|/=* r:|=*" -p "$linepath" - "$exppaths[@]" compadd -Q "$mopts[@]" -S '' -M "r:|/=* r:|=*" -p "$linepath" -a exppaths
fi fi
[[ nm -ne compstate[nmatches] ]] [[ nm -ne compstate[nmatches] ]]

View file

@ -1,17 +1,17 @@
#autoload #autoload
local gopt=-J local __gopt=-J
if [[ "$1" = -([12]|)[VJ] ]]; then if [[ "$1" = -([12]|)[VJ] ]]; then
gopt="$1" __gopt="$1"
shift shift
fi fi
if comptags -R "$1"; then if comptags -R "$1"; then
if [[ $# -gt 3 ]]; then if [[ $# -gt 3 ]]; then
_all_labels - "$gopt" "$@" || return 1 _all_labels - "$__gopt" "$@" || return 1
elif [[ $# -gt 1 ]]; then elif [[ $# -gt 1 ]]; then
_description "$gopt" "$@" _description "$__gopt" "$@"
fi fi
return 0 return 0
else else

View file

@ -58,9 +58,9 @@ while [[ $# -gt 1 ]]; do
# Get the matching array elements. # Get the matching array elements.
PREFIX="${str%%(|\\)${sep}*}" PREFIX="${str%%(|\\)${sep}*}"
builtin compadd -O testarr - "${(@P)arr}" builtin compadd -O testarr -a "$arr"
[[ $#testarr -eq 0 && -n "$_comp_correct" ]] && [[ $#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 # If there are no matches we give up. If there is more than one
# match, this is the part we will complete. # match, this is the part we will complete.
@ -88,9 +88,9 @@ if [[ $# -le 1 || "$str" != *${2}* ]]; then
# No more separators, build the matches. # No more separators, build the matches.
PREFIX="$str" PREFIX="$str"
builtin compadd -O testarr - "${(@P)arr}" builtin compadd -O testarr -a "$arr"
[[ $#testarr -eq 0 && -n "$_comp_correct" ]] && [[ $#testarr -eq 0 && -n "$_comp_correct" ]] &&
compadd -O testarr - "${(@P)arr}" compadd -O testarr -a "$arr"
fi fi
[[ $#testarr -eq 0 || ${#testarr[1]} -eq 0 ]] && return 1 [[ $#testarr -eq 0 || ${#testarr[1]} -eq 0 ]] && return 1
@ -125,9 +125,9 @@ while [[ $# -gt 0 && "$str" == *${1}* ]]; do
arr=tmparr arr=tmparr
fi fi
builtin compadd -O tmparr - "${(@P)arr}" builtin compadd -O tmparr -a "$arr"
[[ $#tmparr -eq 0 && -n "$_comp_correct" ]] && [[ $#tmparr -eq 0 && -n "$_comp_correct" ]] &&
compadd -O tmparr - "${(@P)arr}" compadd -O tmparr - "$arr"
suffixes=("${(@)^suffixes[@]}${(q)1}${(@)^tmparr}") suffixes=("${(@)^suffixes[@]}${(q)1}${(@)^tmparr}")
@ -155,7 +155,7 @@ PREFIX="$pre"
SUFFIX="$suf" SUFFIX="$suf"
for i in "$suffixes[@]"; do for i in "$suffixes[@]"; do
compadd -U "$group[@]" "$expl[@]" "$matchers[@]" "$autosuffix[@]" "$opts[@]" \ 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 done
# This sets the return value to indicate that we added matches (or not). # This sets the return value to indicate that we added matches (or not).

View file

@ -4,4 +4,7 @@
# names of the options that were set when it was called in the array # names of the options that were set when it was called in the array
# `_set_options'. # `_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

View file

@ -4,4 +4,7 @@
# names of the options that were set when it was called in the array # names of the options that were set when it was called in the array
# `_set_options'. # `_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

View file

@ -1,26 +1,26 @@
#autoload #autoload
local targs gopt=-J local __targs __gopt=-J
if [[ "$1" = -C?* ]]; then if [[ "$1" = -C?* ]]; then
targs=( -C "${1[3,-1]}" ) __targs=( -C "${1[3,-1]}" )
shift shift
elif [[ "$1" = -C ]]; then elif [[ "$1" = -C ]]; then
targs=( -C "$2" ) __targs=( -C "$2" )
shift 2 shift 2
else else
targs=() __targs=()
fi fi
if [[ "$1" = -([12]|)[VJ] ]]; then if [[ "$1" = -([12]|)[VJ] ]]; then
gopt="$1" __gopt="$1"
shift shift
fi fi
_tags "$targs[@]" "$1" _tags "$__targs[@]" "$1"
while _tags; do while _tags; do
_all_labels "$gopt" "$@" && return 0 _all_labels "$__gopt" "$@" && return 0
done done
return 1 return 1

View file

@ -26,7 +26,7 @@ case "$state" in
serverhost) serverhost)
: ${(A)archie_servers:=${(M)$(_call hosts archie -L):#archie.*}} : ${(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 esac

View file

@ -49,7 +49,7 @@ _cvs_command () {
watchers "") watchers "")
if (( CURRENT == 1 )); then if (( CURRENT == 1 )); then
_tags commands && { compadd "$@" ${(k)cmds} || compadd "$@" ${(kv)=cmds} } _tags commands && { compadd "$@" -k cmds || compadd "$@" ${(kv)=cmds} }
else else
local curcontext="$curcontext" local curcontext="$curcontext"
@ -584,7 +584,7 @@ _cvs_root () {
fi fi
_tags files && { _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
fi fi
if (( $#_cvs_modules_cache )); then 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 else
_message 'module name' _message 'module name'
fi fi
@ -683,7 +683,7 @@ _cvs_revisions () {
fi fi
if (( $#_cvs_revisions_cache )); then if (( $#_cvs_revisions_cache )); then
_wanted values expl revision compadd - $_cvs_revisions_cache _wanted values expl revision compadd -a _cvs_revisions_cache
else else
_message revision _message revision
fi fi
@ -813,7 +813,7 @@ _cvs_nonexisting_entries () {
${${${${(M)${(f)"$(<"$realdir"CVS/Entries)"}:#(D|)/*}#(D|)/}%%/*}:#${(j:|:)~${files//(#m)[][*?()<|^~#\\]/\\$MATCH}}} ${${${${(M)${(f)"$(<"$realdir"CVS/Entries)"}:#(D|)/*}#(D|)/}%%/*}:#${(j:|:)~${files//(#m)[][*?()<|^~#\\]/\\$MATCH}}}
) )
compquote files compquote files
_wanted files expl file compadd -Qp "$linedir" $files _wanted files expl file compadd -Qp -a linedir files
} }
} }

View file

@ -2,7 +2,7 @@
local expl domains tmp 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 if (( ! $+_cache_domains )); then
_cache_domains=() _cache_domains=()
if [[ -f /etc/resolv.conf ]]; then if [[ -f /etc/resolv.conf ]]; then
@ -10,11 +10,11 @@ if ! zstyle -a ":completion${curcontext}:domains" domains domains; then
[[ "$tmp" = (domain|search)* ]] && [[ "$tmp" = (domain|search)* ]] &&
_cache_domains=( "$_cache_domains[@]" "${=${tmp%%[ ]#}#*[ ]}" ) _cache_domains=( "$_cache_domains[@]" "${=${tmp%%[ ]#}#*[ ]}" )
done < /etc/resolv.conf done < /etc/resolv.conf
_cache_domains=( "${(@)_nslookup_domains:#[ ]#}" ) _cache_domains=( "${(@)_cache_domains:#[ ]#}" )
fi fi
fi fi
domains=( "$_cache_domains[@]" ) domains=( "$_cache_domains[@]" )
fi fi
_wanted domains expl domain && _wanted domains expl domain \
compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" "$expl[@]" - "$domains[@]" compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" -a domains

View file

@ -49,7 +49,7 @@ if [[ -n "$state" ]]; then
expl=function expl=function
fi fi
_wanted functions expl "$expl" \ _wanted functions expl "$expl" \
compadd -M 'r:|_=* r:|=*' - "$_gprof_funcs[@]" && ret=0 compadd -M 'r:|_=* r:|=*' -a _gprof_funcs && ret=0
else else
return 1 return 1
fi fi

View file

@ -16,4 +16,4 @@ if ! zstyle -a ":completion:${curcontext}:" groups groups; then
groups=( "$_cache_groups[@]" ) groups=( "$_cache_groups[@]" )
fi fi
_wanted groups expl group compadd "$@" - "$groups[@]" _wanted groups expl group compadd "$@" -a groups

View file

@ -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

View file

@ -26,7 +26,7 @@ else
else else
disp=() disp=()
fi fi
_all_labels users expl user compadd "$disp[@]" - "$strs[@]" || _all_labels users expl user compadd "$disp[@]" -a strs ||
_users && ret=0 _users && ret=0
fi fi
if _requested jobs; then if _requested jobs; then
@ -38,7 +38,7 @@ else
else else
disp=() disp=()
fi fi
_all_labels jobs expl job compadd "$disp[@]" - "$strs[@]" && ret=0 _all_labels jobs expl job compadd "$disp[@]" -a strs && ret=0
fi fi
(( ret )) || return 0 (( ret )) || return 0
done done

View file

@ -1,32 +1,164 @@
#autoload #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] case "${curcontext}" in
test -f "$compconfig[maildirectory]" && maildirectory=$compconfig[maildirectory] (*: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}/*(^/)) return 1
dirboxes=(${~maildirectory}/*(/)) }
for i in $dirboxes _mailbox_cache () {
do # Depends on $maildirectory and $pinedirectory from _mailboxes!
if test -d "${i}/cur"
then
maildirboxes=($maildirboxes $i)
else
MHboxes=($MHboxes $i)
fi
done
_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 "$@"

View file

@ -42,7 +42,7 @@ else
FS=: $file) FS=: $file)
) )
fi fi
_wanted targets expl 'make target' compadd "$tmp[@]" && return 0 _wanted targets expl 'make target' compadd -a tmp && return 0
fi fi
compset -P 1 '*=' compset -P 1 '*='
_files _files

View file

@ -540,7 +540,7 @@ fstype)
compset -P '*,' compset -P '*,'
_wanted types expl 'file system type' \ _wanted types expl 'file system type' \
compadd -qS, -M 'L:|no=' - "$fss[@]" && ret=0 compadd -qS, -M 'L:|no=' -a fss && ret=0
;; ;;
fsopt) fsopt)
_tags options || return 1 _tags options || return 1
@ -569,8 +569,8 @@ udevordir)
mp_tmp=( "${(@)${(@)tmp#* }%% *}" ) mp_tmp=( "${(@)${(@)tmp#* }%% *}" )
_alternative \ _alternative \
'devices:device:compadd - $dev_tmp[@]' \ 'devices:device:compadd -a dev_tmp' \
'directories:mount point:compadd - $mp_tmp[@]' && ret=0 'directories:mount point:compadd -a mp_tmp' && ret=0
fi fi
;; ;;
esac esac

View file

@ -64,7 +64,7 @@ _mysql_databases () {
) )
shift _mysql_databases shift _mysql_databases
compadd "$expl[@]" - $_mysql_databases compadd "$expl[@]" -a _mysql_databases
} }
_mysql_tables () { _mysql_tables () {
@ -79,7 +79,7 @@ _mysql_tables () {
# remove header # remove header
shift _mysql_tables shift _mysql_tables
compadd "$expl[@]" - $_mysql_tables compadd "$expl[@]" -a _mysql_tables
} }
_mysql_variables () { _mysql_variables () {
@ -205,7 +205,7 @@ _mysqladmin_commands () {
) )
if (( CURRENT == 1 )); then if (( CURRENT == 1 )); then
_wanted commands expl command compadd "$@" - $cmds _wanted commands expl command compadd "$@" -a cmds
else else
local curcontext="$curcontext" local curcontext="$curcontext"

View file

@ -62,8 +62,8 @@ if [[ "$state" = "remote" ]]; then
*) *)
compset -S '(|\\)\(*' || suf="${${QIPREFIX:+(}:-\(}" compset -S '(|\\)\(*' || suf="${${QIPREFIX:+(}:-\(}"
_wanted commands expl 'remote commands' \ _wanted commands expl 'remote commands' \
compadd -qS "$suf" -M 'm:{a-zA-Z}={A-Za-z}' - \ compadd -qS "$suf" -M 'm:{a-zA-Z}={A-Za-z}' -a \
$remote_commands && ret=0 remote_commands && ret=0
;; ;;
esac esac
fi fi

View file

@ -59,7 +59,7 @@ _perl_config_vars () {
(( compstate[quoting] )) && delimiter=' ' (( compstate[quoting] )) && delimiter=' '
compset -P '* ' && compset -q 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 "$@" _perl "$@"

View file

@ -29,4 +29,4 @@ fi
local expl local expl
_wanted pods expl 'Perl base pods' compadd - $_perl_basepods _wanted pods expl 'Perl base pods' compadd -a _perl_basepods

View file

@ -12,13 +12,13 @@ if [[ ${+_perl_builtin_funcs} -eq 0 ]]; then
typeset -agU _perl_builtin_funcs typeset -agU _perl_builtin_funcs
local perlfunc 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 ' _perl_builtin_funcs=( `perl -lne '
$in_funcs++, next if /Alphabetical/; \ $in_funcs++, next if /Alphabetical/; \
next unless $in_funcs; \ next unless $in_funcs; \
if (/^\.Ip "(\w+)/) { \ if (/^\.Ip "(\w+)/) { \
print $1 unless $func{$1}; $func{$1}++ \ print $1 unless $func{$1}; $func{$1}++ \
}' $perlfunc` }' $=perlfunc`
) )
else else
echo "Couldn't find perlfunc man page; giving up." echo "Couldn't find perlfunc man page; giving up."
@ -26,4 +26,6 @@ if [[ ${+_perl_builtin_funcs} -eq 0 ]]; then
fi fi
fi fi
compadd - $_perl_builtin_funcs local expl
_wanted functions expl 'Perl built-in functions' compadd -a _perl_builtin_funcs

View file

@ -62,4 +62,4 @@ fi
local expl local expl
_wanted modules expl 'Perl modules' compadd "$opts[@]" - $_perl_modules _wanted modules expl 'Perl modules' compadd "$opts[@]" -a _perl_modules

View file

@ -1,8 +1,12 @@
#autoload #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 ports=( "$_cache_ports[@]" )
compadd "$@" "$expl[@]" - "$ports[@]" fi
_wanted ports expl port compadd "$@" -a ports

View file

@ -8,5 +8,5 @@ if [[ $compstate[nmatches] -eq nm && -d RCS && $cmd != ci ]]; then
local rep expl local rep expl
rep=(RCS/$PREFIX*$SUFFIX,v(:t:s/\,v//)) 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 fi

View file

@ -124,7 +124,7 @@ if ! compset -P '(#b)([^/]#)/'; then
compset -S '/*' || suf="/" compset -S '/*' || suf="/"
(( $#uhosts )) || _hosts -S "$suf" "$expl[@]" && ret=0 (( $#uhosts )) || _hosts -S "$suf" "$expl[@]" && ret=0
[[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername) [[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername)
compadd -S "$suf" "$expl[@]" - $uhosts && ret=0 compadd -S "$suf" "$expl[@]" -a uhosts && ret=0
done done
(( ret )) || return 0 (( ret )) || return 0
done done

View file

@ -3,6 +3,6 @@
local expl users local expl users
zstyle -a ":completion:${curcontext}:" users 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

View file

@ -96,10 +96,10 @@ if [[ "$state" = map* ]]; then
while _tags; do while _tags; do
# The `-M ...' allows `pa.n<TAB>' to complete to `passwd.byname'. # The `-M ...' allows `pa.n<TAB>' to complete to `passwd.byname'.
_requested maps expl 'map name' \ _requested maps expl 'map name' \
compadd -M 'l:.|by=by l:.|=by r:|.=* r:|=*' - \ compadd -M 'l:.|by=by l:.|=by r:|.=* r:|=*' -a \
"$_yp_cache_maps[@]" && ret=0 _yp_cache_maps && ret=0
_requested nicknames expl nicknames \ _requested nicknames expl nicknames \
compadd - "$_yp_cache_nicks[@]" && ret=0 compadd -a _yp_cache_nicks && ret=0
(( ret )) || return 0 (( ret )) || return 0
done done
elif [[ "$state" = servers ]]; then elif [[ "$state" = servers ]]; then

View file

@ -31,5 +31,5 @@ if (( ! $+_color_cache )); then
fi fi
_wanted colors expl 'color specification' \ _wanted colors expl 'color specification' \
compadd "$@" -M 'm:{a-z}={A-Z} m:-=\ r:[^ A-Z0-9]||[ A-Z0-9]=* r:|=*' - \ compadd "$@" -M 'm:{a-z}={A-Z} m:-=\ r:[^ A-Z0-9]||[ A-Z0-9]=* r:|=*' -a \
"$_color_cache[@]" _color_cache

View file

@ -14,5 +14,5 @@ if (( ! $+_cursor_cache )); then
fi fi
fi fi
_description expl 'cursor name' _wanted cursors expl 'cursor name' \
compadd "$@" "$expl[@]" -M 'm:-=_ r:|_=*' - "$_cursor_cache[@]" compadd "$@" -M 'm:-=_ r:|_=*' -a _cursor_cache

View file

@ -15,5 +15,5 @@ else
[[ "$1" = - ]] && shift [[ "$1" = - ]] && shift
_wanted extensions expl 'X extensions' \ _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 fi

View file

@ -13,4 +13,4 @@ if (( ! $+_font_cache )); then
fi fi
_wanted fonts expl font \ _wanted fonts expl font \
compadd -M 'r:|-=* r:|=*' "$@" -S '' - "$_font_cache[@]" compadd -M 'r:|-=* r:|=*' "$@" -S '' -a _font_cache

View file

@ -19,4 +19,4 @@ if (( ! $+_keysym_cache )); then
fi fi
_wanted keysyms expl 'key symbol' \ _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

View file

@ -73,7 +73,7 @@ xhost)
_tags displays _tags displays
while _tags; do while _tags; do
while _next_label displays expl 'disallow access'; 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 _hosts "$expl[@]" } && ret=0
done done
(( ret )) || return 0 (( ret )) || return 0