diff options
Diffstat (limited to 'Completion/User')
41 files changed, 390 insertions, 489 deletions
diff --git a/Completion/User/_archie b/Completion/User/_archie index 640fbc4ed..e1c9156fa 100644 --- a/Completion/User/_archie +++ b/Completion/User/_archie @@ -1,9 +1,9 @@ #compdef archie -local context state line expl +local curcontext="$curcontext" state line expl typeset -A opt_args -_arguments -s \ +_arguments -C -s \ '-D+[debug level]:debug level:' \ '-v[print version]' \ '-V[verbose mode]' \ @@ -26,9 +26,6 @@ case "$state" in serverhost) : ${(A)archie_servers:=${(M)$(archie -L):#archie.*}} - _tags "${context}:server" hosts || return 1 - - _description expl 'archie servers' - compadd "$expl[@]" - $archie_servers + _wanted hosts expl 'archie servers' && compadd "$expl[@]" - $archie_servers ;; esac diff --git a/Completion/User/_cvs b/Completion/User/_cvs index 61435a9cf..cac9132b7 100644 --- a/Completion/User/_cvs +++ b/Completion/User/_cvs @@ -33,8 +33,11 @@ _cvs_command () { watchers "") if (( CURRENT == 1 )); then - compadd "$@" ${(k)cmds} || compadd "$@" ${(kv)=cmds} + _tags commands && { compadd "$@" ${(k)cmds} || compadd "$@" ${(kv)=cmds} } else + local curcontext="$curcontext" + + curcontext="${curcontext%:*}:$words[1]" _cvs_"${${(k)cmds[(R)* $words[1] *]}:-${(k)cmds[(i)$words[1]]}}" fi } @@ -351,22 +354,24 @@ _cvs_update () { (( $+functions[_cvs_watch] )) || _cvs_watch () { + local expl + if (( CURRENT == 2 )); then - compadd on off add remove + _wanted values expl 'watch comamnd' && compadd on off add remove else case "$words[2]" in on|off) # "+lR" _arguments -s \ - -{l,R} \ - ':watch command:' \ - ':*:file:_cvs_files' + -{l,R} \ + ':watch command:' \ + ':*:file:_cvs_files' ;; add|remove) # "+lRa:" _arguments -s \ - -{l,R} \ - '*-a+:action:(edit unedit commit all none)' \ - ':watch command:' \ - ':*:file:_cvs_files' + -{l,R} \ + '*-a+:action:(edit unedit commit all none)' \ + ':watch command:' \ + ':*:file:_cvs_files' ;; esac fi @@ -376,18 +381,18 @@ _cvs_watch () { _cvs_watchers () { # "+lR" _arguments -s \ - -{l,R} \ - ':*:file:_cvs_files' + -{l,R} \ + ':*:file:_cvs_files' } (( $+functions[_cvs_root] )) || _cvs_root () { - compadd "$@" $_cvs_roots || _files "$@" -/ + _tags files && { compadd "$@" $_cvs_roots || _files "$@" -/ } } (( $+functions[_cvs_tempdir] )) || _cvs_tempdir () { - compadd "$@" $TMPPREFIX:h $TMPDIR /tmp + _tags directories && compadd "$@" $TMPPREFIX:h $TMPDIR /tmp } (( $+functions[_cvs_user_variable] )) || @@ -403,29 +408,29 @@ _cvs_user_variable () { (( $+functions[_cvs_bindir] )) || _cvs_bindir () { - compadd "$@" /usr/local/bin || _files "$@" -/ + _tags directories && { compadd "$@" /usr/local/bin || _files "$@" -/ } } (( $+functions[_cvs_editor] )) || _cvs_editor () { - compadd "$@" vi + _tags commands && compadd "$@" vi } (( $+functions[_cvs_gzip_level] )) || _cvs_gzip_level () { - compadd "$@" 9 + _tags values && compadd "$@" 9 } # define completion functions for cvs common options and arguments. (( $+functions[_cvs_D] )) || _cvs_D () { - compadd "$@" today yesterday week\ ago month\ ago + _tags values && compadd "$@" today yesterday week\ ago month\ ago } (( $+functions[_cvs_k] )) || _cvs_k () { - compadd "$@" kv kvl k o b v + _tags values && compadd "$@" kv kvl k o b v } (( $+functions[_cvs_m] )) || @@ -435,21 +440,26 @@ _cvs_m () { (( $+functions[_cvs_modules] )) || _cvs_modules () { - local root=$CVSROOT + local root=$CVSROOT expl + [[ -f CVS/Root ]] && root=$(<CVS/Root) if [[ $root = :* || ! -d $root ]]; then _message "module name" else - compadd - \ - $root/^CVSROOT(:t) \ - ${${(M)${(f)"$(<$root/CVSROOT/modules)"}:#[^#]*}%%[ ]*} + _wanted modules expl module && + compadd "$expl[@]" - \ + $root/^CVSROOT(:t) \ + ${${(M)${(f)"$(<$root/CVSROOT/modules)"}:#[^#]*}%%[ ]*} fi } (( $+functions[_cvs_revisions] )) || _cvs_revisions () { - compadd - ${${${(M)${(f)"$(cvs -q status -vl .)"}:# *}##[ ]##}%%[ ]*} + local expl + + _wanted values expl revision && + compadd - ${${${(M)${(f)"$(cvs -q status -vl .)"}:# *}##[ ]##}%%[ ]*} } # define completion functions for files maintained by cvs. @@ -477,8 +487,7 @@ _cvs_extract_file_entries () { (( $+functions[_cvs_extract_modifiedfile_entries] )) || _cvs_extract_modifiedfile_entries () { - if [[ -n "$compconfig[cvs_disable_stat]" ]] || - ! { zmodload -e stat || zmodload stat }; then + if _style cvs disable-stat || ! { zmodload -e stat || zmodload stat }; then _cvs_extract_file_entries return fi @@ -566,7 +575,7 @@ _cvs_files_removed () { local omit omit=(${pref}*(D:t)) eval 'entries=(${entries:#('${(j:|:)${(@)omit:q}}')})' - compadd "$@" -P "$qpref" - ${entries:q} || + _tags direcories && compadd "$@" -P "$qpref" - ${entries:q} || _cvs_directories "$@" else _files "$@" diff --git a/Completion/User/_dd b/Completion/User/_dd index 9bcdc876d..3a980b48d 100644 --- a/Completion/User/_dd +++ b/Completion/User/_dd @@ -6,9 +6,9 @@ if compset -P 1 'conv\='; then # If there's a comma present, ignore up to the last one. The # test alone will have that effect. compset -p '*,' - _description expl conversion - compadd "$expl[@]" -qS, -q \ - ascii ebcdic ibm block unblock lcase ucase swab noerror sync + _wanted values expl conversion && + compadd "$expl[@]" -qS, -q \ + ascii ebcdic ibm block unblock lcase ucase swab noerror sync elif compset -P 1 'if\='; then _description expl 'input file' _files "$expl[@]" @@ -16,6 +16,6 @@ elif compset -P 1 'of\='; then _description expl 'output file' _files "$expl[@]" else - _description expl option - compadd "$expl[@]" -S '=' if of ibs obs bs cbs skip files seek count conv + _wanted values expl option && + compadd "$expl[@]" -S '=' if of ibs obs bs cbs skip files seek count conv fi diff --git a/Completion/User/_flex b/Completion/User/_flex index 5d5d55f7a..714e5b9d5 100644 --- a/Completion/User/_flex +++ b/Completion/User/_flex @@ -1,9 +1,9 @@ #compdef flex -local context state line ret=1 +local curcontext="$curcontext" state line ret=1 typeset -A opt_args -_arguments -s \ +_arguments -C -s \ --help --version \ '-b[generate backing-up information]' \ '-d[make scanner running in debug mode]' \ diff --git a/Completion/User/_gcc b/Completion/User/_gcc index 88f70ad52..7292a933c 100644 --- a/Completion/User/_gcc +++ b/Completion/User/_gcc @@ -1,6 +1,6 @@ #compdef gcc -local context state line ret=1 expl args +local curcontext="$curcontext" state line ret=1 expl args typeset -A opt_args args=() @@ -163,7 +163,7 @@ h8/300) esac -_arguments -M 'L:|-{fW}no-=-{fW} r:|[_-]=* r:|=*' \ +_arguments -C -M 'L:|-{fW}no-=-{fW} r:|[_-]=* r:|=*' \ "$args[@]" \ -c -S -E -v -a -w -C -H -P -s '(-pg)-p' '(-p)-pg' \ '-o:output file:_files' \ @@ -273,10 +273,8 @@ dump) 'p[annotate assembler output]' && ret=0 ;; library) - _tags "${context}" libraries || return 1 - - _description expl library - compadd "$expl[@]" - ${^=LD_LIBRARY_PATH:-/usr/lib /usr/local/lib}/lib*.(a|so*)(:t:fr:s/lib//) && ret=0 + _wanted libraries expl library && + compadd "$expl[@]" - ${^=LD_LIBRARY_PATH:-/usr/lib /usr/local/lib}/lib*.(a|so*)(:t:fr:s/lib//) && ret=0 ;; esac diff --git a/Completion/User/_gdb b/Completion/User/_gdb index dab301b39..d037b83d9 100644 --- a/Completion/User/_gdb +++ b/Completion/User/_gdb @@ -10,19 +10,19 @@ local cur="$words[CURRENT]" prev w list ret=1 expl if compset -P '-(cd|directory)='; then _files -/ elif compset -P '-tty='; then - _description expl 'terminal device' - compadd "$expl[@]" - /dev/tty* + _wanted devices expl 'terminal device' && compadd "$expl[@]" - /dev/tty* elif compset -P '-(exec|se)='; then _description expl executable _files "$expl[@]" -g '*(*)' elif compset -P '-(symbols|core|command)='; then _files elif [[ "$PREFIX" = -* ]]; then - _description expl option - compadd "$expl[@]" -QS '' - -symbols\= -exec\= -se\= -core\= -command\= \ - -directory\= -cd\= -tty\= - compadd "$expl[@]" - -help -h -s -e -c -x -d -nx -n -quiet -q \ - -batch -fullname -f -b + if _wanted options expl option; then + compadd "$expl[@]" -QS '' - -symbols\= -exec\= -se\= -core\= -command\= \ + -directory\= -cd\= -tty\= + compadd "$expl[@]" - -help -h -s -e -c -x -d -nx -n -quiet -q \ + -batch -fullname -f -b + fi else prev="$words[CURRENT-1]" @@ -31,10 +31,10 @@ else (-[csx]) _files && return 0 ;; (-e) _description expl executable _files "$expl[@]" -g '*(*)' && return 0 ;; - (-b) _description -V expl 'baud rate' - compadd "$expl[@]" 0 50 75 110 134 150 200 300 600 1200 1800 \ - 2400 4800 9600 19200 38400 57600 115200 \ - 230400 && return 0 ;; + (-b) _wanted values expl -V expl 'baud rate' && + compadd "$expl[@]" 0 50 75 110 134 150 200 300 600 1200 1800 \ + 2400 4800 9600 19200 38400 57600 115200 \ + 230400 && return 0 ;; esac w=( "${(@)words[2,-1]}" ) @@ -44,10 +44,7 @@ else done if [[ $#w -gt 1 ]]; then - _files && ret=0 - _pids -m "${w[1]:t}" && ret=0 - - return ret + _alternative 'files:: _files' "processes:: _pids -m ${w[1]:t}" else _description expl executable _files "$expl[@]" -g '*(*)' diff --git a/Completion/User/_gprof b/Completion/User/_gprof index cbc362331..a69a078ba 100644 --- a/Completion/User/_gprof +++ b/Completion/User/_gprof @@ -1,9 +1,9 @@ #compdef gprof -local context state line ret=1 +local curcontext="$curcontext" state line ret=1 typeset -A opt_args -_arguments -s -{a,b,c,D,h,i,l,L,s,T,v,w,x,y,z} \ +_arguments -C -s -{a,b,c,D,h,i,l,L,s,T,v,w,x,y,z} \ -{A,C,e,E,f,F,J,n,N,O,p,P,q,Q,Z}:'function name:->funcs' \ '-I:directory:_dir_list' \ '-d-:debug level:' '-k:function names:->pair' \ @@ -17,7 +17,7 @@ _arguments -s -{a,b,c,D,h,i,l,L,s,T,v,w,x,y,z} \ if [[ -n "$state" ]]; then local cmd pair expl - _tags "${context}" functions || return 1 + _tags functions || return 1 [[ "$state" = pair ]] && pair=yes diff --git a/Completion/User/_groups b/Completion/User/_groups index bc955a8d2..f1963a8e7 100644 --- a/Completion/User/_groups +++ b/Completion/User/_groups @@ -2,15 +2,14 @@ local expl -_tags any groups || return 1 +_wanted groups expl group || return 1 if (( ! $+groups )); then - if whence -p ypcat > /dev/null; then - : ${(A)groups:=${${(s: :)$(ypcat group.byname)}%%:*}} # If you use NIS + if (( ${+commands[ypcat]} )); then + : ${(A)groups:=${${(s: :)$(ypcat group.byname)}%%:*}} # If you use YP else : ${(A)groups:=${${(s: :)$(</etc/group)}%%:*}} fi fi -_description expl group compadd "$@" "$expl[@]" - $groups diff --git a/Completion/User/_gs b/Completion/User/_gs index 0c9c11e10..2eebb8d23 100644 --- a/Completion/User/_gs +++ b/Completion/User/_gs @@ -8,10 +8,10 @@ if compset -N --; then return 1 fi else - local context state line ret=1 + local curcontext="$curcontext" state line ret=1 typeset -A opt_args - _x_arguments \ + _x_arguments -C \ '-q[quiet startup]' \ '-g-[set device size]:device size (<width>x<height>):' \ '-r-[set resolution]:resolution (<val> or <x>x<y>):' \ @@ -25,38 +25,31 @@ else if [[ "$PREFIX" = *\=* ]]; then _message 'systemdict definition value' else - _tags "$context" names || return 1 - - _description expl 'systemdict definition name' - compadd "$expl[@]" -M 'm:{a-z}={A-Z}' - \ - DISKFONTS NOCACHE NOBIND NODISPLAY NOPAUSE PLATFONTS SAFER \ - WRITESYSTEMDICT && ret=0 + _wanted names expl 'systemdict definition name' && + compadd "$expl[@]" -M 'm:{a-z}={A-Z}' - \ + DISKFONTS NOCACHE NOBIND NODISPLAY NOPAUSE PLATFONTS SAFER \ + WRITESYSTEMDICT && ret=0 fi ;; sname) if compset -P '*\='; then case "$IPREFIX" in *DEVICE\=) - _tags "$context" devices || return 1 - - _description expl 'ghostscript device' - compadd "$expl[@]" - "${(@)${=${$(gs -h)##* devices:}%%Search path:*}:#}" && ret=0 + _wanted devices expl 'ghostscript device' && + compadd "$expl[@]" - "${(@)${=${$(gs -h)##* devices:}%%Search path:*}:#}" && ret=0 ;; *OutputFile\=) - _tags "$context" files || return 1 - _description expl 'output file' - _files && ret=0 + _files "$expl[@]" && ret=0 ;; *) _message 'systemdict value' return 1 esac else - _tags "$context" names || return 1 - - _description expl 'systemdict name' - compadd "$expl[@]" -S\= -M 'm:{a-z}={A-Z}' - DEVICE OutputFile && ret=0 + _wanted names expl 'systemdict name' && + compadd "$expl[@]" -S\= -M 'm:{a-z}={A-Z}' - DEVICE OutputFile && + ret=0 fi ;; esac diff --git a/Completion/User/_hosts b/Completion/User/_hosts index d577c83ab..83480efe4 100644 --- a/Completion/User/_hosts +++ b/Completion/User/_hosts @@ -2,9 +2,7 @@ local expl -_tags any hosts || return 1 - : ${(A)hosts:=${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} -_description expl host -compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" "$expl[@]" - "$hosts[@]" +_wanted hosts expl host && + compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" "$expl[@]" - "$hosts[@]" diff --git a/Completion/User/_killall b/Completion/User/_killall index 5df1acbb9..ebe02f10c 100644 --- a/Completion/User/_killall +++ b/Completion/User/_killall @@ -1,6 +1,4 @@ #compdef killall -if compset -P 1 -; then - _description expl signal - compadd "$expl[@]" $signals[1,-3] -fi +compset -P 1 - && _wanted -C - signals expl signal && + compadd "$expl[@]" $signals[1,-3] diff --git a/Completion/User/_lynx b/Completion/User/_lynx index 8399c4735..e3b57a9b4 100644 --- a/Completion/User/_lynx +++ b/Completion/User/_lynx @@ -1,9 +1,9 @@ #compdef lynx -local context state line +local curcontext="$curcontext" state line typeset -A opt_args -_arguments \ +_arguments -C \ '-accept_all_cookies' \ '-anonymous' \ '-assume_charset=:MIMENAME:' \ diff --git a/Completion/User/_mailboxes b/Completion/User/_mailboxes index 06906628e..97628ef9a 100644 --- a/Completion/User/_mailboxes +++ b/Completion/User/_mailboxes @@ -1,7 +1,7 @@ #autoload -emulate -L zsh -setopt nullglob +#emulate -L zsh +setopt localoptions nullglob # This is still needlessly mutt-biased and should be fixed. @@ -12,35 +12,31 @@ local maildirectory="${maildirectory:-~/Mail}" if (( ! $+_mailbox_cache )) then -[[ -f ${~muttrc:-.} ]] && muttboxes=( ${$(grep mailboxes ${~muttrc})[2,-1]} ) + [[ -f ${~muttrc:-.} ]] && muttboxes=( ${$(grep mailboxes ${~muttrc})[2,-1]} ) -mboxes=( ${~maildirectory}/*(^/) ${~pinedirectory}/**/*(.) ) -dirboxes=( ${~maildirectory}/*(/) ) + mboxes=( ${~maildirectory}/*(^/) ${~pinedirectory}/**/*(.) ) + dirboxes=( ${~maildirectory}/*(/) ) -while (( $#dirboxes )) -do + while (( $#dirboxes )); do i=$dirboxes[1] shift dirboxes - if [[ -d "$i/cur" ]] - then - maildirboxes=( $maildirboxes $i ) - elif j=( $i/<1-> ) && [[ -n "$j" ]] - then - MHboxes=( $MHboxes $i ) + if [[ -d "$i/cur" ]]; then + maildirboxes=( $maildirboxes $i ) + elif j=( $i/<1-> ) && [[ -n "$j" ]]; then + MHboxes=( $MHboxes $i ) else - mboxes=( $mboxes $i/*(.) ) - dirboxes=( $dirboxes $i/*(/) ) + mboxes=( $mboxes $i/*(.) ) + dirboxes=( $dirboxes $i/*(/) ) fi -done + done -[[ -n "$muttboxes" || -d ~/.elm || -d ~/.mutt ]] && - _mailbox_cache=(\! \< \> $muttboxes) -[[ -n "$mailpath" ]] && - _mailbox_cache=($_mailbox_cache ${mailpath//\?*/}) - -_mailbox_cache=($_mailbox_cache $mboxes $maildirboxes $MHboxes) + [[ -n "$muttboxes" || -d ~/.elm || -d ~/.mutt ]] && + _mailbox_cache=(\! \< \> $muttboxes) + [[ -n "$mailpath" ]] && + _mailbox_cache=($_mailbox_cache ${mailpath//\?*/}) + _mailbox_cache=($_mailbox_cache $mboxes $maildirboxes $MHboxes) fi -_description expl 'mailbox specification' -compadd "$@" "$expl[@]" - "$_mailbox_cache[@]" +_wanted files expl 'mailbox specification' && + compadd "$@" "$expl[@]" - "$_mailbox_cache[@]" diff --git a/Completion/User/_make b/Completion/User/_make index f6544ffb0..1531b34d6 100644 --- a/Completion/User/_make +++ b/Completion/User/_make @@ -18,12 +18,11 @@ else file='' fi - _description expl 'make target' - [[ -n "$file" ]] && - compadd "$expl[@]" - \ - $(awk '/^[a-zA-Z0-9][^\/ \t]+:/ {print $1} - /^\.include *<bsd\.port\.(subdir\.|pre\.)?mk>/ || /^\.include *".*mk\/bsd\.pkg\.(subdir\.)?mk"/ { - print "fetch fetch-list extract patch configure build install reinstall deinstall package describe checkpatch checksum makesum" }' \ - FS=: $file) && ret=0 + [[ -n "$file" ]] && _wanted targets expl 'make target' && + compadd "$expl[@]" - \ + $(awk '/^[a-zA-Z0-9][^\/ \t]+:/ {print $1} + /^\.include *<bsd\.port\.(subdir\.|pre\.)?mk>/ || /^\.include *".*mk\/bsd\.pkg\.(subdir\.)?mk"/ { + print "fetch fetch-list extract patch configure build install reinstall deinstall package describe checkpatch checksum makesum" }' \ + FS=: $file) && ret=0 (( ret )) && { compset -P 1 '*\='; _files } fi diff --git a/Completion/User/_man b/Completion/User/_man index 60bd23dd7..18b74d30b 100644 --- a/Completion/User/_man +++ b/Completion/User/_man @@ -22,7 +22,7 @@ if (( ! $#manpath )); then fi (( $#manpath )) || manpath=( ${(s.:.)$(manpath 2>/dev/null)} ) || - manpath=( /usr/man(-/N) /(opt|usr)/(dt|share|X11R6|local)/(cat|)man(-/N) ) + manpath=( /usr/man(-/N) /(opt|usr)/(dt|share|X11R6|local)/(cat|)man(-/N) ) # `sman' is the SGML manual directory for Solaris 7. @@ -33,5 +33,5 @@ else rep=( $manpath/(sman|man|cat)*/${~approx}$PREFIX${~star}$SUFFIX.<->*(N:t) ) fi -_description expl 'manual page' -(( $#rep )) && compadd "$expl[@]" - ${rep%%.[^.]##(.gz|)} +(( $#rep )) && _wanted manuals expl 'manual page' && + compadd "$expl[@]" - ${rep%%.[^.]##(.gz|)} diff --git a/Completion/User/_mh b/Completion/User/_mh index 87ab8a18e..e4d042dc2 100644 --- a/Completion/User/_mh +++ b/Completion/User/_mh @@ -17,12 +17,12 @@ if compset -P 1 -; then # get list of options, which MH commands can generate themselves # awk is just too icky to use for this, sorry. send me one if # you come up with it. - _description expl option - compadd "$expl[@]" - $($words[1] -help | perl -ne 'if (/^\s*-\(?(\S+)/) { - $n = $1; - $n =~ s/\)//g; - print $n =~ s/^\[([a-z]+)\]// ? "$n\n$1$n\n" : "$n\n"; - }') + _wanted options expl option && + compadd "$expl[@]" - $($words[1] -help | perl -ne 'if (/^\s*-\(?(\S+)/) { + $n = $1; + $n =~ s/\)//g; + print $n =~ s/^\[([a-z]+)\]// ? "$n\n$1$n\n" : "$n\n"; + }') return elif compset -P 1 '[+@]' || [[ "$prev" = -draftfolder ]]; then # Complete folder names. @@ -53,11 +53,11 @@ elif [[ "$prev" = -(form|audit|filter) ]]; then _description expl 'MH template file' _files "$expl[@]" -W mhfpath -g '*(.)' elif [[ "$prev" = -(no|)cc ]]; then - _description expl 'CC address' - compadd "$expl[@]" all to cc me + _wanted -C "$prev" values expl 'CC address' && + compadd "$expl[@]" all to cc me elif [[ "$prev" = -[rw]cache ]]; then - _description expl cache - compadd "$expl[@]" public private never ask + _wanted -C "$prev" values expl cache && + compadd "$expl[@]" public private never ask else # Generate sequences. local foldnam folddir f ret @@ -74,11 +74,11 @@ else # leaving foldnam empty works here fi - _description expl sequence - compadd "$expl[@]" $(mark $foldnam 2>/dev/null | awk -F: '{ print $1 }') && - ret=0 - compadd "$expl[@]" reply next cur prev first last all unseen && ret=0 - _files "$expl[@]" -W folddir -g '<->' && ret=0 - + if _wanted sequences expl sequence; then + compadd "$expl[@]" $(mark $foldnam 2>/dev/null | awk -F: '{ print $1 }') && + ret=0 + compadd "$expl[@]" reply next cur prev first last all unseen && ret=0 + _files "$expl[@]" -W folddir -g '<->' && ret=0 + fi return ret fi diff --git a/Completion/User/_mount b/Completion/User/_mount index 39e31ee35..a68260ae7 100644 --- a/Completion/User/_mount +++ b/Completion/User/_mount @@ -5,7 +5,9 @@ # arguments for the `mount' command for different operating systems # are below these table. -local context state line ret=1 args fss deffs=iso9660 descr tmp +local curcontext="$curcontext" state line ret=1 +local args fss deffs=iso9660 descr tmp + typeset -A opt_args if (( ! $+_fs_any )); then @@ -209,13 +211,13 @@ if [[ "$words[1]" = mount ]]; then ;; esac - _arguments "$args[@]" && ret=0 + _arguments -C "$args[@]" && ret=0 else # Completion for umount. - _arguments -s \ + _arguments -C -s \ '-h[show help]' \ '-V[show version]' \ '-v[verbose mode]' \ @@ -228,14 +230,13 @@ fi case "$state" in fstype) - _tags "$context" types || return 1 - compset -P '*,' - _description expl 'file system type' - compadd "$expl[@]" -qS, -M 'L:|no=' - "$fss[@]" && ret=0 + + _wanted types expl 'file system type' && + compadd "$expl[@]" -qS, -M 'L:|no=' - "$fss[@]" && ret=0 ;; fsopt) - _tags "$context" options || return 1 + _tags options || return 1 eval 'tmp=(' '"$_fs_'${(s:,:)^${opt_args[-t]:-${deffs}}}'[@]"' ')' tmp=( "$_fs_any[@]" "${(@)tmp:#}" ) @@ -245,7 +246,7 @@ devordir) if (( $+opt_args[-a] )); then _message "no device or directory with option \`-a'" else - _alternative "$context" \ + _alternative \ 'devices:device:compadd /dev/\*' \ 'directories:mount point:_files -/' && ret=0 fi @@ -260,7 +261,7 @@ udevordir) dev_tmp=( "${(@)${(@)tmp%% *}:#none}" ) mp_tmp=( "${(@)${(@)tmp#* }%% *}" ) - _alternative "$context" \ + _alternative \ 'devices:device:compadd - $dev_tmp[@]' \ 'directories:mount point:compadd - $mp_tmp[@]' && ret=0 fi diff --git a/Completion/User/_mutt b/Completion/User/_mutt index 16b1b0c6d..98c59b2e0 100644 --- a/Completion/User/_mutt +++ b/Completion/User/_mutt @@ -1,8 +1,8 @@ #compdef mutt -local context state line muttrc="~/.muttrc" ret=1 +local curcontext="$curcontext" state line muttrc="~/.muttrc" ret=1 - _arguments \ + _arguments -C \ '::recipient:->userhost' \ '-a:MIME attachment:_files' \ '-b:BCC recipient:->userhost' \ @@ -25,7 +25,7 @@ local context state line muttrc="~/.muttrc" ret=1 '-Z+:open first mailbox with new mail:' && ret=0 if [[ "$state" = userhost ]]; then - _tags "$context" hosts || return 1 + _tags hosts || return 1 if compset -P '*@'; then _description expl 'remote host name' diff --git a/Completion/User/_netscape b/Completion/User/_netscape index 3caaad05e..2f0537133 100644 --- a/Completion/User/_netscape +++ b/Completion/User/_netscape @@ -1,9 +1,9 @@ #compdef netscape -local context state line ret=1 +local curcontext="$curcontext" state line ret=1 typeset -A opt_args -_x_arguments \ +_x_arguments -C \ '-xrm:resource:_x_resource' \ '-help[show usage message]' \ '-version[show the version number and build date]' \ @@ -25,7 +25,7 @@ _x_arguments \ '*:location:->urls' && ret=0 [[ "$state" = "urls" ]] && - _tags "$context" files && _files "$@" && return 0 + _files "$@" && return 0 # Handle netscape remote commands @@ -40,35 +40,33 @@ if [[ "$state" = "remote" ]]; then openFile*) _files -W ~;; saveAs*) if compset -P "*,"; then - if _tags "$context" types; then - _description expl 'data type' - compadd -s")" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript && - ret=0 + _wanted types expl 'data type' && + compadd -s")" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript && + ret=0 fi else - _tags "$context" files && _path_files -W ~ && ret=0 + _tags files && _path_files -W ~ && ret=0 fi ;; mailto*) compset -P "*," if compset -P '*@'; then - if _tags "$context" hosts; then - _description expl 'remote host name' - _hosts "$expl[@]" -q -S, && ret=0 + _wanted hosts expl 'remote host name' && + _hosts "$expl[@]" -q -S, && ret=0 fi else - if _tags "$context" users; then - _description expl 'login name' - _users "$expl[@]" -q -S@ && ret=0 + _wanted users expl 'login name' && _users "$expl[@]" -q -S@ && ret=0 fi fi ;; *) - if _tags "$context" commands; then + if _wanted commands expl 'remote commands'; then if [[ "$QIPREFIX" ]]; then - compadd -q -S '(' -M 'm:{a-zA-Z}={A-Za-z}' $remote_commands && ret=0 + compadd "$expl[@]" -qS '(' -M 'm:{a-zA-Z}={A-Za-z}' - \ + $remote_commands && ret=0 else - compadd -s'(' -S '' -M 'm:{a-zA-Z}={A-Za-z}' $remote_commands && ret=0 + compadd "$expl[@]" -s'(' -S '' -M 'm:{a-zA-Z}={A-Za-z}' - \ + $remote_commands && ret=0 fi fi ;; @@ -77,15 +75,12 @@ fi if [[ "$state" = "urls" ]]; then # Complete netscape urls - if [[ -prefix about: ]]; then - if _tags "$context" values; then - _description expl 'about what' - compset -P about: - compadd authors blank cache document fonts global hype image-cache \ - license logo memory-cache mozilla plugins && ret=0 - fi + if compset about: ; then + _wanted values expl 'about what' && + compadd authors blank cache document fonts global hype image-cache \ + license logo memory-cache mozilla plugins && ret=0 else - if _tags "$context" prefixes; then + if _tags prefixes; then _description expl 'URL prefix' compadd "$expl[@]" -S '' about: mocha: javascript: _urls "$@" && ret=0 diff --git a/Completion/User/_nslookup b/Completion/User/_nslookup index f3e290505..495a0e3de 100644 --- a/Completion/User/_nslookup +++ b/Completion/User/_nslookup @@ -19,7 +19,7 @@ # other characters than lower case letters, we try to call the function # `_nslookup_host'. -local context state expl ret=1 setopts +local context curstate="$curcontext" expl ret=1 setopts setopts=( 'all[print current values]' \ @@ -52,17 +52,15 @@ if [[ -n "$compcontext" ]]; then funcall ret _nslookup_command && return ret - _tags any commands || return 1 - - _description expl 'command' - compadd "$expl[@]" - server lserver root finger ls view help set && ret=0 - _hosts && ret=0 + _alternative \ + 'commands:command:compadd server lserver root finger ls view help set' \ + 'hosts:: _host' && ret=0 return ret elif [[ "$compstate[context]" = redirect ]]; then funcall ret _nslookup_redirect && return ret - _tags redirection files || return 1 + _tags -C redirection files || return 1 if [[ "$words[1]" != (finger|ls) ]]; then _message "redirection not allowed for command \`$words[1]'" @@ -88,10 +86,7 @@ if [[ -n "$compcontext" ]]; then case "$words[1]" in (|l)server) - _tags argument hosts || return 1 - - _description expl 'new default server' - _hosts "$expl[@]" + _wanted hosts expl 'new default server' && _hosts "$expl[@]" return ;; root|exit|help|\?) @@ -112,8 +107,6 @@ if [[ -n "$compcontext" ]]; then return ;; view) - _tags argument files || return 1 - _description expl 'view file' _files "$expl[@]" return @@ -126,10 +119,7 @@ if [[ -n "$compcontext" ]]; then [[ -z "$state" ]] && return ret ;; *) - _tags argument hosts || return 1 - - _description expl 'server' - _hosts "$expl[@]" + _wanted hosts expl 'server' && _hosts "$expl[@]" return esac fi @@ -140,7 +130,7 @@ if [[ -z "$state" ]]; then local line typeset -A opt_args - _arguments \ + _arguments -C \ "-${(@)^${(@M)setopts:#*\]:*}/\[/=[}" \ "-${(@)^setopts:#(\(|*\]:)*}" \ "${(@)^${(@)${(@M)setopts:#\(*}/\)/)-}/\(/(-}" \ @@ -151,7 +141,7 @@ fi # This is completion after `srchlist' for both types. if [[ -n "$state" ]]; then - _tags "$context" hosts || return 1 + _tags hosts || return 1 if compset -P '*/'; then _description expl 'search list entry' diff --git a/Completion/User/_pbm b/Completion/User/_pbm index c697ebaa6..9eecd0390 100644 --- a/Completion/User/_pbm +++ b/Completion/User/_pbm @@ -254,8 +254,7 @@ pgmtoppm) fi _x_color && ret=0 - _description expl option - compadd "$expl[@]" - -map && ret=0 + _wanted options expl option && compadd "$expl[@]" - -map && ret=0 return ret elif [[ CURRENT -eq 3 && "$words[2]" = -map ]]; then @@ -591,12 +590,12 @@ ppmquant) fi if [[ CURRENT -eq 2 ]]; then - _description expl option - if [[ -n "$opt" ]]; then - compadd "$expl[@]" - -map -fs -floyd && ret=0 - else - compadd "$expl[@]" - -map && ret=0 - fi + _wanted options expl option && + if [[ -n "$opt" ]]; then + compadd "$expl[@]" - -map -fs -floyd && ret=0 + else + compadd "$expl[@]" - -map && ret=0 + fi _message 'number of colors' return ret diff --git a/Completion/User/_perl_basepods b/Completion/User/_perl_basepods index 2dc0874f0..7f257aed3 100644 --- a/Completion/User/_perl_basepods +++ b/Completion/User/_perl_basepods @@ -15,18 +15,19 @@ if [[ ${+_perl_basepods} -eq 0 ]]; then _perl_basepods=( ${$(basepods):t:r} ) else local podpath + podpath=$(perl -MConfig -e 'print "$Config{installprivlib}/pod"') + if [[ ! -e $podpath/perl.pod ]]; then echo "Couldn't find perl.pod from Config.pm; giving up." return 1 else - cd $podpath - _perl_basepods=( *.pod(:r:t) ) - cd $OLDPWD + _perl_basepods=( ${podpath}/*.pod(:r:t) ) fi fi fi local expl -_description expl "Perl base pods" -compadd "$expl[@]" - $_perl_basepods + +_wanted pods expl 'Perl base pods' && + compadd "$expl[@]" - $_perl_basepods diff --git a/Completion/User/_perl_builtin_funcs b/Completion/User/_perl_builtin_funcs index 804488db9..7ac69828d 100644 --- a/Completion/User/_perl_builtin_funcs +++ b/Completion/User/_perl_builtin_funcs @@ -27,5 +27,6 @@ if [[ ${+_perl_builtin_funcs} -eq 0 ]]; then fi local expl -_description expl "Perl built-in functions" -compadd "$expl[@]" - $_perl_builtin_funcs + +_wanted functions expl 'Perl built-in functions' && + compadd "$expl[@]" - $_perl_builtin_funcs diff --git a/Completion/User/_perl_modules b/Completion/User/_perl_modules index ef5c00628..272ebb5e4 100644 --- a/Completion/User/_perl_modules +++ b/Completion/User/_perl_modules @@ -42,5 +42,5 @@ if [[ ${+_perl_modules} -eq 0 ]]; then fi local expl -_description expl "Perl modules" -compadd "$expl[@]" - $_perl_modules + +_wanted modules expl 'Perl modules' && compadd "$expl[@]" - $_perl_modules diff --git a/Completion/User/_ports b/Completion/User/_ports index 9012dfd5e..ffd04ce5e 100644 --- a/Completion/User/_ports +++ b/Completion/User/_ports @@ -2,9 +2,6 @@ local expl -_tags any ports || return 1 - : ${(A)ports:=${${(M)${${(f)"$(</etc/services)"}:#\#*}#*/tcp}%%[ ]*}} -_description expl port -compadd "$@" "$expl[@]" - "$ports[@]" +_wanted ports expl port && compadd "$@" "$expl[@]" - "$ports[@]" diff --git a/Completion/User/_rcs b/Completion/User/_rcs index 272e54681..0831b1d0b 100644 --- a/Completion/User/_rcs +++ b/Completion/User/_rcs @@ -8,6 +8,5 @@ if [[ $compstate[nmatches] -eq nm && -d RCS && $words[1] != ci ]]; then local rep expl rep=(RCS/$PREFIX*$SUFFIX,v(:t:s/\,v//)) - _description expl 'RCS file' - (( $#rep )) && compadd "$expl[@]" - $rep + (( $#rep )) && _wanted files expl 'RCS file' && compadd "$expl[@]" - $rep fi diff --git a/Completion/User/_rlogin b/Completion/User/_rlogin index 898f10870..d732cf8a9 100644 --- a/Completion/User/_rlogin +++ b/Completion/User/_rlogin @@ -38,25 +38,21 @@ _rlogin () { return ret ;; rcp) - local state line ret=1 + local curcontext="$curcontext" state line ret=1 typeset -A opt_args - _arguments -s \ + _arguments -C -s \ '-p[preserve modification times]' \ '-r[recursively copy directories]' \ '*:files:->files' && ret=0 if [[ -n "$state" ]]; then if compset -P '*:'; then - _tags "$context" files || return 1 - _files && ret=0 elif compset -P '*@'; then - _tags "$context" hosts || return 1 - - _rlogin_hosts -S: -q && ret=0 + _tags hosts && _rlogin_hosts -S: -q && ret=0 else - _alternative "$context" \ + _alternative \ 'files:: _files' \ 'hosts:: _rlogin_all_hosts -qS:' \ 'users:: _rlogin_users -qS@' && ret=0 @@ -68,24 +64,21 @@ _rlogin () { } _rlogin_users () { - _tags any users && _combination accounts_users_hosts users "$@" + _tags users && _combination accounts_users_hosts users "$@" } _rlogin_hosts () { - _tags any hosts || return 1 - - if [[ "$IPREFIX" == *@ ]]; then - _combination accounts_users_hosts "users=${IPREFIX/@}" hosts "$@" - else - _combination accounts_users_hosts \ - ${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@" - fi + _tags hosts && + if [[ "$IPREFIX" == *@ ]]; then + _combination accounts_users_hosts "users=${IPREFIX/@}" hosts "$@" + else + _combination accounts_users_hosts \ + ${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@" + fi } _rlogin_all_hosts () { - _tags any hosts || return 1 - - _combination accounts_users_hosts hosts "$@" + _tags hosts && _combination accounts_users_hosts hosts "$@" } _rlogin "$@" diff --git a/Completion/User/_socket b/Completion/User/_socket index ad9232af9..b155e7ad4 100644 --- a/Completion/User/_socket +++ b/Completion/User/_socket @@ -5,19 +5,14 @@ # socket_hosts_ports # The array that contains paris `host:port'. -local context state line expl +local curcontext="$curcontext" state line expl typeset -A opt_args -if _tags any options && - [[ $CURRENT -eq 2 && ( - -z "$compconfig[option_prefix]" || - "$compconfig[option_prefix]" = *\!${words[1]}* || - "$PREFIX" = -* ) ]]; then - _description expl option - compadd -M 'r:|[_-]=* r:|=*' "$expl[@]" - -version -fi +[[ $CURRENT -eq 2 ]] && _wanted options expl option && + { ! _style options prefix-needed || [[ "$PREFIX" = -* ]] } && + compadd -M 'r:|[_-]=* r:|=*' "$expl[@]" - -version -_arguments -s \ +_arguments -C -s \ '-b[background]' \ '-c[crlf]' \ '-f[fork]' \ @@ -43,24 +38,17 @@ command) arg1) if (( $+opt_args[-s] )); then - _tags "$context" ports || return 1 - - _description expl 'port to listen' - _ports "$expl[@]" + _wanted ports expl 'port to listen' && _ports "$expl[@]" else - _tags "$context" hosts || return 1 - - _description expl 'host' - _combination socket_hosts_ports hosts "$expl[@]" + _wanted hosts expl 'host' && + _combination socket_hosts_ports hosts "$expl[@]" fi ;; arg2) if (( ! $+opt_args[-s] )); then - _tags "$context" ports || return 1 - - _description expl 'port to connect' - _combination socket_hosts_ports hosts="${line[2]:q}" ports "$expl[@]" + _wanted ports expl 'port to connect' && + _combination socket_hosts_ports hosts="${line[2]:q}" ports "$expl[@]" fi ;; esac diff --git a/Completion/User/_ssh b/Completion/User/_ssh index 2c71b49a0..e7c6d37f6 100644 --- a/Completion/User/_ssh +++ b/Completion/User/_ssh @@ -1,7 +1,7 @@ #compdef ssh slogin scp ssh-add ssh-agent ssh-keygen _ssh () { - local context state lstate line ret=1 expl args tmp + local curcontext="$curcontext" state lstate line ret=1 expl args tmp typeset -A opt_args local accounts_users_hosts @@ -27,7 +27,7 @@ _ssh () { ) ;& ssh-opt) - _arguments -s \ + _arguments -C -s \ '-a[disable forwarding of authentication agent connection]' \ '-c[select encryption cipher]:encryption cipher:(idea des 3des blowfish arcfour tss none)' \ '-e[set escape character]:escape character (or `none'"'"'):' \ @@ -58,31 +58,25 @@ _ssh () { if compset -P '*[= ]'; then case "$IPREFIX" in *(#i)(batchmode|compression|fallbacktorsh|forward(agent|x11)|keepalive|passwordauthentication|rhosts(|rsa)authentication|rsaauthentication|usersh|kerberos(authetication|tgtparsing)|usepriviledgedport)*) - _tags "$context" values && compadd yes no && ret=0 + _wanted values expl 'truth value' && compadd "$expl[@]" yes no && + ret=0 ;; *(#i)cipher*) - if _tags "$context" values; then - _description expl 'encryption cipher' - compadd "$expl[@]" idea des 3des blowfish arcfour tss none && ret=0 - fi + _wanted values expl 'encryption cipher' && + compadd "$expl[@]" idea des 3des blowfish arcfour tss none && \ + ret=0 ;; *(#i)globalknownhostsfile*) - if _tags "$context" files; then - _description expl 'global file with known hosts' - _files "$expl[@]" && ret=0 - fi + _description expl 'global file with known hosts' + _files "$expl[@]" && ret=0 ;; *(#i)hostname*) - if _tags "$context" hosts; then - _description expl 'real host name to log into' - _ssh_hosts "$expl[@]" && ret=0 - fi + _wanted hosts expl 'real host name to log into' && + _ssh_hosts "$expl[@]" && ret=0 ;; *(#i)identityfile*) - if _tags "$context" files; then - _description expl 'SSH identity file' - _files "$expl[@]" && ret=0 - fi + _description expl 'SSH identity file' + _files "$expl[@]" && ret=0 ;; *(#i)(local|remote)forward*) state=forward @@ -94,44 +88,36 @@ _ssh () { _normal && ret=0 ;; *(#i)stricthostkeychecking*) - _tags "$context" values && compadd yes no ask + _wanted values expl 'checking type' && + compadd "$expl[@]" yes no ask ;; *(#i)userknownhostsfile*) - if _tags "$context" files; then - _description expl 'user file with known hosts' - _files "$expl[@]" && ret=0 - fi + _description expl 'user file with known hosts' + _files "$expl[@]" && ret=0 ;; *(#i)user*) - if _tags "$context" files; then - _description expl 'user to log in as' - _ssh_users "$expl[@]" && ret=0 - fi + _wanted users expl 'user to log in as' && + _ssh_users "$expl[@]" && ret=0 ;; *(#i)xauthlocation*) - if _tags "$context" files; then - _description expl 'xauth program' - _files "$expl[@]" -g '*(*)' && ret=0 - fi + _description expl 'xauth program' + _files "$expl[@]" -g '*(*)' && ret=0 ;; esac else - if _tags "$context" values; then - _description expl 'configure file option' - compadd "$expl[@]" -M 'm:{a-z}={A-Z}' -S '=' - \ - BatchMode ClearAllForwardings Cipher Compression \ - CompressionLevel Host ConnectionAttempts EscapeChar \ - FallBackToRsh ForwardAgent ForwardX11 \ - GlobalKnownHostsFile HostName IdentityFile KeepAlive \ - KerberosAuthentication KerberosTgtPassing LocalForward \ - NumberOfPasswordPrompts PasswordAuthentication Port \ - ProxyCommand RemoteForward RhostsAuthentication \ - RhostsRSAAuthentication RSAAuthentication \ - StrictHostKeyChecking TISAuthentication \ - UsePriviledgedPort User UserKnownHostsFile UseRsh \ - XAuthLocation \ - && ret=0 - fi + _wanted values expl 'configure file option' && + compadd "$expl[@]" -M 'm:{a-z}={A-Z}' -S '=' - \ + BatchMode ClearAllForwardings Cipher Compression \ + CompressionLevel Host ConnectionAttempts EscapeChar \ + FallBackToRsh ForwardAgent ForwardX11 \ + GlobalKnownHostsFile HostName IdentityFile KeepAlive \ + KerberosAuthentication KerberosTgtPassing LocalForward \ + NumberOfPasswordPrompts PasswordAuthentication Port \ + ProxyCommand RemoteForward RhostsAuthentication \ + RhostsRSAAuthentication RSAAuthentication \ + StrictHostKeyChecking TISAuthentication \ + UsePriviledgedPort User UserKnownHostsFile UseRsh \ + XAuthLocation && ret=0 fi ;; forward) @@ -139,7 +125,7 @@ _ssh () { if compset -P '*:'; then _message 'port number' else - _tags "$context" hosts && _ssh_hosts -S: -q + _wanted hosts expl host && _ssh_hosts -qS: "$expl[@]" fi else _message 'listen-port number' @@ -154,17 +140,15 @@ _ssh () { ;; userhost) if compset -P '*@'; then - if _tags "$context" hosts; then - _description expl 'remote host name' - _ssh_hosts "$expl[@]" && ret=0 - fi + _wanted hosts expl 'remote host name' && + _ssh_hosts "$expl[@]" && ret=0 else if (( $+opt_args[-l] )); then tmp=() else tmp=( 'users:login name:_ssh_users -qS@' ) fi - _alternative "$context" \ + _alternative \ 'hosts:remote host name:_ssh_hosts' \ "$tmp[@]" && ret=0 fi @@ -177,7 +161,7 @@ _ssh () { return ret ;; scp) - _arguments -s \ + _arguments -C -s \ '-c[select encryption cipher]:encryption cipher:(idea des 3des blowfish arcfour tss none)' \ '-P[specify port on remote host]:port number on remote host:' \ '-i[select identity file]:SSH identity file:_files' \ @@ -198,14 +182,14 @@ _ssh () { return elif [[ -n "$state" ]]; then if compset -P '*:'; then - _tags "$context" files && _files && ret=0 + _files && ret=0 elif compset -P '*@'; then - _tags "$context" hosts && _ssh_hosts -S: && ret=0 + _wanted hosts expl host && _ssh_hosts -S: "$expl[@]" && ret=0 else - _alternative "$context" \ + _alternative \ 'files:: _files' \ - 'hosts:: _ssh_hosts -S:' \ - 'users:: _ssh_users -S@' && ret=0 + 'hosts:host:_ssh_hosts -S:' \ + 'users:user:_ssh_users -S@' && ret=0 fi fi return ret @@ -243,12 +227,10 @@ _ssh () { } _ssh_users () { - _tags any users && _combination accounts_users_hosts users "$@" + _combination accounts_users_hosts users "$@" } _ssh_hosts () { - _tags any hosts || return 1 - if [[ "$IPREFIX" == *@ ]]; then _combination accounts_users_hosts "users=${IPREFIX/@}" hosts "$@" else diff --git a/Completion/User/_stty b/Completion/User/_stty index 45408fbc1..06d0bf851 100644 --- a/Completion/User/_stty +++ b/Completion/User/_stty @@ -3,18 +3,19 @@ local expl if [[ "$words[CURRENT-1]" = \ - (*erase|discard|status|dsusp|intr|kill|lnext|quit|reprint|start|s*p) ]] -then - _description expl 'control character' - compadd "$expl[@]" '^-' '^h' '^?' '^c' '^u' + (*erase|discard|status|dsusp|intr|kill|lnext|quit|reprint|start|s*p) ]]; then + _wanted characters expl 'control character' && + compadd "$expl[@]" '^-' '^h' '^?' '^c' '^u' else - _description expl setting compset -P '[-+]' - compadd "$expl[@]" rows columns intr quit erase kill eof eol \ - eol2 start stop susp dsusp reprint discard werase lnext \ - parenb parodd cs8 cstopb hupcl cread clocal parext \ - ignbrk brkint ignpar parmrk inpck istrip inlcr igncr icrnl iuclc \ - ixon ixany ixoff imaxbel isig icanon xcase echo echoe echok \ - echonl noflsh tostop echoctl echoprt echoke flusho pending iexten \ - opost olcuc onlcr ocrnl onocr onlret ofill ofdel + _wanted values expl setting && + compadd "$expl[@]" rows columns intr quit erase kill eof eol \ + eol2 start stop susp dsusp reprint discard \ + werase lnext parenb parodd cs8 cstopb hupcl \ + cread clocal parext ignbrk brkint ignpar \ + parmrk inpck istrip inlcr igncr icrnl iuclc \ + ixon ixany ixoff imaxbel isig icanon xcase \ + echo echoe echok echonl noflsh tostop echoctl \ + echoprt echoke flusho pending iexten opost \ + olcuc onlcr ocrnl onocr onlret ofill ofdel fi diff --git a/Completion/User/_tar b/Completion/User/_tar index d779f6cf1..defaaf39a 100644 --- a/Completion/User/_tar +++ b/Completion/User/_tar @@ -37,10 +37,10 @@ if [[ "$words[2]" = *[txcdruA]*~-* ]]; then elif [[ $_tar_cmd != *[txcdruA]* && CURRENT -gt 2 ]]; then # look for more obscure long options: these aren't all handled. (( $words[(I)--(diff|compare)] )) && _tar_cmd="d$_tar_cmd" - (( $words[(I)--append] )) && _tar_cmd="r$_tar_cmd" - (( $words[(I)--update] )) && _tar_cmd="u$_tar_cmd" + (( $words[(I)--append] )) && _tar_cmd="r$_tar_cmd" + (( $words[(I)--update] )) && _tar_cmd="u$_tar_cmd" (( $words[(I)--(con|)catenate] )) && _tar_cmd="A$_tar_cmd" - (( $words[(I)--delete] )) && del=1 + (( $words[(I)--delete] )) && del=1 fi # Next, we try to find the archive name and store it in `tf'. The name @@ -107,8 +107,8 @@ elif [[ ( "$_tar_cmd" = *[xt]* || -n $del ) && -n "$tf" ]]; then _tar_cache_name=$tf fi - _description expl 'file from archive' - _multi_parts "$expl[@]" / _tar_cache_list + _wanted archived-files expl 'file from archive' && + _multi_parts "$expl[@]" / _tar_cache_list else # See if we should use a path prefix. We have to use eval as the dir can diff --git a/Completion/User/_telnet b/Completion/User/_telnet index 8e584b040..597c0a021 100644 --- a/Completion/User/_telnet +++ b/Completion/User/_telnet @@ -5,7 +5,7 @@ # telnet_hosts_ports_users # The array that contains 3-tuples `host:port:user'. -local context state line expl +local curcontext="$curcontext" state line expl typeset -A opt_args if (( ! $+_telnet_short )); then @@ -52,44 +52,36 @@ if (( ! $+_telnet_short )); then done fi -if _tags any options && (( $#_telnet_long )) && - { ! _style options prefix-needed yes || [[ "$PREFIX" = [-+]* ]] } ; then - _description expl 'option' - _describe -o option _telnet_long "$expl[@]" -fi +(( $#_telnet_long )) && _wanted options expl option && + { ! _style options prefix-needed || [[ "$PREFIX" = [-+]* ]] } && + _describe -o option _telnet_long "$expl[@]" -_arguments -s \ +_arguments -C -s \ "$_telnet_short[@]" \ ':host:->hosts' \ ':port:->ports' case "$state" in hosts) - _tags "$context" hosts || return 1 - - _description expl 'host' - _combination telnet_hosts_ports_users \ - ${opt_args[-l]:+users=${opt_args[-l]:q}} \ - hosts "$expl[@]" + _wanted hosts expl host && + _combination telnet_hosts_ports_users \ + ${opt_args[-l]:+users=${opt_args[-l]:q}} \ + hosts "$expl[@]" ;; ports) - _tags "$context" ports || return 1 - - _description expl 'port' - _combination telnet_hosts_ports_users \ - ${opt_args[-l]:+users=${opt_args[-l]:q}} \ - hosts="${line[2]:q}" \ - ports "$expl[@]" + _wanted ports expl port && + _combination telnet_hosts_ports_users \ + ${opt_args[-l]:+users=${opt_args[-l]:q}} \ + hosts="${line[2]:q}" \ + ports "$expl[@]" ;; users) - _tags "$context" users || return 1 - - _description expl 'user' - _combination telnet_hosts_ports_users \ - ${line[2]:+hosts="${line[2]:q}"} \ - ${line[3]:+ports="${line[3]:q}"} \ - users "$expl[@]" + _wanted users expl user && + _combination telnet_hosts_ports_users \ + ${line[2]:+hosts="${line[2]:q}"} \ + ${line[3]:+ports="${line[3]:q}"} \ + users "$expl[@]" ;; esac diff --git a/Completion/User/_tiff b/Completion/User/_tiff index e3a023c24..27ab33227 100644 --- a/Completion/User/_tiff +++ b/Completion/User/_tiff @@ -19,12 +19,12 @@ fi local _in_tiff=yes -local context state line ret=1 +local curcontext="$curcontext" state line ret=1 typeset -A opt_args case "$words[1]" in tiff2bw) - _arguments \ + _arguments -C \ '-c[specify compression scheme]:compression scheme:->compress' \ '-r[specify rows per strip]:rows per strip:' \ '-R[specify percentage of red channel]:percentage of red channel:' \ @@ -59,7 +59,7 @@ tiffcmp) ':second input TIFF file:_files -g \*.\(\#i\)' && ret=0 ;; tiffcp) - _arguments \ + _arguments -C \ '-B[write output in bin-endian byte order]' \ '-c[specify compression scheme]:compression scheme:->compress' \ '-o[set initial TIFF directory (file offset)]:file offset:' \ @@ -74,7 +74,7 @@ tiffcp) '*:input TIFF file:_files -g \*.\(\#i\)' && ret=0 ;; tiffdither) - _arguments \ + _arguments -C \ '-c[specify compression scheme]:compression scheme:->compress' \ '-f[specify fill order]:fill order:(lsb2msb msb2lsb)' \ '-r[specify rows per strip]:rows per strip:' \ @@ -102,7 +102,7 @@ tiffinfo) '*:input TIFF file:_files -g \*.\(\#i\)' && ret=0 ;; tiffmedian) - _arguments \ + _arguments -C \ '-r[specify rows per strip]:rows per strip:' \ '-C[specify number of colormap entries]:number of colormap entries:' \ '-c[specify compression scheme]:compression scheme:->compress' \ @@ -135,14 +135,14 @@ fax2tiff) ':FAX input file:_files -g \*.\(\#i\)\(g\[34\]\|fax\)' && ret=0 ;; gif2tiff) - _arguments \ + _arguments -C \ '-r[specify rows per strip]:rows per strip:' \ '-c[specify compression scheme]:compression scheme:->compress' \ ':input GIF file:_files -g \*.\(\#i\)gif' \ ':output file:_files -g \*.\(\#i\)tiff' && ret=0 ;; ppm2tiff) - _arguments \ + _arguments -C \ '-r[specify rows per strip]:rows per strip:' \ '-c[specify compression scheme]:compression scheme:->compress' \ '-R[specify resolution]:resolution:' \ @@ -150,14 +150,14 @@ ppm2tiff) ':output file:_files -g \*.\(\#i\)tiff' && ret=0 ;; ras2tiff) - _arguments \ + _arguments -C \ '-r[specify rows per strip]:rows per strip:' \ '-c[specify compression scheme]:compression scheme:->compress' \ ':input raster image file:_files -g \*.\(\#i\)ras\(\|t\)' \ ':output file:_files -g \*.\(\#i\)tiff' && ret=0 ;; pal2rgb) - _arguments \ + _arguments -C \ '-C[specify number of bits for colormap entries]:bits for colormap entries:(8 16)' \ '-p[set sample packing]:sample packing:(contig separate)' \ '-c[specify compression scheme]:compression scheme:->compress' \ @@ -194,11 +194,10 @@ if [[ -n "$state" ]]; then ;; esac else - _tags "$context" values || return 1 - - _description expl 'compression scheme' - compadd "$expl[@]" - none g4 packbits && ret=0 - compadd "$expl[@]" -qS: - lzw zip jpeg g3 && ret=0 + if _wanted values expl 'compression scheme'; then + compadd "$expl[@]" - none g4 packbits && ret=0 + compadd "$expl[@]" -qS: - lzw zip jpeg g3 && ret=0 + fi fi fi diff --git a/Completion/User/_urls b/Completion/User/_urls index 8c0c6f8d8..787f3c0ca 100644 --- a/Completion/User/_urls +++ b/Completion/User/_urls @@ -4,9 +4,9 @@ # Options: # -f : complete files first. # -# Configuration keys used: +# Configuration styles used: # -# urls_path +# urls:path # The path to a directory containing a URL database, such as: # # % cd ~/.zsh/urls @@ -29,90 +29,91 @@ # % cat bookmark/zsh/meta # http://www.zsh.org/ # -# urls_localhttp -# Specify a local web server in the form: -# hostname:doc root:user area +# urls:local +# Specify a local web server as an array with three elements: +# <hostname> <doc root> <user area> # where hostname is the name of the web server, doc root is the path to # the default web pages for the server and user area is the directory # name used by a user placing web pages within their home area. -# e.g. compconf urls_localhttp=www:/usr/local/apache/htdocs:public_html +# E.g.: +# compstyle '*:urls:local' www /usr/local/apache/htdocs public_html local ipre scheme host user uhosts ret=1 expl -local urls_path="${compconfig[urls_path]:-${ZDOTDIR:-$HOME}/.zsh/urls}" -local localhttp_servername="${${(@s.:.)compconfig[urls_localhttp]}[1]}" -local localhttp_documentroot="${${(@s.:.)compconfig[urls_localhttp]}[2]}" -local localhttp_userdir="${${(@s.:.)compconfig[urls_localhttp]}[3]}" +local urls_path localhttp +_style -s urls path urls_path || urls_path="${ZDOTDIR:-$HOME}/.zsh/urls" +_style -a urls local localhttp +local localhttp_servername="$localhttp[1]" +local localhttp_documentroot="$localhttp[2]" +local localhttp_userdir="$localhttp[3]" if [[ "$1" = -f ]]; then shift - _tags argument:-f files && _files "$@" && return + _tags -C -f files && _files "$@" && return fi ipre="$IPREFIX" if ! compset -P '(#b)([-+.a-z0-9]#):' && - _tags argument prefixes; then - _description expl 'URL prefix' + _wanted argument prefixes expl 'URL prefix'; then [[ -d $urls_path/bookmark ]] && compadd "$@" "$expl[@]" -S '' bookmark: && ret=0 compadd "$@" "$expl[@]" -S '' file: ftp:// gopher:// http:// && ret=0 - return $ret + return ret fi scheme="$match[1]" case "$scheme" in http|ftp|gopher) if ! compset -P //; then - _tags "$scheme" slashes && compadd "$@" -S '' // + _wanted -C "$scheme" slashes expl 'end of prefix' && + compadd "$expl[@]" "$@" -S '' // return fi ;; file) if ! compset -P //; then - _tags file files || return 1 + _wanted -C file files expl 'local file' || return 1 if [[ -prefix / ]]; then - _path_files "$@" -S '' -g '*(^/)' && ret=0 - _path_files "$@" -S/ -r '/' -/ && ret=0 + _path_files "$expl[@]" "$@" -S '' -g '*(^/)' && ret=0 + _path_files "$expl[@]" "$@" -S/ -r '/' -/ && ret=0 elif [[ -z "$PREFIX" ]]; then - compadd -S '/' -r '/' - "${PWD%/}" - ret=0 + compadd "$expl[@]" -S '/' -r '/' - "${PWD%/}" && ret=0 fi - return $ret + return ret fi ;; bookmark) if [[ -f "$urls_path/$scheme/$PREFIX$SUFFIX" && -s "$urls_path/$scheme/$PREFIX$SUFFIX" ]]; then - _tags bookmark caches || return 1 - - compadd "$@" -QU -- "$ipre$(<"$urls_path/$scheme/$PREFIX$SUFFIX")" && ret=0 + _wanted -C bookmark caches expl biikmarks && + compadd "$expl[@]" "$@" -QU - \ + "$ipre$(<"$urls_path/$scheme/$PREFIX$SUFFIX")" && ret=0 else - _tags bookmark files || return 1 - - _description expl 'bookmark' - _path_files -W "$urls_path/$scheme" "$expl[@]" -S '' -g '*(^/)' && ret=0 - _path_files -W "$urls_path/$scheme" -S/ -r '/' -/ && ret=0 + if _wanted -C bookmark files 'bookmark'; then + _path_files -W "$urls_path/$scheme" "$expl[@]" -S '' -g '*(^/)' && + ret=0 + _path_files -W "$urls_path/$scheme" -S/ -r '/' -/ && ret=0 + fi fi - return $ret + return ret ;; esac # Complete hosts if ! compset -P '(#b)([^/]#)/' && - _tags argument hosts; then + _wanted hosts expl host; then uhosts=($urls_path/$scheme/$PREFIX*$SUFFIX(/:t)) (( $#uhosts )) || _hosts -S/ && ret=0 [[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername) - _description expl host compadd "$expl[@]" "$@" -QS/ - $uhosts && ret=0 - return $ret + return ret fi host="$match[1]" # Complete part after hostname -_tags local files || return 1 +_wanted -C local files expl 'local file' || return 1 if [[ "$localhttp_servername" = "$host" ]]; then if compset -P \~; then @@ -121,14 +122,14 @@ if [[ "$localhttp_servername" = "$host" ]]; then return fi user="$match[1]" - _path_files -W ~$user/$localhttp_userdir -g '*(^/)' && ret=0 - _path_files -W ~$user/$localhttp_userdir -S/ -r '/' -/ && ret=0 + _path_files "$expl[@]" -W ~$user/$localhttp_userdir -g '*(^/)' && ret=0 + _path_files "$expl[@]" -W ~$user/$localhttp_userdir -S/ -r '/' -/ && ret=0 else - _path_files -W $localhttp_documentroot -g '*(^/)' && ret=0 - _path_files -W $localhttp_documentroot -S/ -r '/' -/ && ret=0 + _path_files "$expl[@]" -W $localhttp_documentroot -g '*(^/)' && ret=0 + _path_files "$expl[@]" -W $localhttp_documentroot -S/ -r '/' -/ && ret=0 fi else - _path_files -W $urls_path/$scheme/$host -g '*(^/)' && ret=0 - _path_files -W $urls_path/$scheme/$host -S/ -r '/' -/ && ret=0 + _path_files "$expl[@]" -W $urls_path/$scheme/$host -g '*(^/)' && ret=0 + _path_files "$expl[@]" -W $urls_path/$scheme/$host -S/ -r '/' -/ && ret=0 fi return $ret diff --git a/Completion/User/_use_lo b/Completion/User/_use_lo index 56651dd67..5f2210997 100644 --- a/Completion/User/_use_lo +++ b/Completion/User/_use_lo @@ -3,6 +3,4 @@ # This is for GNU-like commands which understand the --help option, # but which do not otherwise require special completion handling. -[[ "$PREFIX" = --* ]] && _arguments -- && return 0 - -_default +_arguments || _default diff --git a/Completion/User/_user_at_host b/Completion/User/_user_at_host index c33a024d9..1f93daacc 100644 --- a/Completion/User/_user_at_host +++ b/Completion/User/_user_at_host @@ -1,17 +1,13 @@ #autoload if [[ -prefix 1 *@ ]]; then - - _tags any:user-at hosts || return 1 - local user=${PREFIX/@} compset -P 1 '*@' - _description expl "hostnames for $user" - _combination accounts_users_hosts users="$user" hosts "$expl[@]" "$@" -else - _tags any users || return 1 - _description expl "usernames" - _combination accounts_users_hosts users -S@ -q "$expl[@]" "$@" + _wanted -C user-at hosts expl "hostnames for $user" && + _combination accounts_users_hosts users="$user" hosts "$expl[@]" "$@" +else + _wanted users expl "usernames" && + _combination accounts_users_hosts users -S@ -q "$expl[@]" "$@" fi diff --git a/Completion/User/_users b/Completion/User/_users index 9f2751c11..fdef36073 100644 --- a/Completion/User/_users +++ b/Completion/User/_users @@ -5,9 +5,7 @@ local expl -_tags any users || return 1 - -_description expl user +_wanted users expl user || return 1 [[ "${(t)users}" = *array* ]] && compadd "$expl[@]" "$@" - "$users[@]" && return 0 diff --git a/Completion/User/_users_on b/Completion/User/_users_on index 221ebb0fd..3d35af02b 100644 --- a/Completion/User/_users_on +++ b/Completion/User/_users_on @@ -2,7 +2,7 @@ local expl -_tags any users || return 1 +_tags users || return 1 if which users >/dev/null; then _description expl 'users logged on' diff --git a/Completion/User/_wget b/Completion/User/_wget index 3a15d3867..8e73bd45d 100644 --- a/Completion/User/_wget +++ b/Completion/User/_wget @@ -1,11 +1,11 @@ #compdef wget -local context state line +local curcontext="$curcontext" state line typeset -A opt_args local tmp1 tmp2 -_arguments -s \ +_arguments -C -s \ '(--version)-V[version]' '(-V)--version' \ '(--help)-h[help]' '(-h)--help' \ '(--background)-b[background]' '(-b)--background' \ diff --git a/Completion/User/_whois b/Completion/User/_whois index 1e0f7707c..97306871e 100644 --- a/Completion/User/_whois +++ b/Completion/User/_whois @@ -102,7 +102,7 @@ _whois_setup () { if (( $#opts )); then opts="($opts)"; else opts=; fi if [[ $opt = h ]]; then _whois_arguments=("$_whois_arguments[@]" - "${opts}${hostopt}[specify host]:host:_whois_hosts") + "${opts}${hostopt}:host:_whois_hosts") else _whois_arguments=("$_whois_arguments[@]" "${opts}-${opt}[${${(@M)_whois_servers:#*:$opt}%:?}]") @@ -112,11 +112,11 @@ _whois_setup () { } _whois_single () { - local context state line expl + local curcontext="$curcontext" state line expl typeset -A opt_args local tmp host - _arguments \ + _arguments -C \ "$_whois_arguments[@]" \ ':identifier:->identifier' @@ -144,11 +144,11 @@ _whois_single () { } _whois_multi () { - local state line expl + local curcontext="$curcontext" state line expl typeset -A opt_args local tmp host - _arguments \ + _arguments -C \ "$_whois_arguments[@]" \ '*::identifier:->identifier' @@ -189,14 +189,14 @@ _whois_fwhois () { } _whois_hosts () { - _tags any hosts && + _tags hosts && compadd "$@" \ -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' \ - ${_whois_servers%:?} || _hosts "$@" } _whois_ports () { - _tags any ports && compadd "$@" - whois || _ports "$@" + _tags ports && compadd "$@" - whois || _ports "$@" } (( $+functions[_whois:whois.internic.net] )) || @@ -204,10 +204,7 @@ _whois:whois.internic.net () { if (( CURRENT == 1 )); then local expl - _tags any string || return 1 - - _description expl string - compadd "$expl[@]" HELP DOMAIN HOST + _wanted string expl string && compadd "$expl[@]" HELP DOMAIN HOST else _message 'string' fi @@ -218,10 +215,7 @@ _whois:whois.nic.ad.jp () { if (( CURRENT == 1 )); then local expl - _tags any string || return 1 - - _description expl string - compadd HELP DOM NET HOST PERSON CONN COM + _wanted string expl string && compadd HELP DOM NET HOST PERSON CONN COM else _message 'string' fi diff --git a/Completion/User/_yp b/Completion/User/_yp index d0876f6dd..1e86bf278 100644 --- a/Completion/User/_yp +++ b/Completion/User/_yp @@ -1,6 +1,6 @@ #compdef ypcat ypmatch yppasswd ypwhich ypset ypserv ypbind yppush yppoll ypxfr domainname -local context line state ret=1 +local curcontext="$curcontext" line state ret=1 typeset -A opt_args if (( ! $+_yp_cache_maps )); then @@ -16,17 +16,17 @@ fi case "$words[1]" in ypcat) - _arguments -s "$_yp_args[@]" ':map name:->map' && ret=0 + _arguments -C -s "$_yp_args[@]" ':map name:->map' && ret=0 ;; ypmatch) - _arguments -s "$_yp_args[@]" '*::key map:->keymap' && ret=0 + _arguments -C -s "$_yp_args[@]" '*::key map:->keymap' && ret=0 ;; yppasswd) _users return ;; ypwhich) - _arguments \ + _arguments -C \ '(-x)-d[specify domain]:domain name:' \ '(-x -V2 -m -t)-V1[identify version 1 servers]' \ '(-x -V1 -m -t)-V2[identify version 2 servers]' \ @@ -36,7 +36,7 @@ ypwhich) ':host:_hosts' && ret=0 ;; ypset) - _arguments \ + _arguments -C \ '(-V2)-V1[bind version 1 servers]' \ '(-V1)-V2[bind version 2 servers]' \ '-d[specify domain]:domain name:' \ @@ -44,30 +44,30 @@ ypset) ':server:_hosts' && ret=0 ;; ypserv) - _arguments \ + _arguments -C \ '-a[specify database routines]:database routines:((b\:btree d\:dbm/ndbm h\:hash))' && ret=0 ;; ypbind) - _arguments \ + _arguments -C \ '-s[allow secure mode for ypbind]' \ '-S[set domain and servers]:domain:->servers' \ '(-ypsetme)-ypset[accept all ypset requests]' \ '(-ypset)-ypsetme[accept only local ypset requests]' && ret=0 ;; yppush) - _arguments \ + _arguments -C \ '-d[specify domain]:domain name:' \ '-v[print messages]' \ ':map name:->map' && ret=0 ;; yppoll) - _arguments \ + _arguments -C \ '-d[specify domain]:domain name:' \ '-h[specify host]:ask server on host:_hosts' \ ':map name:->map' && ret=0 ;; ypxfr) - _arguments \ + _arguments -C \ '-a[specify database routines]:database routines:((b\:btree d\:dbm/ndbm h\:hash))' \ '-f[force transfer]' \ '-c[don'"'"'t clear current map]' \ @@ -88,30 +88,22 @@ if [[ "$state" = map* ]]; then local expl if [[ $+opt_args[-t] -eq 0 && "$state" != maponly ]]; then - _tags "$context" maps nicknames + _tags maps nicknames else - _tags "$context" maps + _tags maps fi while _tags; do - if _requested maps; then - # The `-M ...' allows `pa.n<TAB>' to complete to `passwd.byname'. - - _description expl 'map name' - compadd "$expl[@]" -M 'l:.|by=by l:.|=by r:|.=* r:|=*' - \ - "$_yp_cache_maps[@]" && ret=0 - fi - if _requested nicknames; then - _description expl 'nicknames' - compadd "$expl[@]" - "$_yp_cache_nicks[@]" && ret=0 - fi + # The `-M ...' allows `pa.n<TAB>' to complete to `passwd.byname'. + _requested maps expl 'map name' && + compadd "$expl[@]" -M 'l:.|by=by l:.|=by r:|.=* r:|=*' - \ + "$_yp_cache_maps[@]" && ret=0 + _requested nicknames expl nicknames && + compadd "$expl[@]" - "$_yp_cache_nicks[@]" && ret=0 done elif [[ "$state" = servers ]]; then if compset -P '*,'; then - if _tags "$context" hosts; then - _description expl 'server' - _hosts -qS, && ret=0 - fi + _wanted hosts expl server && _hosts -qS, && ret=0 else _message 'domain name' fi |