diff options
Diffstat (limited to 'Completion/Base')
-rw-r--r-- | Completion/Base/_brace_parameter | 6 | ||||
-rw-r--r-- | Completion/Base/_condition | 59 | ||||
-rw-r--r-- | Completion/Base/_default | 2 | ||||
-rw-r--r-- | Completion/Base/_describe | 45 | ||||
-rw-r--r-- | Completion/Base/_first | 25 | ||||
-rw-r--r-- | Completion/Base/_jobs | 6 | ||||
-rw-r--r-- | Completion/Base/_values | 2 |
7 files changed, 97 insertions, 48 deletions
diff --git a/Completion/Base/_brace_parameter b/Completion/Base/_brace_parameter index 092376e78..fde6d4f0f 100644 --- a/Completion/Base/_brace_parameter +++ b/Completion/Base/_brace_parameter @@ -1,5 +1,3 @@ -#defcomp -brace-parameter- +#compdef -brace-parameter- -# Simple but without spiffy suffix handling: compgen -v -S '} ' - -compadd -S '} ' -r '-:?#%+=[/' - "${(@)${${${(f)$(typeset)}%%\=*}##* }:gs/'//}" +_parameters -e diff --git a/Completion/Base/_condition b/Completion/Base/_condition index 3e45e1b8f..b6a4eff7a 100644 --- a/Completion/Base/_condition +++ b/Completion/Base/_condition @@ -1,10 +1,55 @@ -#defcomp -condition- +#compdef -condition- -if [[ -current -1 -o ]]; then - complist -o -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' -elif [[ -current -1 -nt || -current -1 -ot || -current -1 -ef ]]; then - _files +local prev="$words[CURRENT-1]" ret=1 + +if [[ "$prev" = -o ]]; then + _tags -C -o options && _options +elif [[ "$prev" = -([a-hkprsuwxLOGSN]|[no]t|ef) ]]; then + _tags -C "$prev" files && _files else - _files - complist -v + if [[ "$PREFIX" = -* ]] || + ! zstyle -T ":completion:${curcontext}:options" prefix-needed; then + + if [[ "$prev" = (\[\[|\|\||\&\&|\!|\() ]]; then + _describe -o 'condition code' \ + '( -a:existing\ file + -b:block\ special\ file + -c:character\ special\ file + -d:directory + -e:existing\ file + -f:regular\ file + -g:setgid\ bit + -h:symbolic\ link + -k:sticky\ bit + -n:non-empty\ string + -o:option + -p:named\ pipe + -r:readable\ file + -s:non-empty\ file + -t:terminal\ file\ descriptor + -u:setuid\ bit + -w:writable\ file + -x:executable\ file + -z:empty\ string + -L:symbolic\ link + -O:own\ file + -G:group-owned\ file + -S:socket + -N:unread\ file)' && ret=0 + else + _describe -o 'condition code' \ + '( -nt:newer\ than + -ot:older\ than + -ef:same\ file + -eq:numerically\ equal + -ne:numerically\ not\ equal + -lt:numerically\ less\ than + -le:numerically\ less\ then\ or\ equal + -lt:numerically\ greater\ than + -le:numerically\ greater\ then\ or\ equal)' && ret=0 + fi + fi + _alternative 'files:: _files' 'parameters:: _parameters' && ret=0 + + return ret fi diff --git a/Completion/Base/_default b/Completion/Base/_default index fd5869e2e..e5091a544 100644 --- a/Completion/Base/_default +++ b/Completion/Base/_default @@ -12,8 +12,6 @@ if { zstyle -s ":completion:${curcontext}:" use-compctl ctl || compcall "$opt[@]" || return 0 fi -_wanted files || return 1 - _files && return 0 # magicequalsubst allows arguments like <any-old-stuff>=~/foo to do diff --git a/Completion/Base/_describe b/Completion/Base/_describe index 6e6f4f4a9..ca2d3e4cf 100644 --- a/Completion/Base/_describe +++ b/Completion/Base/_describe @@ -14,8 +14,6 @@ fi # Do the tests. `showd' is set if the descriptions should be shown. -_wanted "$_type" || return 1 - zstyle -T ":completion:${curcontext}:$_type" verbose && _showd=yes _descr="$1" @@ -24,30 +22,35 @@ shift [[ "$_type" = options ]] && zstyle -t ":completion:${curcontext}:options" prefix-hidden && _hide=yes -while _next_label "$_type" _expl "$_descr"; do +_tags "$_type" +while _tags; do + while _next_label "$_type" _expl "$_descr"; do - if [[ -n "$_showd" ]]; then - compdescribe -I ' -- ' "$@" - else - compdescribe -i "$@" - fi + if [[ -n "$_showd" ]]; then + compdescribe -I ' -- ' "$@" + else + compdescribe -i "$@" + fi - while compdescribe -g _args _tmpd _tmpmd _tmps _tmpms; do + while compdescribe -g _args _tmpd _tmpmd _tmps _tmpms; do - # See if we should remove the option prefix characters. + # See if we should remove the option prefix characters. - if [[ -n "$_hide" ]]; then - if [[ "$PREFIX" = --* ]]; then - _tmpd=( "${(@)_tmpd#--}" ) - _tmps=( "${(@)_tmps#--}" ) - elif [[ "$PREFIX" = [-+]* ]]; then - _tmpd=( "${(@)_tmpd#[-+]}" ) - _tmps=( "${(@)_tmps#[-+]}" ) + if [[ -n "$_hide" ]]; then + if [[ "$PREFIX" = --* ]]; then + _tmpd=( "${(@)_tmpd#--}" ) + _tmps=( "${(@)_tmps#--}" ) + elif [[ "$PREFIX" = [-+]* ]]; then + _tmpd=( "${(@)_tmpd#[-+]}" ) + _tmps=( "${(@)_tmps#[-+]}" ) + fi fi - fi - compadd "$_args[@]" "$_expl[@]" -ld _tmpd - "$_tmpmd[@]" && _ret=0 - compadd "$_args[@]" "$_expl[@]" -d _tmps - "$_tmpms[@]" && _ret=0 + compadd "$_args[@]" "$_expl[@]" -ld _tmpd - "$_tmpmd[@]" && _ret=0 + compadd "$_args[@]" "$_expl[@]" -d _tmps - "$_tmpms[@]" && _ret=0 + done done + (( _ret )) || return 0 done -return _ret + +return 1 diff --git a/Completion/Base/_first b/Completion/Base/_first index d9e7ee82c..93602f307 100644 --- a/Completion/Base/_first +++ b/Completion/Base/_first @@ -35,28 +35,35 @@ # and hitting TAB. # # if [[ "$PREFIX" = *,, ]]; then -# local max i=1 +# local max i=1 expl opt # # PREFIX="$PREFIX[1,-2]" # # If a numeric prefix is given, we use it as the number of # # lines (multiplied by ten below) in the history to search. -# if [[ NUMERIC -gt 1 ]]; then +# if [[ ${NUMERIC:-1} -gt 1 ]]; then # max=$NUMERIC -# NUMERIC=1 +# unset NUMERIC # else # # The default is to search the last 100 lines. # max=10 # fi -# # We first search in the last ten lines, then in the last -# # twenty lines, and so on... +# # We first search in the last ten words, then in the last +# # twenty words, and so on... # while [[ i -le max ]]; do -# if compgen -X "%Bhistory ($n):%b" -Q -H $(( i*10 )) ''; then +# if zstyle -t ":completion:${curcontext}:history-words" sort; then +# opt=-J +# else +# opt=-V +# fi +# if _wanted "$opt" history-words expl "history ($n)" \ +# compadd "$expl[@]" -Q - \ +# "${(@)${(@)historywords:#[\$'\"]*}[1,i*10]}"; then # # We have found at least one matching word, so we switch # # on menu-completion and make sure that no other -# # completion function is called by setting _comp_skip. +# # completion function is called by setting _compskip. # compstate[insert]=menu -# _comp_skip=1 -# return +# _compskip=all +# return 0 # fi # (( i++ )) # done diff --git a/Completion/Base/_jobs b/Completion/Base/_jobs index 45983ad16..359cf0905 100644 --- a/Completion/Base/_jobs +++ b/Completion/Base/_jobs @@ -2,8 +2,6 @@ local expl disp jobs job jids pfx='%' desc how expls -_wanted jobs || return 1 - if [[ "$1" = -t ]]; then zstyle -T ":completion:${curcontext}:jobs" prefix-needed && [[ "$PREFIX" != %* && compstate[nmatches] -ne 0 ]] && return 1 @@ -79,7 +77,7 @@ else fi if [[ -n "$desc" ]]; then - _all_labels jobs expl "$expls" compadd "$@" -ld disp - "%$^jobs[@]" + _wanted jobs expl "$expls" compadd "$@" -ld disp - "%$^jobs[@]" else - _all_labels jobs expl "$expls" compadd "$@" - "%$^jobs[@]" + _wanted jobs expl "$expls" compadd "$@" - "%$^jobs[@]" fi diff --git a/Completion/Base/_values b/Completion/Base/_values index eff7b94ce..39c8df201 100644 --- a/Completion/Base/_values +++ b/Completion/Base/_values @@ -18,7 +18,7 @@ if compvalues -i "$@"; then if ! compvalues -D descr action; then - _wanted values || return 1 + _tags values || return 1 curcontext="${oldcontext%:*}:values" |