diff options
author | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-04-11 07:57:56 +0000 |
---|---|---|
committer | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2000-04-11 07:57:56 +0000 |
commit | fac3086d9782e73dcaf1aa65fd36a0b63a374719 (patch) | |
tree | 7bab35e2787ca17f02ec932dffae1bfff2ffcfe3 /Completion/Builtins | |
parent | 37012f06a7e5e8a64614dbf9032c77cff1bcfcfb (diff) | |
download | zsh-fac3086d9782e73dcaf1aa65fd36a0b63a374719.tar.gz zsh-fac3086d9782e73dcaf1aa65fd36a0b63a374719.tar.xz zsh-fac3086d9782e73dcaf1aa65fd36a0b63a374719.zip |
_wanted now tests both tags and labels; change places where _wanted was called without a command; allow multiple patterns per string in file-patterns; update _next_tags to work with labels (10632)
Diffstat (limited to 'Completion/Builtins')
-rw-r--r-- | Completion/Builtins/_compdef | 16 | ||||
-rw-r--r-- | Completion/Builtins/_hash | 19 | ||||
-rw-r--r-- | Completion/Builtins/_pids | 4 | ||||
-rw-r--r-- | Completion/Builtins/_popd | 4 | ||||
-rw-r--r-- | Completion/Builtins/_sched | 4 | ||||
-rw-r--r-- | Completion/Builtins/_signals | 9 | ||||
-rw-r--r-- | Completion/Builtins/_vars | 12 | ||||
-rw-r--r-- | Completion/Builtins/_zcompile | 3 | ||||
-rw-r--r-- | Completion/Builtins/_zftp | 15 | ||||
-rw-r--r-- | Completion/Builtins/_zpty | 6 | ||||
-rw-r--r-- | Completion/Builtins/_zstyle | 26 |
11 files changed, 54 insertions, 64 deletions
diff --git a/Completion/Builtins/_compdef b/Completion/Builtins/_compdef index d47a560c9..6287810e5 100644 --- a/Completion/Builtins/_compdef +++ b/Completion/Builtins/_compdef @@ -19,15 +19,13 @@ case $state in _wanted commands expl 'completed command' compadd - ${(k)_comps} ;; cfun) - if _wanted functions; then - list=( ${^fpath:/.}/_(|*[^~])(N:t) ) - if zstyle -T ":completion:${curcontext}:functions" prefix-hidden; then - disp=( ${list[@]#_} ) - _all_labels functions expl 'completion function' \ - compadd -d disp - "$list[@]" - else - _all_labels functions expl 'completion function' compadd - "$list[@]" - fi + list=( ${^fpath:/.}/_(|*[^~])(N:t) ) + if zstyle -T ":completion:${curcontext}:functions" prefix-hidden; then + disp=( ${list[@]#_} ) + _wanted functions expl 'completion function' \ + compadd -d disp - "$list[@]" + else + _wanted functions expl 'completion function' compadd - "$list[@]" fi ;; style) diff --git a/Completion/Builtins/_hash b/Completion/Builtins/_hash index 171c5e2e8..c577fc4d7 100644 --- a/Completion/Builtins/_hash +++ b/Completion/Builtins/_hash @@ -1,13 +1,16 @@ -#defcomp hash +#compdef hash -if [[ -mword 1 -*d* ]]; then - if [[ -string 1 '=' ]]; then - _path_files -g '*(-/)' +local expl + +if [[ "$words[2]" = -*d* ]]; then + if compset -P 1 '*='; then + _wanted -C -d-value files expl directories _path_files -/ else - complist -n -q -S '=' + _wanted -C -d named-directories expl 'named directory' \ + compadd -q -S '=' - "${(@k)nameddirs}" fi -elif [[ -string 1 '=' ]]; then - _files -/g '*(*)' +elif compset -P 1 '*='; then + _wanted -C value values expl 'executable file' _files "$expl[@]" -g '*(-*)' else - complist -m -q -S '=' + _wanted -C name commands expl command compadd -q -S '=' - "${(@k)commands}" fi diff --git a/Completion/Builtins/_pids b/Completion/Builtins/_pids index 7dec90e7d..1d02f5530 100644 --- a/Completion/Builtins/_pids +++ b/Completion/Builtins/_pids @@ -5,7 +5,7 @@ local out list expl match desc listargs args -_wanted processes || return 1 +_tags processes || return 1 if [[ "$1" = -m ]]; then match="${2}*" @@ -29,6 +29,6 @@ else desc=() fi -_all_labels processes expl 'process ID' \ +_wanted processes expl 'process ID' \ compadd "$@" "$desc[@]" - \ ${${${(M)${(f)"${out}"}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]#*${~match}}## #}%% *} diff --git a/Completion/Builtins/_popd b/Completion/Builtins/_popd index 2a3413253..19b773173 100644 --- a/Completion/Builtins/_popd +++ b/Completion/Builtins/_popd @@ -12,8 +12,6 @@ local expl list lines revlines disp ! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed || [[ $PREFIX = [-+]* ]] || return 1 -_wanted directory-stack || return 1 - if zstyle -T ":completion:${curcontext}:directory-stack" verbose; then # get the list of directories with their canonical number # and turn the lines into an array, removing the current directory @@ -39,5 +37,5 @@ else disp=() fi -_all_labels -V directory-stack expl 'directory stack' \ +_wanted -V directory-stack expl 'directory stack' \ compadd "$@" "$disp[@]" -Q - "$list[@]" diff --git a/Completion/Builtins/_sched b/Completion/Builtins/_sched index 98ecb3642..82b8a7c91 100644 --- a/Completion/Builtins/_sched +++ b/Completion/Builtins/_sched @@ -4,15 +4,13 @@ local expl lines disp if [[ CURRENT -eq 2 ]]; then if compset -P -; then - _wanted -C - jobs || return 1 - lines=(${(f)"$(sched)"}) if zstyle -T ":completion:${curcontext}:jobs" verbose; then disp=( -ld lines ) else disp=() fi - [[ -z $lines ]] || _all_labels jobs expl 'scheduled jobs' \ + [[ -z $lines ]] || _wanted jobs expl 'scheduled jobs' \ compadd "$disp[@]" - {1..$#lines} return else diff --git a/Completion/Builtins/_signals b/Completion/Builtins/_signals index aa95a8499..447d9d16c 100644 --- a/Completion/Builtins/_signals +++ b/Completion/Builtins/_signals @@ -20,10 +20,9 @@ done [[ "$1" = -(|-) ]] && shift -if _wanted signals && - { [[ -z "$minus" ]] || - ! zstyle -T ":completion:${curcontext}:signals" prefix-needed || - [[ "$PREFIX" = -* ]] } ; then +if [[ -z "$minus" ]] || + ! zstyle -T ":completion:${curcontext}:signals" prefix-needed || + [[ "$PREFIX" = -* ]]; then local disp tmp if zstyle -t ":completion:${curcontext}:signals" prefix-hidden; then @@ -32,7 +31,7 @@ if _wanted signals && else disp=() fi - _all_labels signals expl signal \ + _wanted signals expl signal \ compadd "$@" "$disp[@]" -M 'm:{a-z}={A-Z}' - \ "${minus}${(@)^signals[1,last]}" fi diff --git a/Completion/Builtins/_vars b/Completion/Builtins/_vars index 43cdf5d2c..711a0a1f2 100644 --- a/Completion/Builtins/_vars +++ b/Completion/Builtins/_vars @@ -1,8 +1,8 @@ #compdef getopts read unset vared # This will handle completion of keys of associative arrays, e.g. at -# `vared compconfig[<TAB>'. However, in this version the [ must be -# added by hand. +# `vared foo[<TAB>'. However, in this version the [ must be added +# by hand. if [[ $PREFIX = *\[* ]]; then local var=${PREFIX%%\[*} @@ -16,13 +16,9 @@ if [[ $PREFIX = *\[* ]]; then if [[ ${(tP)var} = assoc* ]]; then local expl - _tags subscript association-keys || return 1 - - _description expl 'association key' - compadd "$expl[@]" $addclose - ${(kP)var} + _wanted -C subscript association-keys expl 'association key' \ + compadd $addclose - ${(kP)var} fi else - _tags any parameters || return 1 - _parameters fi diff --git a/Completion/Builtins/_zcompile b/Completion/Builtins/_zcompile index 5ec6f96ce..c82226dc2 100644 --- a/Completion/Builtins/_zcompile +++ b/Completion/Builtins/_zcompile @@ -18,5 +18,6 @@ _arguments -s \ if (( $+opt_args[-c] )); then _wanted functions expl 'function to write' compadd - ${(k)functions} else - _wanted file expl 'zsh source file' _files + _description files expl 'zsh source file' + _files "$expl[@]" fi diff --git a/Completion/Builtins/_zftp b/Completion/Builtins/_zftp index 0d6530dfc..610af2607 100644 --- a/Completion/Builtins/_zftp +++ b/Completion/Builtins/_zftp @@ -28,35 +28,34 @@ fi case $subcom in *(cd|ls|dir)) # complete remote directories - _wanted directories && zfcd_match $PREFIX $SUFFIX + _tags directories && zfcd_match $PREFIX $SUFFIX ;; *(get(|at)|gcp|delete|remote)) # complete remote files - _wanted files && zfget_match $PREFIX $SUFFIX + _tags files && zfget_match $PREFIX $SUFFIX ;; *(put(|at)|pcp)) # complete local files - _wanted files && _files + _files ;; *(open|anon|params)) # complete hosts: should do cleverer stuff with user names - _wanted hosts && _hosts + _hosts ;; *(goto|mark)) # complete bookmarks. First decide if ncftp mode is go. - _wanted bookmarks || return 1 if [[ $words[2] = -*n* ]]; then if [[ -f ~/.ncftp/bookmarks ]]; then - _all_labels bookmarks expl bookmark \ + _wanted bookmarks expl bookmark \ compadd - $(awk -F, 'NR > 2 { print $1 }' ~/.ncftp/bookmarks) fi else if [[ -f ${ZFTP_BMFILE:=${ZDOTDIR:-$HOME}/.zfbkmarks} ]]; then - _all_labels bookmarks expl bookmark \ + _wanted bookmarks expl bookmark \ compadd - $(awk '{print $1}' $ZFTP_BMFILE) fi fi @@ -72,7 +71,7 @@ case $subcom in # complete arguments like sess1:file1 sess2:file2 if [[ $PREFIX = *:* ]]; then # complete file in the given session - _wanted files || return 1 + _tags files || return 1 local sess=${PREFIX%%:*} oldsess=$ZFTP_SESSION compset -p $(( $#sess + 1 )) [[ -n $sess ]] && zftp session $sess diff --git a/Completion/Builtins/_zpty b/Completion/Builtins/_zpty index d8c77ff2e..ac631baf4 100644 --- a/Completion/Builtins/_zpty +++ b/Completion/Builtins/_zpty @@ -11,13 +11,13 @@ _arguments -C -s \ '(-e -b -d -w -r)-L[list defined commands as calls]' \ '(-r)*::args:_normal' -if [[ $state = name ]] && _wanted names; then +if [[ $state = name ]]; then list=( ${${(f)"$(zpty)"}#*\) } ) names=( ${list%%:*} ) if zstyle -T ":completion:${curcontext}" verbose; then zformat -a list ' --' ${${(f)"$(zpty)"}#*\) } - _all_labels names expl 'zpty command names' compadd -d list - "$names[@]" + _wanted names expl 'zpty command names' compadd -d list - "$names[@]" else - _all_labels names expl 'zpty command names' compadd - "$names[@]" + _wanted names expl 'zpty command names' compadd - "$names[@]" fi fi diff --git a/Completion/Builtins/_zstyle b/Completion/Builtins/_zstyle index b4e151d78..b19303300 100644 --- a/Completion/Builtins/_zstyle +++ b/Completion/Builtins/_zstyle @@ -96,20 +96,18 @@ while [[ -n $state ]]; do case "$ostate" in contexts) - if _wanted contexts; then - if [[ $PREFIX != :*: ]]; then - _all_labels contexts expl context compadd -P : -S : completion zftp - elif [[ $PREFIX = :completion:* ]]; then - mesg='' - case "$PREFIX" in - :completion:[^:]#) mesg=function ;; - :completion:[^:]#:[^:]#) mesg=completer ;; - :completion:[^:]#:[^:]#:[^:]#) mesg='command or context' ;; - :completion:[^:]#:[^:]#:[^:]#:[^:]#) mesg=argument ;; - :completion:[^:]#:[^:]#:[^:]#:[^:]#:[^:]#) mesg=tag ;; - esac - [[ -n "$mesg" ]] && _message "$mesg" - fi + if [[ $PREFIX != :*: ]]; then + _wanted contexts expl context compadd -P : -S : completion zftp + elif [[ $PREFIX = :completion:* ]] && _tags contexts; then + mesg='' + case "$PREFIX" in + :completion:[^:]#) mesg=function ;; + :completion:[^:]#:[^:]#) mesg=completer ;; + :completion:[^:]#:[^:]#:[^:]#) mesg='command or context' ;; + :completion:[^:]#:[^:]#:[^:]#:[^:]#) mesg=argument ;; + :completion:[^:]#:[^:]#:[^:]#:[^:]#:[^:]#) mesg=tag ;; + esac + [[ -n "$mesg" ]] && _message "$mesg" fi ;; |