From 35b2633ad941966f5fca07b625a594a5b68c0fdb Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Mon, 15 Nov 1999 12:01:46 +0000 Subject: manual/8639 --- Completion/Builtins/_aliases | 2 +- Completion/Builtins/_arrays | 6 ++---- Completion/Builtins/_autoload | 6 ++---- Completion/Builtins/_bindkey | 12 ++++-------- Completion/Builtins/_builtin | 6 ++---- Completion/Builtins/_cd | 6 ++---- Completion/Builtins/_command | 6 ++---- Completion/Builtins/_compdef | 12 ++++-------- Completion/Builtins/_disable | 2 +- Completion/Builtins/_echotc | 9 ++++----- Completion/Builtins/_enable | 2 +- Completion/Builtins/_functions | 6 ++---- Completion/Builtins/_hash | 22 +++++++--------------- Completion/Builtins/_kill | 9 +++------ Completion/Builtins/_limits | 6 ++---- Completion/Builtins/_pids | 14 ++++++++------ Completion/Builtins/_popd | 10 ++++------ Completion/Builtins/_sched | 5 ++--- Completion/Builtins/_stat | 15 +++++++++------ Completion/Builtins/_trap | 5 +---- Completion/Builtins/_unhash | 2 +- Completion/Builtins/_vars | 14 +++++--------- Completion/Builtins/_wait | 2 +- Completion/Builtins/_which | 2 +- Completion/Builtins/_zftp | 35 +++++++++++++++-------------------- Completion/Builtins/_zle | 9 +++------ Completion/Builtins/_zmodload | 14 +++++--------- 27 files changed, 94 insertions(+), 145 deletions(-) (limited to 'Completion/Builtins') diff --git a/Completion/Builtins/_aliases b/Completion/Builtins/_aliases index a097d020e..78ec59686 100644 --- a/Completion/Builtins/_aliases +++ b/Completion/Builtins/_aliases @@ -2,6 +2,6 @@ local expl -_alternative any:argument \ +_alternative \ 'aliases:regular alias:compadd - ${(@k)aliases}' \ 'global-aliases:global alias:compadd - ${(@k)galiases}' diff --git a/Completion/Builtins/_arrays b/Completion/Builtins/_arrays index 37eb20bf5..4f67ff08d 100644 --- a/Completion/Builtins/_arrays +++ b/Completion/Builtins/_arrays @@ -2,7 +2,5 @@ local expl -_tags any:argument arrays || return 1 - -_description expl array -compadd "$expl[@]" - "${(@k)parameters[(R)*array*]}" +_wanted arrays expl array && + compadd "$expl[@]" - "${(@k)parameters[(R)*array*]}" diff --git a/Completion/Builtins/_autoload b/Completion/Builtins/_autoload index 116bb7765..de5a6045d 100644 --- a/Completion/Builtins/_autoload +++ b/Completion/Builtins/_autoload @@ -2,7 +2,5 @@ local expl -_tags any:argument functions || return 1 - -_description expl 'shell function' -compadd "$expl[@]" - ${^fpath}/*(N:t) +_wanted functions expl 'shell function' && + compadd "$expl[@]" - ${^fpath}/*(N:t) diff --git a/Completion/Builtins/_bindkey b/Completion/Builtins/_bindkey index 31215a576..98459916b 100644 --- a/Completion/Builtins/_bindkey +++ b/Completion/Builtins/_bindkey @@ -10,13 +10,9 @@ local expl if [[ "$words[2]" = -*[DAN]* || "$words[CURRENT-1]" = -*M ]]; then - _tags -M keymaps || return 1 - - _description expl keymap - compadd "$expl[@]" - "$keymaps[@]" + _wanted -C -M keymaps expl keymap && + compadd "$expl[@]" - "$keymaps[@]" else - _tags any:argument widgets || return 1 - - _description expl widget - compadd "$expl[@]" -M 'r:|-=* r:|=*' - "${(@k)widgets}" + _wanted widgets expl widget && + compadd "$expl[@]" -M 'r:|-=* r:|=*' - "${(@k)widgets}" fi diff --git a/Completion/Builtins/_builtin b/Completion/Builtins/_builtin index fcb20560f..8d682420a 100644 --- a/Completion/Builtins/_builtin +++ b/Completion/Builtins/_builtin @@ -7,8 +7,6 @@ if (( $CURRENT > 2 )); then else local expl - _tags any:command commands || return 1 - - _description expl 'builtin command' - compadd "$expl[@]" "$@" - "${(k@)builtins}" + _wanted commands expl 'builtin command' && + compadd "$expl[@]" "$@" - "${(k@)builtins}" fi diff --git a/Completion/Builtins/_cd b/Completion/Builtins/_cd index 26846fde2..2203dcf15 100644 --- a/Completion/Builtins/_cd +++ b/Completion/Builtins/_cd @@ -22,10 +22,8 @@ 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]}}) - if (( $#rep )) && _tags replacement strings; then - _description expl replacement - compadd "$expl[@]" $rep - fi + (( $#rep )) && _wanted -C replacement strings expl replacement && + compadd "$expl[@]" $rep elif _popd || [[ $PREFIX != (\~|/|./|../)* && $#cdpath -ne 0 ]]; then local tdir tdir2 diff --git a/Completion/Builtins/_command b/Completion/Builtins/_command index 23995dbbe..1cfa6add9 100644 --- a/Completion/Builtins/_command +++ b/Completion/Builtins/_command @@ -6,8 +6,6 @@ if [[ CURRENT -ge 3 ]]; then else local expl - _tags any:command commands || return 1 - - _description expl 'external command' - compadd "$expl[@]" "$@" - "${(k@)commands}" + _wanted commands expl 'external command' && + compadd "$expl[@]" "$@" - "${(k@)commands}" fi diff --git a/Completion/Builtins/_compdef b/Completion/Builtins/_compdef index df25d44de..7b4b0cb35 100644 --- a/Completion/Builtins/_compdef +++ b/Completion/Builtins/_compdef @@ -12,16 +12,12 @@ while [[ $words[base] = -* ]]; do done if [ "$delete" ]; then - _tags any:argument commands || return 1 - - _description expl 'completed command' - compadd "$expl[@]" - ${(k)_comps} + _wanted commands expl 'completed command' && + compadd "$expl[@]" - ${(k)_comps} else if [[ CURRENT -eq base ]]; then - _tags any:argument functions || return 1 - - _description expl 'completion function' - compadd "$expl[@]" - ${^fpath:/.}/_(|*[^~])(N:t) + _wanted functions expl 'completion function' && + compadd "$expl[@]" - ${^fpath:/.}/_(|*[^~])(N:t) else _command_names fi diff --git a/Completion/Builtins/_disable b/Completion/Builtins/_disable index 33c202864..7c17c9939 100644 --- a/Completion/Builtins/_disable +++ b/Completion/Builtins/_disable @@ -12,4 +12,4 @@ args=() [[ "$prev" != -* ]] && tags=( 'builtins:builtin command:compadd - ${(@k)builtins} ) -_alternative any "$args[@]" +_alternative "$args[@]" diff --git a/Completion/Builtins/_echotc b/Completion/Builtins/_echotc index 2193261a1..06b78408d 100644 --- a/Completion/Builtins/_echotc +++ b/Completion/Builtins/_echotc @@ -2,8 +2,7 @@ local expl -_tags any:argument capabilities || return 1 - -_description expl 'terminal capability' -compadd "$expl[@]" \ - al dc dl do le up al bl cd ce cl cr dc dl do ho is le ma nd nl se so up +_wanted capabilities expl 'terminal capability' && + compadd "$expl[@]" \ + al dc dl do le up al bl cd ce cl cr \ + dc dl do ho is le ma nd nl se so up diff --git a/Completion/Builtins/_enable b/Completion/Builtins/_enable index ae2bdc38c..5cb07539e 100644 --- a/Completion/Builtins/_enable +++ b/Completion/Builtins/_enable @@ -12,4 +12,4 @@ args=() [[ "$prev" != -* ]] && tags=( 'builtins:builtin command:compadd - ${(@k)dis_builtins} ) -_alternative any "$args[@]" +_alternative "$args[@]" diff --git a/Completion/Builtins/_functions b/Completion/Builtins/_functions index 9e6925ce7..98b21da68 100644 --- a/Completion/Builtins/_functions +++ b/Completion/Builtins/_functions @@ -2,7 +2,5 @@ local expl -_tags argument:any functions || return 1 - -_description expl 'shell function' -compadd "$expl[@]" "$@" - "${(k@)functions}" +_wanted functions expl 'shell function' && + compadd "$expl[@]" "$@" - "${(k@)functions}" diff --git a/Completion/Builtins/_hash b/Completion/Builtins/_hash index 24a9964b9..e5f182528 100644 --- a/Completion/Builtins/_hash +++ b/Completion/Builtins/_hash @@ -4,23 +4,15 @@ local expl if [[ "$words[2]" = -*d* ]]; then if compset -P 1 '*\='; then - _tags - -d-value files || return 1 - - _path_files -g '*(-/)' + _wanted -C -d-value files && _path_files -g '*(-/)' else - _tags - -d named-directories || return 1 - - _description expl 'named directory' - compadd "$expl[@]" -q -S '=' - "${(@k)nameddirs}" + _wanted -C -d named-directories expl 'named directory' && + compadd "$expl[@]" -q -S '=' - "${(@k)nameddirs}" fi elif compset -P 1 '*\='; then - _tags value executables || return 1 - - _description expl 'executable file' - _files "$expl[@]" -g '*(*)' + _wanted -C value values executables expl 'executable file' && + _files "$expl[@]" -g '*(*)' else - _tags any:argument commands || return 1 - - _description expl command - compadd "$expl[@]" -q -S '=' - "${(@k)commands}" + _wanted -C name commands expl command && + compadd "$expl[@]" -q -S '=' - "${(@k)commands}" fi diff --git a/Completion/Builtins/_kill b/Completion/Builtins/_kill index e2dc88dac..0fee6dee8 100644 --- a/Completion/Builtins/_kill +++ b/Completion/Builtins/_kill @@ -3,11 +3,8 @@ local list expl if compset -P 1 -; then - - _tags - -:signal signals || return 1 - - _description expl signal - compadd "$expl[@]" $signals[1,-3] + _wanted -C - expl signal && + compadd "$expl[@]" $signals[1,-3] else - _alternative argument 'jobs:: _jobs' 'processes:: _pids' + _alternative -C argument 'jobs:: _jobs' 'processes:: _pids' fi diff --git a/Completion/Builtins/_limits b/Completion/Builtins/_limits index 12e90e96a..dae573e03 100644 --- a/Completion/Builtins/_limits +++ b/Completion/Builtins/_limits @@ -2,7 +2,5 @@ local expl -_tags any:argument limits || return 1 - -_description expl 'process limits' -compadd "$expl[@]" ${${(f)"$(limit)"}%% *} +_wanted limits expl 'process limits' && + compadd "$expl[@]" ${${(f)"$(limit)"}%% *} diff --git a/Completion/Builtins/_pids b/Completion/Builtins/_pids index f96c11e2d..597a19477 100644 --- a/Completion/Builtins/_pids +++ b/Completion/Builtins/_pids @@ -3,23 +3,25 @@ # If given the `-m ' option, this tries to complete only pids # of processes whose command line match the `'. -local list expl match desc +local list expl match desc listargs args -_tags any processes || return 1 +_wanted processes expl 'process ID' || return 1 if [[ "$1" = -m ]]; then match="${2}*" shift 2 fi -_description expl 'process ID' +_style -a ps list-arguments listargs +_style -a ps arguments args +(( $#listargs )) || listargs=( "$args[@]" ) -if _style processes description yes; then - list=("${(@Mr:COLUMNS-1:)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${~match}}") +if _style processes description; then + list=("${(@Mr:COLUMNS-1:)${(f@)$(ps $listargs 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${~match}}") desc=(-ld list) else desc=() fi compadd "$expl[@]" "$@" "$desc[@]" - \ - ${${${(M)${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]:#*${~match}}## #}%% *} + ${${${(M)${(f)"$(ps $args 2>/dev/null)"}[2,-1]:#*${~match}}## #}%% *} diff --git a/Completion/Builtins/_popd b/Completion/Builtins/_popd index 5e4910f48..9b9b0d048 100644 --- a/Completion/Builtins/_popd +++ b/Completion/Builtins/_popd @@ -7,14 +7,13 @@ setopt extendedglob nonomatch -_tags any directory-stack || return 1 +local expl list lines revlines disp -! _style directory-stack prefix-needed yes || - [[ $PREFIX = [-+]* ]] || return 1 +_wanted directory-stack -V expl 'directory stack' || return 1 -local expl list lines revlines disp +! _style directory-stack prefix-needed || [[ $PREFIX = [-+]* ]] || return 1 -if _style directory-stack description yes; then +if _style directory-stack description; then # get the list of directories with their canonical number # and turn the lines into an array, removing the current directory lines=("${PWD}" "${dirstack[@]}") @@ -39,5 +38,4 @@ else disp=() fi -_description -V expl 'directory stack index' compadd "$expl[@]" "$@" -qS/ "$disp[@]" -Q - "$list[@]" diff --git a/Completion/Builtins/_sched b/Completion/Builtins/_sched index d3245f7ef..6a327e891 100644 --- a/Completion/Builtins/_sched +++ b/Completion/Builtins/_sched @@ -4,15 +4,14 @@ local expl lines disp if [[ CURRENT -eq 2 ]]; then if compset -P -; then - _tags - - entries || return 1 + _wanted -C - entries expl 'scheduled jobs' || return 1 lines=(${(f)"$(sched)"}) - if _style entries description yes; then + if _style entries description; then disp=( -ld lines ) else disp=() fi - _description expl 'scheduled jobs' [[ -z $lines ]] || compadd "$expl[@]" "$disp[@]" - {1..$#lines} else _message 'time specification' diff --git a/Completion/Builtins/_stat b/Completion/Builtins/_stat index 3f1b62ca3..75370f991 100644 --- a/Completion/Builtins/_stat +++ b/Completion/Builtins/_stat @@ -5,11 +5,14 @@ local expl if [[ "$words[CURRENT-1]" = -[AH] ]]; then _arrays else - _tags any:argument elements || return 1 + _tags elements files || return 1 - _description expl 'inode element' - [[ "$PREFIX[1]" = + ]] && - compadd "$expl[@]" - +device +inode +mode +nlink +uid +gid +rdev +size \ - +atime +mtime +ctime +blksize +block +link - _files + while _tags; do + _requested elements expl 'inode element' && + { ! _style elements prefix-needed || [[ "$PREFIX[1]" = + ]] } && + compadd "$expl[@]" - +device +inode +mode +nlink +uid +gid +rdev \ + +size +atime +mtime +ctime +blksize +block +link + fi + _requested files && _files + done fi diff --git a/Completion/Builtins/_trap b/Completion/Builtins/_trap index 5dbb2d284..bbbef1c55 100644 --- a/Completion/Builtins/_trap +++ b/Completion/Builtins/_trap @@ -6,8 +6,5 @@ if [[ CURRENT -eq 2 ]]; then compset -q _normal else - _tags any:argument signals || return 1 - - _description expl signal - compadd "$expl[@]" - "$signals[@]" + _wanted signals expl signal && compadd "$expl[@]" - "$signals[@]" fi diff --git a/Completion/Builtins/_unhash b/Completion/Builtins/_unhash index 6ccbc21a4..7a0d0c25a 100644 --- a/Completion/Builtins/_unhash +++ b/Completion/Builtins/_unhash @@ -11,4 +11,4 @@ args=() [[ "$fl != -* ]] && args=( 'commands:: _command_names -e' ) -_alternative any:argument "$args[@]" +_alternative "$args[@]" diff --git a/Completion/Builtins/_vars b/Completion/Builtins/_vars index 43cdf5d2c..2758f3de2 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['. However, in this version the [ must be -# added by hand. +# `vared foo['. 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 "$expl[@]" $addclose - ${(kP)var} fi else - _tags any parameters || return 1 - - _parameters + _tags parameters && _parameters fi diff --git a/Completion/Builtins/_wait b/Completion/Builtins/_wait index 04ad5e873..28fdb7985 100644 --- a/Completion/Builtins/_wait +++ b/Completion/Builtins/_wait @@ -1,3 +1,3 @@ #compdef wait -_alternative argument:any 'jobs:: _jobs' 'processes:: _pids' +_alternative 'jobs:: _jobs' 'processes:: _pids' diff --git a/Completion/Builtins/_which b/Completion/Builtins/_which index 6e9e0a460..5b1427962 100644 --- a/Completion/Builtins/_which +++ b/Completion/Builtins/_which @@ -4,7 +4,7 @@ local args args=( "$@" ) -_alternative -O args any:argument \ +_alternative -O args \ 'commands:external command:compadd - ${(k@)commands}' \ 'builtins:builtin command:compadd - ${(k@)builtins}' \ 'functions:shell function:compadd - ${(k@)functions}' \ diff --git a/Completion/Builtins/_zftp b/Completion/Builtins/_zftp index 2728d1747..8407de30e 100644 --- a/Completion/Builtins/_zftp +++ b/Completion/Builtins/_zftp @@ -4,7 +4,7 @@ # zfcd_match and zfget_match (also used for old-style completion) # need to be installed for remote file and directory completion to work. -emulate -L zsh +# emulate -L zsh # Don't try any more completion after this. _compskip=all @@ -13,12 +13,10 @@ local subcom expl if [[ $words[1] = zftp ]]; then if [[ $CURRENT -eq 2 ]]; then - _tags command commands || return 1 - - _description expl sub-command - compadd "$expl[@]" open params user login type ascii binary mode put \ - putat get getat append appendat ls dir local remote mkdir rmdir \ - session rmsession + _wanted commands expl sub-command && + compadd "$expl[@]" open params user login type ascii binary mode put \ + putat get getat append appendat ls dir local remote mkdir rmdir \ + session rmsession return fi subcom=$words[2] @@ -29,28 +27,27 @@ fi case $subcom in *(cd|ls|dir)) # complete remote directories - _tags "$subcom" directories && zfcd_match $PREFIX $SUFFIX + _tags -C "$subcom" directories && zfcd_match $PREFIX $SUFFIX ;; *(get(|at)|gcp|delete|remote)) # complete remote files - _tags "$subcom" files && zfget_match $PREFIX $SUFFIX + _tags -C "$subcom" files && zfget_match $PREFIX $SUFFIX ;; *(put(|at)|pcp)) # complete local files - _tags "$subcom" files && _files + _tags -C "$subcom" files && _files ;; *(open|anon|params)) # complete hosts: should do cleverer stuff with user names - _tags "$subcom" hosts && _hosts + _tags -C "$subcom" hosts && _hosts ;; *(goto|mark)) # complete bookmarks. First decide if ncftp mode is go. - _tags "$subcom" bookmarks || return 1 - _description expl bookmark + _wanted -C "$subcom" bookmarks expl bookmark || return 1 if [[ $words[2] = -*n* ]]; then if [[ -f ~/.ncftp/bookmarks ]]; then compadd "$expl[@]" - $(awk -F, 'NR > 2 { print $1 }' ~/.ncftp/bookmarks) @@ -64,16 +61,15 @@ case $subcom in *session) # complete sessions, excluding the current one. - _tags "$subcom" sessions || return 1 - _description expl 'another FTP session' - compadd "$expl[@]" - ${$(zftp session):#$ZFTP_SESSION} + _wanted -C "$subcom" sessions expl 'another FTP session' && + compadd "$expl[@]" - ${$(zftp session):#$ZFTP_SESSION} ;; *transfer) # complete arguments like sess1:file1 sess2:file2 if [[ $PREFIX = *:* ]]; then # complete file in the given session - _tags "$subcom" files || return 1 + _tags -C "$subcom" files || return 1 local sess=${PREFIX%%:*} oldsess=$ZFTP_SESSION compset -p $(( $#sess + 1 )) [[ -n $sess ]] && zftp session $sess @@ -81,9 +77,8 @@ case $subcom in [[ -n $sess && -n $oldsess ]] && zftp session $oldsess else # note here we can complete the current session - _tags "$subcom" sessions || return 1 - _description expl 'FTP session' - compadd "$expl[@]" -S : - $(zftp session) + _wanted -C "$subcom" sessions expl 'FTP session' && + compadd "$expl[@]" -S : - $(zftp session) fi ;; diff --git a/Completion/Builtins/_zle b/Completion/Builtins/_zle index 21997ef62..8e8017817 100644 --- a/Completion/Builtins/_zle +++ b/Completion/Builtins/_zle @@ -3,11 +3,8 @@ local expl if [[ "$words[2]" = -N && CURRENT -eq 3 ]]; then - _tags any:argument functions || return 1 - _description expl 'widget shell function' - compadd "$expl[@]" "$@" - "${(k@)functions}" && ret=0 + _wanted -C -N functions expl 'widget shell function' && + compadd "$expl[@]" "$@" - "${(k@)functions}" && ret=0 else - _tags any:argument widgets || return 1 - _description expl widget - compadd "$expl[@]" - "${(@k)widgets}" + _wanted widgets expl widget && compadd "$expl[@]" - "${(@k)widgets}" fi diff --git a/Completion/Builtins/_zmodload b/Completion/Builtins/_zmodload index 1a1097a7a..bedc4b08f 100644 --- a/Completion/Builtins/_zmodload +++ b/Completion/Builtins/_zmodload @@ -3,15 +3,11 @@ local fl="$words[2]" expl if [[ "$fl" = -*(a*u|u*a)* || "$fl" = -*a* && CURRENT -ge 4 ]]; then - _tags any:argument builtins || return 1 - _description expl 'builtin command' - compadd "$expl[@]" "$@" - "${(k@)builtins}" && ret=0 + _wanted builtins expl 'builtin command' && + compadd "$expl[@]" "$@" - "${(k@)builtins}" elif [[ "$fl" = -*u* ]]; then - _tags any:argument modules || return 1 - _description expl module - compadd "$expl[@]" - "${(@k)modules}" + _wanted modules expl module && compadd "$expl[@]" - "${(@k)modules}" else - _tags any:argument files || return 1 - _description expl 'module file' - compadd "$expl[@]" - ${^module_path}/*.s[ol](N:t:r) + _wanted files expl 'module file' && + compadd "$expl[@]" - ${^module_path}/*.s[ol](N:t:r) fi -- cgit 1.4.1