diff options
Diffstat (limited to 'Completion/User')
-rw-r--r-- | Completion/User/_cvs | 1190 | ||||
-rw-r--r-- | Completion/User/_gdb | 5 | ||||
-rw-r--r-- | Completion/User/_gprof | 60 | ||||
-rw-r--r-- | Completion/User/_groups | 4 | ||||
-rw-r--r-- | Completion/User/_lp | 35 | ||||
-rw-r--r-- | Completion/User/_mh | 15 | ||||
-rw-r--r-- | Completion/User/_mount | 2 | ||||
-rw-r--r-- | Completion/User/_netscape | 24 | ||||
-rw-r--r-- | Completion/User/_nslookup | 52 | ||||
-rw-r--r-- | Completion/User/_rlogin | 8 | ||||
-rw-r--r-- | Completion/User/_socket | 49 | ||||
-rw-r--r-- | Completion/User/_tiff | 6 | ||||
-rw-r--r-- | Completion/User/_urls | 91 | ||||
-rw-r--r-- | Completion/User/_users | 6 | ||||
-rw-r--r-- | Completion/User/_users_on | 6 | ||||
-rw-r--r-- | Completion/User/_whois | 61 |
16 files changed, 845 insertions, 769 deletions
diff --git a/Completion/User/_cvs b/Completion/User/_cvs index 356c7a80a..ce928fe50 100644 --- a/Completion/User/_cvs +++ b/Completion/User/_cvs @@ -19,662 +19,640 @@ _cvs () { # define cvs command dispatch function. -if ! builtin functions _cvs_command >&-; then - _cvs_command () { - typeset -A cmds - cmds=(add " ad new " admin " adm rcs " annotate " ann " - checkout " co get " commit " ci com " diff " di dif " - edit "" editors "" export " exp ex " - history " hi his " import " im imp " init "" - log " lo rlog " login " logon lgn " logout "" - rdiff " patch pa " release " re rel " remove " rm delete " - status " st stat " rtag " rt rfreeze " tag " ta freeze " - unedit "" update " up upd " watch "" - watchers "") - - if (( CURRENT == 1 )); then - compadd "$@" ${(k)cmds} || compadd "$@" ${(kv)=cmds} +(( $+functions[_cvs_command] )) || +_cvs_command () { + local cmd + typeset -A cmds + cmds=(add " ad new " admin " adm rcs " annotate " ann " + checkout " co get " commit " ci com " diff " di dif " + edit "" editors "" export " exp ex " + history " hi his " import " im imp " init "" + log " lo rlog " login " logon lgn " logout "" + rdiff " patch pa " release " re rel " remove " rm delete " + status " st stat " rtag " rt rfreeze " tag " ta freeze " + unedit "" update " up upd " watch "" + watchers "") + + if (( CURRENT == 1 )); then + _tags commands && { compadd "$@" ${(k)cmds} || compadd "$@" ${(kv)=cmds} } + else + local curcontext="$curcontext" + + cmd="${${(k)cmds[(R)* $words[1] *]}:-${(k)cmds[(i)$words[1]]}}" + if (( $#cmd )); then + curcontext="${curcontext%:*:*}:cvs-${cmd}:" + _cvs_$cmd else - case "${${(k)cmds[(R)* $words[1] *]}:-$words[1]}" in - add) _cvs_add;; - admin) _cvs_admin;; - annotate) _cvs_annotate;; - checkout) _cvs_checkout;; - commit) _cvs_commit;; - diff) _cvs_diff;; - edit) _cvs_edit;; - editors) _cvs_editors;; - export) _cvs_export;; - history) _cvs_history;; - import) _cvs_import;; - init) _cvs_init;; - log) _cvs_log;; - login) _cvs_login;; - logout) _cvs_logout;; - rdiff) _cvs_rdiff;; - release) _cvs_release;; - remove) _cvs_remove;; - status) _cvs_status;; - rtag) _cvs_rtag;; - tag) _cvs_tag;; - unedit) _cvs_unedit;; - update) _cvs_update;; - watch) _cvs_watch;; - watchers) _cvs_watchers;; - *) _message "unknown cvs command: $words[1]";; - esac + _message "unknown cvs command: $words[1]" fi - } -fi + fi +} # define completion functions for each cvs command -if ! builtin functions _cvs_add >&-; then - _cvs_add () { - # "+k:m:" - _arguments -s \ - '-k+:keyword substitution:_cvs_k' \ - '-m+:message:_cvs_m' \ - '*:file:_cvs_files_unmaintained' \ - } -fi - -if ! builtin functions _cvs_admin >&-; then - _cvs_admin () { - # "+ib::c:a:A:e:l::u::LUn:N:m:o:s:t::IqxV:k:" - _arguments -s \ - -{i,L,U,I,q,x} \ - '-b-:default branch:(1.1.1)' \ - '-c+:comment leader (not used):' \ - '-a+:login names (not work with CVS):' \ - '-A+:access list to append (not work with CVS):' \ - '-e+:access list to erase (not work with CVS):' \ - '-l-:revision to lock:' \ - '-u-:revision to unlock:' \ - '-n+:symbolic-name[\:revision]:' \ - '-N+:symbolic-name[\:revision]:' \ - '-m+:revision\:msg:' \ - '-o+:range to delete:' \ - '-s+:state[\:revision]:' \ - '-t-:descriptive text:_cvs_admin_t' \ - '-V+:version (obsolete):' \ - '-k+:keyword substitution:_cvs_k' \ - '*:file:_cvs_files' - } -fi +(( $+functions[_cvs_add] )) || +_cvs_add () { + # "+k:m:" + _arguments -s \ + '-k+:keyword substitution:_cvs_k' \ + '-m+:message:_cvs_m' \ + '*:file:_cvs_files_unmaintained' \ +} -if ! builtin functions _cvs_admin_t >&-; then - _cvs_admin_t () { - if compset -P -; then - _message 'descriptive text' - else - _files "$@" - fi - } -fi - -if ! builtin functions _cvs_annotate >&-; then - _cvs_annotate () { - # "+lr:D:fR" - _arguments -s \ - -{l,f,R} \ - '-r+:tag:_cvs_revisions' \ - '-D+:date:_cvs_D' \ - '*:file:_cvs_files' - } -fi - -if ! builtin functions _cvs_checkout >&-; then - _cvs_checkout () { - # "+ANnk:d:flRpQqcsr:D:j:P" - _arguments -s \ - -{A,N,n,f,l,R,q,c,s,P} \ - '-k+:keyword substitution:_cvs_k' \ - '-d+:directory:_files -/' \ - '-r+:tag:_cvs_revisions' \ - '-D+:date:_cvs_D' \ - '-j+:tag:_cvs_revisions' \ - '*:module:_cvs_modules' - } -fi - -if ! builtin functions _cvs_commit >&-; then - _cvs_commit () { - # "+nlRm:fF:r:" - _arguments -s \ - -{n,l,R,f} \ - '-m+:message:_cvs_m' \ - '-F+:log message file:_files' \ - '-r+:tag:_cvs_revisions' \ - '*:file:_cvs_files_modified' - } -fi +(( $+functions[_cvs_admin] )) || +_cvs_admin () { + # "+ib::c:a:A:e:l::u::LUn:N:m:o:s:t::IqxV:k:" + _arguments -s \ + -{i,L,U,I,q,x} \ + '-b-:default branch:(1.1.1)' \ + '-c+:comment leader (not used):' \ + '-a+:login names (not work with CVS):' \ + '-A+:access list to append (not work with CVS):' \ + '-e+:access list to erase (not work with CVS):' \ + '-l-:revision to lock:' \ + '-u-:revision to unlock:' \ + '-n+:symbolic-name(\:revision):' \ + '-N+:symbolic-name(\:revision):' \ + '-m+:revision\:msg:' \ + '-o+:range to delete:' \ + '-s+:state(\:revision):' \ + '-t-:descriptive text:_cvs_admin_t' \ + '-V+:version (obsolete):' \ + '-k+:keyword substitution:_cvs_k' \ + '*:file:_cvs_files' +} -if ! builtin functions _cvs_diff >&-; then - _cvs_diff () { - # "+abcdefhilnpstuw0123456789BHNRC:D:F:I:L:U:V:W:k:r:" - _arguments -s \ - -{l,R} \ - '-D+:date:_cvs_D' \ - '-k+:keyword substitution:_cvs_k' \ - '-r+:tag:_cvs_revisions' \ - -{h,p,0,1,2,3,4,5,6,7,8,9} \ - '--binary' \ - '--brief' \ - '--changed-group-format=:format:' \ - '-c' '-C+:lines:' '--context=-:lines:' \ - '-e' '--ed' \ - '-t' '--expand-tabs' \ - '-f' '--forward-ed' \ - '--horizon-lines=:lines:' \ - '--ifdef=:name:' \ - '-w' '--ignore-all-space' \ - '-B' '--ignore-blank-lines' \ - '-i' '--ignore-case' \ - '-I+:regex:' '--ignore-matching-lines=:regex:' \ - '-b' '--ignore-space-change' \ - '--initial-tab' \ - '*-L+:label:' '*--label=:label:' \ - '--left-column' \ - '--line-format=:format:' \ - '-d' '--minimal' \ - '-N' '--new-file' \ - '--new-group-format=:format:' \ - '--new-line-format=:format:' \ - '--old-group-format=:format:' \ - '--old-line-format=:format:' \ - '--paginate' \ - '-n' '--rcs' \ - '-s' '--report-identical-files' \ - '--show-c-function' \ - '-F+:regex:' '--show-function-line=:regex:' \ - '-y' '--side-by-side' \ - '-H' '--speed-large-files' \ - '--suppress-common-lines' \ - '-a' '--text' \ - '--unchanged-group-format=:format:' \ - '--unchanged-line-format=:format:' \ - '-u' '-U+:lines:' '--unified=-:lines:' \ - '-W:columns:' '--width=:columns:' \ - '*:file:_cvs_diff_arg' - } -fi +(( $+functions[_cvs_admin_t] )) || +_cvs_admin_t () { + if compset -P -; then + _message 'descriptive text' + else + _files "$@" + fi +} -if ! builtin functions _cvs_diff_arg >&-; then - _cvs_diff_arg () { - _cvs_files_modified || _cvs_files - } -fi +(( $+functions[_cvs_annotate] )) || +_cvs_annotate () { + # "+lr:D:fR" + _arguments -s \ + -{l,f,R} \ + '-r+:tag:_cvs_revisions' \ + '-D+:date:_cvs_D' \ + '*:file:_cvs_files' +} -if ! builtin functions _cvs_edit >&-; then - _cvs_edit () { - # "+lRa:" - _arguments -s \ - -{l,R} \ - '-a+:action:(edit unedit commit all none)' - '*:file:_cvs_files' - } -fi +(( $+functions[_cvs_checkout] )) || +_cvs_checkout () { + # "+ANnk:d:flRpQqcsr:D:j:P" + _arguments -s \ + -{A,N,n,f,l,R,q,c,s,P} \ + '-k+:keyword substitution:_cvs_k' \ + '-d+:directory:_files -/' \ + '-r+:tag:_cvs_revisions' \ + '-D+:date:_cvs_D' \ + '-j+:tag:_cvs_revisions' \ + '*:module:_cvs_modules' +} -if ! builtin functions _cvs_editors >&-; then - _cvs_editors () { - # "+lR" - _arguments -s \ - -{l,R} \ - '*:file:_cvs_files' - } -fi - -if ! builtin functions _cvs_export >&-; then - _cvs_export () { - # "+Nnk:d:flRQqr:D:" - _arguments -s \ - -{N,n,f,l,R,Q,q} \ - '-k+:keyword substitution:_cvs_k' \ - '-d+:directory:_files -/' \ - '-r+:tag:_cvs_revisions' \ - '-D+:date:_cvs_D' \ - '*:module:_cvs_modules' - } -fi - -if ! builtin functions _cvs_history >&-; then - _cvs_history () { - # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:" - _arguments -s \ - -{T,a,c,e,l,o,w,\?} \ - '-D+:date:_cvs_D' \ - '-b+:string:' \ - '-f+:arg:' \ - '-m+:module:_cvs_modules' \ - '-n+:arg:' \ - '*-p+:repository:' \ - '-r+:rev:' \ - '-t+:tag:' \ - '-u+:user name:' \ - '-x+:type:_cvs_history_x' \ - '-X+:arg:' \ - '-z+:arg:' \ - '*:file:_cvs_files' - } -fi - -if ! builtin functions _cvs_history_x >&-; then - _cvs_history_x () { - compset -P '*' - - compadd "$@" -y '( - F\ --\ release - O\ --\ checkout - E\ --\ export - T\ --\ rtag - C\ --\ merge\ collision-detected - G\ --\ merge\ succeed - U\ --\ working\ file\ was\ copied - W\ --\ working\ file\ was\ deleted - A\ --\ A\ file\ was\ added - M\ --\ A\ file\ was\ modified - R\ --\ A\ file\ was\ removed - )' F O E T C G U W A M R - } -fi - -if ! builtin functions _cvs_import >&-; then - _cvs_import () { - # "+Qqdb:m:I:k:W:" - _arguments -s \ - -{Q,q,d} \ - '-b+:branch:' \ - '-m+:message:_cvs_m' \ - '*-I+:name:_files' \ - '-k+:keyword substitution:_cvs_k' \ - '*-W+:spec:' \ - ':repository:_cvs_modules' \ - ':vendor tag:' \ - ':release tag:' - } -fi +(( $+functions[_cvs_commit] )) || +_cvs_commit () { + # "+nlRm:fF:r:" + _arguments -s \ + -{n,l,R,f} \ + '-m+:message:_cvs_m' \ + '-F+:log message file:_files' \ + '-r+:tag:_cvs_revisions' \ + '*:file:_cvs_files_modified' +} -if ! builtin functions _cvs_init >&-; then - _cvs_init () { - false - } -fi +(( $+functions[_cvs_diff] )) || +_cvs_diff () { + # "+abcdefhilnpstuw0123456789BHNRC:D:F:I:L:U:V:W:k:r:" + _arguments -s \ + -{l,R} \ + '-D+:date:_cvs_D' \ + '-k+:keyword substitution:_cvs_k' \ + '-r+:tag:_cvs_revisions' \ + -{h,p,0,1,2,3,4,5,6,7,8,9} \ + '--binary' \ + '--brief' \ + '--changed-group-format=:format:' \ + '-c' '-C+:lines:' '--context=-:lines:' \ + '-e' '--ed' \ + '-t' '--expand-tabs' \ + '-f' '--forward-ed' \ + '--horizon-lines=:lines:' \ + '--ifdef=:name:' \ + '-w' '--ignore-all-space' \ + '-B' '--ignore-blank-lines' \ + '-i' '--ignore-case' \ + '-I+:regex:' '--ignore-matching-lines=:regex:' \ + '-b' '--ignore-space-change' \ + '--initial-tab' \ + '*-L+:label:' '*--label=:label:' \ + '--left-column' \ + '--line-format=:format:' \ + '-d' '--minimal' \ + '-N' '--new-file' \ + '--new-group-format=:format:' \ + '--new-line-format=:format:' \ + '--old-group-format=:format:' \ + '--old-line-format=:format:' \ + '--paginate' \ + '-n' '--rcs' \ + '-s' '--report-identical-files' \ + '--show-c-function' \ + '-F+:regex:' '--show-function-line=:regex:' \ + '-y' '--side-by-side' \ + '-H' '--speed-large-files' \ + '--suppress-common-lines' \ + '-a' '--text' \ + '--unchanged-group-format=:format:' \ + '--unchanged-line-format=:format:' \ + '-u' '-U+:lines:' '--unified=-:lines:' \ + '-W:columns:' '--width=:columns:' \ + '*:file:_cvs_diff_arg' +} -if ! builtin functions _cvs_login >&-; then - _cvs_login () { - false - } -fi +(( $+functions[_cvs_diff_arg] )) || +_cvs_diff_arg () { + _cvs_files_modified || _cvs_files +} -if ! builtin functions _cvs_logout >&-; then - _cvs_logout () { - false - } -fi - -if ! builtin functions _cvs_rdiff >&-; then - _cvs_rdiff () { - # "+V:k:cuftsQqlRD:r:" - _arguments -s \ - -{c,u,f,t,s,Q,q,l,R} \ - '-V+:version:' \ - '-k+:keyword substitution:_cvs_k' \ - '*-D+:date:_cvs_D' \ - '*-r+:tag:_cvs_revisions' \ - '*:module:_cvs_modules' - } -fi - -if ! builtin functions _cvs_release >&-; then - _cvs_release () { - # "+Qdq" - _arguments -s \ - -{Q,d,q} \ - '*:directory:_files -/' - } -fi - -if ! builtin functions _cvs_remove >&-; then - _cvs_remove () { - # "+flR" - _arguments -s \ - -{f,l,R} \ - '*:file:_cvs_files_removed' - } -fi +(( $+functions[_cvs_edit] )) || +_cvs_edit () { + # "+lRa:" + _arguments -s \ + -{l,R} \ + '-a+:action:(edit unedit commit all none)' \ + '*:file:_cvs_files' +} -if ! builtin functions _cvs_status >&-; then - _cvs_status () { - # "+vlR" - _arguments -s \ - -{v,l,R} \ - '*:file:_cvs_files' - } -fi - -if ! builtin functions _cvs_tag >&-; then - _cvs_tag () { - # "+FQqlRcdr:D:bf" - _arguments -s \ - -{F,Q,q,l,R,c,d,b,f} \ - '-r+:tag:_cvs_revisions' \ - '-D+:date:_cvs_D' \ - '*:file:_cvs_files' - } -fi +(( $+functions[_cvs_editors] )) || +_cvs_editors () { + # "+lR" + _arguments -s \ + -{l,R} \ + '*:file:_cvs_files' +} + +(( $+functions[_cvs_export] )) || +_cvs_export () { + # "+Nnk:d:flRQqr:D:" + _arguments -s \ + -{N,n,f,l,R,Q,q} \ + '-k+:keyword substitution:_cvs_k' \ + '-d+:directory:_files -/' \ + '-r+:tag:_cvs_revisions' \ + '-D+:date:_cvs_D' \ + '*:module:_cvs_modules' +} + +(( $+functions[_cvs_history] )) || +_cvs_history () { + # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:" + _arguments -s \ + -{T,a,c,e,l,o,w,\?} \ + '-D+:date:_cvs_D' \ + '-b+:string:' \ + '-f+:file:_cvs_files' \ + '-m+:module:_cvs_modules' \ + '-n+:module:_cvs_modules' \ + '*-p+:repository:' \ + '-r+:rev:' \ + '-t+:tag:' \ + '-u+:user name:' \ + '-x+:type:_cvs_history_x' \ + '-X+:arg:' \ + '-z+:timezone:' \ + '*:file:_cvs_files' +} + +(( $+functions[_cvs_history_x] )) || +_cvs_history_x () { + _values -s '' 'type' \ + 'F[release]' \ + 'O[checkout]' \ + 'E[export]' \ + 'T[rtag]' \ + 'C[merge collision-detected]' \ + 'G[merge succeed]' \ + 'U[working file was copied]' \ + 'W[working file was deleted]' \ + 'A[A file was added]' \ + 'M[A file was modified]' \ + 'R[A file was removed]' +} + +(( $+functions[_cvs_import] )) || +_cvs_import () { + # "+Qqdb:m:I:k:W:" + _arguments -s \ + -{Q,q,d} \ + '-b+:branch:' \ + '-m+:message:_cvs_m' \ + '*-I+:name:_files' \ + '-k+:keyword substitution:_cvs_k' \ + '*-W+:spec:' \ + ':repository:_cvs_modules' \ + ':vendor tag:' \ + ':release tag:' +} + +(( $+functions[_cvs_init] )) || +_cvs_init () { + false +} + +(( $+functions[_cvs_log] )) || +_cvs_log () { + # "+bd:hlNRr::s:tw::" + _arguments -s \ + -{b,h,l,N,R,t} \ + '-d+:dates:' \ + '-r-:revisions:' \ + '-s+:states:' \ + '-w-:logins:' \ + '*:file:_cvs_files' +} + +(( $+functions[_cvs_login] )) || +_cvs_login () { + false +} + +(( $+functions[_cvs_logout] )) || +_cvs_logout () { + false +} + +(( $+functions[_cvs_rdiff] )) || +_cvs_rdiff () { + # "+V:k:cuftsQqlRD:r:" + _arguments -s \ + -{c,u,f,t,s,Q,q,l,R} \ + '-V+:version:' \ + '-k+:keyword substitution:_cvs_k' \ + '*-D+:date:_cvs_D' \ + '*-r+:tag:_cvs_revisions' \ + '*:module:_cvs_modules' +} + +(( $+functions[_cvs_release] )) || +_cvs_release () { + # "+Qdq" + _arguments -s \ + -{Q,d,q} \ + '*:directory:_files -/' +} + +(( $+functions[_cvs_remove] )) || +_cvs_remove () { + # "+flR" + _arguments -s \ + -{f,l,R} \ + '*:file:_cvs_files_removed' +} + +(( $+functions[_cvs_rtag] )) || +_cvs_rtag () { + # "+FanfQqlRdbr:D:" + _arguments -s \ + -{F,a,n,f,Q,q,l,R,d,b} \ + '*-D+:date:_cvs_D' \ + '*-r+:tag:_cvs_revisions' \ + ':tag:' \ + '*:module:_cvs_modules' +} + +(( $+functions[_cvs_status] )) || +_cvs_status () { + # "+vlR" + _arguments -s \ + -{v,l,R} \ + '*:file:_cvs_files' +} + +(( $+functions[_cvs_tag] )) || +_cvs_tag () { + # "+FQqlRcdr:D:bf" + _arguments -s \ + -{F,Q,q,l,R,c,d,b,f} \ + '-r+:tag:_cvs_revisions' \ + '-D+:date:_cvs_D' \ + ':tag:' \ + '*:file:_cvs_files' +} + +(( $+functions[_cvs_unedit] )) || +_cvs_unedit () { + # "+lR" + _arguments -s \ + -{l,R} \ + '*:file:_cvs_files' +} + +(( $+functions[_cvs_update] )) || +_cvs_update () { + # "+ApCPflRQqduk:r:D:j:I:W:" + _arguments -s \ + -{A,C,p,P,f,l,R,Q,q,d,u} \ + '-k+:keyword substitution:_cvs_k' \ + '-r+:tag:_cvs_revisions' \ + '-D+:date:_cvs_D' \ + '-j+:tag:_cvs_revisions' \ + '*-I+:name:_files' \ + '*-W+:spec:' \ + '*:file:_cvs_files' +} + +(( $+functions[_cvs_watch] )) || +_cvs_watch () { + local expl + + if (( CURRENT == 2 )); then + _wanted values expl 'watch command' compadd on off add remove + else + case "$words[2]" in + on|off) # "+lR" + _arguments -s \ + -{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' + ;; + esac + fi +} -if ! builtin functions _cvs_unedit >&-; then - _cvs_unedit () { - # "+lR" - _arguments -s \ +(( $+functions[_cvs_watchers] )) || +_cvs_watchers () { + # "+lR" + _arguments -s \ -{l,R} \ '*:file:_cvs_files' - } -fi - -if ! builtin functions _cvs_update >&-; then - _cvs_update () { - # "+ApPflRQqduk:r:D:j:I:W:" - _arguments -s \ - -{A,p,P,f,l,R,Q,q,d,u} \ - '-k+:keyword substitution:_cvs_k' \ - '-r+:tag:_cvs_revisions' \ - '-D+:date:_cvs_D' \ - '-j+:tag:_cvs_revisions' \ - '*-I+:name:_files' \ - '*-W+:spec:' \ - '*:file:_cvs_files' - } -fi +} -if ! builtin functions _cvs_watch >&-; then - _cvs_watch () { - if (( CURRENT == 2 )); then - compadd on off add remove - else - case "$words[2]" in - on|off) # "+lR" - _arguments -s \ - -{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' - ;; - esac - fi - } -fi +(( $+functions[_cvs_loadstat] )) || +_cvs_loadstat () { + zstyle -t ":completion:${curcontext}:" disable-stat && return + (( $+_cvs_loadstat_tried )) && return + _cvs_loadstat_tried=yes -if ! builtin functions _cvs_watchers >&-; then - _cvs_watchers () { - # "+lR" - _arguments -s \ - -{l,R} \ - ':*:file:_cvs_files' - } -fi + zmodload -i zsh/stat 2>/dev/null +} -if ! builtin functions _cvs_root >&-; then - _cvs_root () { - compadd "$@" $_cvs_roots || _files "$@" -/ - } -fi +(( $+functions[_cvs_root] )) || +_cvs_root () { + local cvspassfile id -if ! builtin functions _cvs_tempdir >&-; then - _cvs_tempdir () { - compadd "$@" $TMPPREFIX:h $TMPDIR /tmp - } -fi + typeset -gU _cvs_roots -if ! builtin functions _cvs_user_variable >&-; then - _cvs_user_variable () { - if compset -P '*='; then - _default + if [[ -f "${cvspassfile::=${CVS_PASSFILE:-$HOME/.cvspass}}" ]]; then + _cvs_loadstat + if (( $+builtins[stat] )); then + id="$(LC_ALL=C builtin stat -g +mtime -F '%Y/%m/%d-%T' "$cvspassfile")" else - _message "variable=value" + id="$(LC_ALL=C ls -l "$cvspassfile")" + fi + if [[ "$id" != "$_cvs_pass_id" ]]; then + _cvs_roots=($_cvs_roots ${${(f)"$(<$cvspassfile)"}%% *}) + _cvs_pass_id="$id" fi + fi + + _tags files && { + compadd -M 'r:|[:@./]=* r:|=*' "$@" $_cvs_roots || _files "$@" -/ } -fi +} + +(( $+functions[_cvs_tempdir] )) || +_cvs_tempdir () { + _tags directories && compadd "$@" $TMPPREFIX:h $TMPDIR /tmp +} + +(( $+functions[_cvs_user_variable] )) || +_cvs_user_variable () { + if compset -P '*='; then + _default + else + _message "variable=value" + fi +} # define completion functions for cvs global options. -if ! builtin functions _cvs_bindir >&-; then - _cvs_bindir () { - compadd "$@" /usr/local/bin || _files "$@" -/ - } -fi +(( $+functions[_cvs_bindir] )) || +_cvs_bindir () { + _tags directories && { compadd "$@" /usr/local/bin || _files "$@" -/ } +} -if ! builtin functions _cvs_editor >&-; then - _cvs_editor () { - compadd "$@" vi - } -fi +(( $+functions[_cvs_editor] )) || +_cvs_editor () { + _tags commands && compadd "$@" vi +} -if ! builtin functions _cvs_gzip_level >&-; then - _cvs_gzip_level () { - compadd "$@" 9 - } -fi +(( $+functions[_cvs_gzip_level] )) || +_cvs_gzip_level () { + _tags values && compadd "$@" 9 +} # define completion functions for cvs common options and arguments. -if ! builtin functions _cvs_D >&-; then - _cvs_D () { - compadd "$@" today yesterday week\ ago month\ ago - } -fi +(( $+functions[_cvs_D] )) || +_cvs_D () { + _tags values && compadd "$@" today yesterday week\ ago month\ ago +} -if ! builtin functions _cvs_k >&-; then - _cvs_k () { - compadd "$@" kv kvl k o b v - } -fi +(( $+functions[_cvs_k] )) || +_cvs_k () { + _tags values && compadd "$@" kv kvl k o b v +} -if ! builtin functions _cvs_m >&-; then - _cvs_m () { - _message "log message" - } -fi +(( $+functions[_cvs_m] )) || +_cvs_m () { + _message "log message" +} -if ! builtin functions _cvs_modules >&-; then - _cvs_modules () { - local root=$CVSROOT - [[ -f CVS/Root ]] && root=$(<CVS/Root) +(( $+functions[_cvs_modules] )) || +_cvs_modules () { + local root=$CVSROOT expl - if [[ $root = :* || ! -d $root ]]; then - _message "module name" - else - compadd - \ - $root/^CVSROOT(:t) \ - ${${(M)${(f)"$(<$root/CVSROOT/modules)"}:#[^#]*}%%[ ]*} - fi - } -fi + [[ -f CVS/Root ]] && root=$(<CVS/Root) -if ! builtin functions _cvs_revisions >&-; then - _cvs_revisions () { - compadd - ${${${(M)${(f)"$(cvs -q status -vl .)"}:# *}##[ ]##}%%[ ]*} - } -fi + if [[ $root = :* || ! -d $root ]]; then + _message "module name" + else + _wanted modules expl module \ + compadd - $root/^CVSROOT(:t) \ + ${${(M)${(f)"$(<$root/CVSROOT/modules)"}:#[^#]*}%%[ ]*} + fi +} + +(( $+functions[_cvs_revisions] )) || +_cvs_revisions () { + local expl + + _wanted values expl revision \ + compadd - ${${${(M)${(f)"$(cvs -q status -vl .)"}:# *}##[ ]##(No Tags Exist)#}%%[ ]*} +} # define completion functions for files maintained by cvs. -if ! builtin functions _cvs_setup_prefix >&-; then - _cvs_setup_prefix () { - if [[ -prefix */ ]]; then - qpref="${PREFIX%/*}/" - pref=$~qpref - else - qpref= - pref=./ - fi - } -fi +(( $+functions[_cvs_setup_prefix] )) || +_cvs_setup_prefix () { + if [[ -prefix */ ]]; then + qpref="${PREFIX%/*}/" + pref=$~qpref + else + qpref= + pref=./ + fi +} -if ! builtin functions _cvs_extract_directory_entries >&-; then - _cvs_extract_directory_entries () { - entries=($entries ${${${(M)rawentries:#D/*}#D/}%%/*}) - } -fi +(( $+functions[_cvs_extract_directory_entries] )) || +_cvs_extract_directory_entries () { + entries=($entries ${${${(M)rawentries:#D/*}#D/}%%/*}) +} -if ! builtin functions _cvs_extract_file_entries >&-; then - _cvs_extract_file_entries () { - entries=($entries ${${${(M)rawentries:#/*}#/}%%/*}) - } -fi - -if ! builtin functions _cvs_extract_modifiedfile_entries >&-; then - _cvs_extract_modifiedfile_entries () { - if [[ -n "$compconfig[_cvs_disable_stat]" ]] || - ! { zmodload -e stat || zmodload stat }; then - _cvs_extract_file_entries - return - fi +(( $+functions[_cvs_extract_file_entries] )) || +_cvs_extract_file_entries () { + entries=($entries ${${${(M)rawentries:#/*}#/}%%/*}) +} - local ents pats - ents=(${${${${(M)rawentries:#/*}#/}/\\/[^\\/]#\\///}%/[^/]#/[^/]#}) - pats=(${${${(f)"$(LANG=C builtin stat -gn +mtime -F '%a %b %e %T %Y' ${pref}*(D))"}##*/}/ //}) - eval 'ents=(${ents:#('${(j:|:)${(@)pats:q}}')})' - entries=($entries ${ents%%/*}) - } -fi - -if ! builtin functions _cvs_setup_allentries >&-; then - _cvs_setup_allentries () { - entries=() - if [[ -f ${pref}CVS/Entries ]]; then - local rawentries - rawentries=(${(f)"$(<${pref}CVS/Entries)"}) - _cvs_extract_file_entries - _cvs_extract_directory_entries - fi - } -fi - -if ! builtin functions _cvs_setup_direntries >&-; then - _cvs_setup_direntries () { - entries=() - if [[ -f ${pref}CVS/Entries ]]; then - local rawentries - rawentries=(${(f)"$(<${pref}CVS/Entries)"}) - _cvs_extract_directory_entries - fi - } -fi - -if ! builtin functions _cvs_setup_modentries >&-; then - _cvs_setup_modentries () { - entries=() - if [[ -f ${pref}CVS/Entries ]]; then - local rawentries - rawentries=(${(f)"$(<${pref}CVS/Entries)"}) - _cvs_extract_modifiedfile_entries - _cvs_extract_directory_entries - fi - } -fi +(( $+functions[_cvs_extract_modifiedfile_entries] )) || +_cvs_extract_modifiedfile_entries () { + _cvs_loadstat + if (( ! $+builtins[stat] )); then + _cvs_extract_file_entries + return + fi -if ! builtin functions _cvs_directories >&-; then - _cvs_directories () { - if [[ -d ${pref}CVS ]]; then - _cvs_setup_direntries - (( $#entries )) && compgen "$@" -g "${(j:|:)${(@)entries:q}}" - else - _files "$@" - fi - } -fi - -if ! builtin functions _cvs_files >&-; then - _cvs_files () { - local qpref pref entries - _cvs_setup_prefix - if [[ -d ${pref}CVS ]]; then - _cvs_setup_allentries - (( $#entries )) && compgen "$@" -g "${(j:|:)${(@)entries:q}}" - else - _files "$@" - fi - } -fi - -if ! builtin functions _cvs_files_modified >&-; then - _cvs_files_modified () { - local qpref pref entries - _cvs_setup_prefix - if [[ -d ${pref}CVS ]]; then - _cvs_setup_modentries - (( $#entries )) && compgen "$@" -g "${(j:|:)${(@)entries:q}}" - else - _files "$@" - fi - } -fi - -if ! builtin functions _cvs_files_removed >&-; then - _cvs_files_removed () { - local qpref pref entries - _cvs_setup_prefix - if [[ -d ${pref}CVS ]]; then - _cvs_setup_allentries - setopt localoptions unset - local omit - omit=(${pref}*(D:t)) - eval 'entries=(${entries:#('${(j:|:)${(@)omit:q}}')})' - compadd "$@" -P "$qpref" - ${entries:q} || - _cvs_directories "$@" - else - _files "$@" - fi - } -fi - -if ! builtin functions _cvs_files_unmaintained >&-; then - _cvs_files_unmaintained () { - local qpref pref entries - _cvs_setup_prefix - if [[ -d ${pref}CVS ]]; then - _cvs_setup_allentries - setopt localoptions unset - local omit - omit=($_cvs_ignore_default ${entries:q} ${=cvsignore}) - [[ -r ~/.cvsignore ]] && omit=($omit $(<~/.cvsignore)) - [[ -r ${pref}.cvsignore ]] && omit=($omit $(<${pref}.cvsignore)) - compgen "$@" -g '*~(*/|)('${(j:|:)omit}')(D)' || - compgen "$@" -g '*~(*/|)('${(j:|:)${(@)entries:q}}')(D)' || - _cvs_directories "$@" - else - _files "$@" - fi - } -fi + local ents pats + ents=(${${${${(M)rawentries:#/*}#/}/\\/[^\\/]#\\///}%/[^/]#/[^/]#}) + pats=(${${${(f)"$(LC_ALL=C builtin stat -gn +mtime -F '%a %b %e %T %Y' ${pref}*(D))"}##*/}/ //}) + eval 'ents=(${ents:#('${(j:|:)${(@)pats:q}}')})' + entries=($entries ${ents%%/*}) +} -# define configuration variables. +(( $+functions[_cvs_setup_allentries] )) || +_cvs_setup_allentries () { + entries=() + if [[ -f ${pref}CVS/Entries ]]; then + local rawentries + rawentries=(${(f)"$(<${pref}CVS/Entries)"}) + _cvs_extract_file_entries + _cvs_extract_directory_entries + fi +} + +(( $+functions[_cvs_setup_direntries] )) || +_cvs_setup_direntries () { + entries=() + if [[ -f ${pref}CVS/Entries ]]; then + local rawentries + rawentries=(${(f)"$(<${pref}CVS/Entries)"}) + _cvs_extract_directory_entries + fi +} + +(( $+functions[_cvs_setup_modentries] )) || +_cvs_setup_modentries () { + entries=() + if [[ -f ${pref}CVS/Entries ]]; then + local rawentries + rawentries=(${(f)"$(<${pref}CVS/Entries)"}) + _cvs_extract_modifiedfile_entries + _cvs_extract_directory_entries + fi +} -if (( ! $+_cvs_roots )); then - if [[ -f ~/.cvspass ]]; then - _cvs_roots=(${${(f)"$(<~/.cvspass)"}%% *}) +(( $+functions[_cvs_directories] )) || +_cvs_directories () { + if [[ -d ${pref}CVS ]]; then + _cvs_setup_direntries + (( $#entries )) && _files "$@" -g "${(j:|:)${(@)entries:q}}" else - _cvs_roots=() + _files "$@" fi -fi +} + +(( $+functions[_cvs_files] )) || +_cvs_files () { + local qpref pref entries + _cvs_setup_prefix + if [[ -d ${pref}CVS ]]; then + _cvs_setup_allentries + (( $#entries )) && _files "$@" -g "${(j:|:)${(@)entries:q}}" + else + _files "$@" + fi +} + +(( $+functions[_cvs_files_modified] )) || +_cvs_files_modified () { + local qpref pref entries + _cvs_setup_prefix + if [[ -d ${pref}CVS ]]; then + _cvs_setup_modentries + (( $#entries )) && _files "$@" -g "${(j:|:)${(@)entries:q}}" + else + _files "$@" + fi +} + +(( $+functions[_cvs_files_removed] )) || +_cvs_files_removed () { + local qpref pref entries + _cvs_setup_prefix + if [[ -d ${pref}CVS ]]; then + _cvs_setup_allentries + setopt localoptions unset + local omit + omit=(${pref}*(D:t)) + eval 'entries=(${entries:#('${(j:|:)${(@)omit:q}}')})' + _tags directories && compadd "$@" -P "$qpref" - ${entries:q} || + _cvs_directories "$@" + else + _files "$@" + fi +} + +(( $+functions[_cvs_files_unmaintained] )) || +_cvs_files_unmaintained () { + local qpref pref entries + _cvs_setup_prefix + if [[ -d ${pref}CVS ]]; then + _cvs_setup_allentries + setopt localoptions unset + local omit + omit=($_cvs_ignore_default ${entries:q} ${=cvsignore}) + [[ -r ~/.cvsignore ]] && omit=($omit $(<~/.cvsignore)) + [[ -r ${pref}.cvsignore ]] && omit=($omit $(<${pref}.cvsignore)) + _path_files "$@" -g '*~(*/|)('${(j:|:)omit}')(D)' || + _path_files "$@" -g '*~(*/|)('${(j:|:)${(@)entries:q}}')(D)' || + _cvs_directories "$@" + else + _files "$@" + fi +} + +# define configuration variables. -if (( ! $+_cvs_ignore_default )); then - _cvs_ignore_default=( - RCS SCCS CVS CVS.adm RCSLOG 'cvslog.*' tags TAGS .make.state .nse_depinfo - '*\~' '\#*' '.\#*' ',*' '_$*' '*$' '*.old' '*.bak' '*.BAK' '*.orig' '*.rej' - '.del-*' '*.a' '*.olb' '*.o' '*.obj' '*.so' '*.exe' '*.Z' '*.elc' '*.ln' - core - ) -fi +(( $+_cvs_ignore_default )) || +_cvs_ignore_default=( + RCS SCCS CVS CVS.adm RCSLOG 'cvslog.*' tags TAGS .make.state .nse_depinfo + '*\~' '\#*' '.\#*' ',*' '_$*' '*$' '*.old' '*.bak' '*.BAK' '*.orig' '*.rej' + '.del-*' '*.a' '*.olb' '*.o' '*.obj' '*.so' '*.exe' '*.Z' '*.elc' '*.ln' + core +) # call real _cvs. -_cvs "$@" +[[ -o kshautoload ]] || _cvs "$@" diff --git a/Completion/User/_gdb b/Completion/User/_gdb index a29eaf8b2..0445e18e9 100644 --- a/Completion/User/_gdb +++ b/Completion/User/_gdb @@ -17,7 +17,8 @@ elif compset -P '-(exec|se)='; then elif compset -P '-(symbols|core|command)='; then _files elif [[ "$PREFIX" = -* ]]; then - if _wanted options; then + _tags options + while _tags; do while _next_label options expl option; do compadd "$expl[@]" -QS '' - -symbols\= -exec\= -se\= -core\= -command\= \ -directory\= -cd\= -tty\= && ret=0 @@ -25,7 +26,7 @@ elif [[ "$PREFIX" = -* ]]; then -batch -fullname -f -b && ret=0 done (( ret )) || return 0 - fi + done else prev="$words[CURRENT-1]" diff --git a/Completion/User/_gprof b/Completion/User/_gprof index 0a1d621be..659e921e8 100644 --- a/Completion/User/_gprof +++ b/Completion/User/_gprof @@ -1,12 +1,58 @@ #compdef gprof -_arguments -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: _exec_funcs' \ +local curcontext="$curcontext" state line ret=1 +typeset -A opt_args + +_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: _exec_funcs -p' \ + '-d-:debug level:' '-k:function names:->pair' \ '-m:minimum execution count:' \ - ':executable:_files -g *(*)' \ - ':profile file:_files -g gmon.*' \ + ':executable:_files -g \*\(\*\)' \ + ':profile file:_files -g gmon.\*' \ -- -s '(#--[no-] --)' \ - '*=name*:function name: _exec_funcs' \ - '*=dirs*:directory:_dir_list' + '*=name*:function name:->funcs' \ + '*=dirs*:directory:_dir_list' && ret=0 + +if [[ -n "$state" ]]; then + local cmd pair expl + + _tags functions || return 1 + + [[ "$state" = pair ]] && pair=yes + + if [[ $#line -gt 1 ]]; then + cmd="$line[2]" + else + return 1 + fi + + if [[ -n "$cmd" ]]; then + if [[ "$cmd" = /* ]]; then + tmp="$cmd" + else + tmp="$PWD/$cmd" + fi + + if [[ "$tmp" != "$_gprof_command" ]]; then + _gprof_command="$tmp" + _gprof_funcs=( "${(@)${(@M)${(@f)$(nm $cmd)}:#[^ ]# [tT] ([^_]|_[^_])*}##* }" ) + fi + + if [[ -n "$pair" ]]; then + if compset -P '*/'; then + expl='call arc to function' + else + expl='call arc from function' + fi + else + expl=function + fi + _wanted functions expl "$expl" \ + compadd "$expl[@]" -M 'r:|_=* r:|=*' - "$_gprof_funcs[@]" && ret=0 + else + return 1 + fi +fi + +return ret diff --git a/Completion/User/_groups b/Completion/User/_groups index 27444d26d..7ee9969cd 100644 --- a/Completion/User/_groups +++ b/Completion/User/_groups @@ -2,7 +2,7 @@ local expl groups tmp -_wanted groups || return 1 +_tags groups || return 1 if ! zstyle -a ":completion:${curcontext}:" groups groups; then (( $+_cache_groups )) || @@ -16,4 +16,4 @@ if ! zstyle -a ":completion:${curcontext}:" groups groups; then groups=( "$_cache_groups[@]" ) fi -_all_labels groups expl group compadd "$@" - "$groups[@]" +_wanted groups expl group compadd "$@" - "$groups[@]" diff --git a/Completion/User/_lp b/Completion/User/_lp index e996507ce..60cf8cfd0 100644 --- a/Completion/User/_lp +++ b/Completion/User/_lp @@ -36,28 +36,27 @@ if (( ! $+_lp_cache )); then fi if compset -P -P || [[ "$words[CURRENT-1]" = -P ]]; then - if _wanted printers; then - if zstyle -T ":completion:${curcontext}:printers" verbose; then - zformat -a list ' -- ' "$_lp_cache[@]" - disp=(-ld list) - else - disp=() - fi - _all_labels printers expl printer \ - compadd "$disp[@]" - "${(@)_lp_cache%%:*}" && return 0 + if zstyle -T ":completion:${curcontext}:printers" verbose; then + zformat -a list ' -- ' "$_lp_cache[@]" + disp=(-ld list) + else + disp=() + fi + _wanted printers expl printer \ + compadd "$disp[@]" - "${(@)_lp_cache%%:*}" && return 0 - (( $+_lp_alias_cache )) || return 1 + (( $+_lp_alias_cache )) || return 1 - if zstyle -T ":completion:${curcontext}:printers" verbose; then - zformat -a list ' -- ' "$_lp_alias_cache[@]" - disp=(-ld list) - else - disp=() - fi - compadd "$expl[@]" "$disp[@]" - "${(@)_lp_alias_cache%%:*}" + if zstyle -T ":completion:${curcontext}:printers" verbose; then + zformat -a list ' -- ' "$_lp_alias_cache[@]" + disp=(-ld list) else - return 1 + disp=() fi + _wanted printers expl printer \ + compadd "$disp[@]" - "${(@)_lp_alias_cache%%:*}" && return 0 + + return 1 else if [[ "${words[1]:t}" = (lpq|lprm) ]]; then if [[ "$words" = *-P* ]]; then diff --git a/Completion/User/_mh b/Completion/User/_mh index 724b45e5a..29d6bc2a1 100644 --- a/Completion/User/_mh +++ b/Completion/User/_mh @@ -17,16 +17,13 @@ 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. - if _wanted options; then - _all_labels options expl option \ - compadd - $($words[1] -help | perl -ne 'if (/^\s*-\(?(\S+)/) { + _wanted options expl option \ + compadd - $($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 - fi - return 1 + return elif compset -P 1 '[+@]' || [[ "$prev" = -draftfolder ]]; then # Complete folder names. local mhpath @@ -72,13 +69,15 @@ else # leaving foldnam empty works here fi - if _wanted sequences; then + _tags sequences + while _tags; do while _next_label sequences expl sequence; do 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 done - fi + (( ret )) || return 0 + done return ret fi diff --git a/Completion/User/_mount b/Completion/User/_mount index a148fff27..418b7974f 100644 --- a/Completion/User/_mount +++ b/Completion/User/_mount @@ -543,7 +543,7 @@ fstype) compadd "$expl[@]" -qS, -M 'L:|no=' - "$fss[@]" && ret=0 ;; fsopt) - _wanted options || return 1 + _tags options || return 1 eval 'tmp=(' '"$_fs_'${(s:,:)^${opt_args[$typeops]:-${deffs}}}'[@]"' ')' tmp=( "$_fs_any[@]" "${(@)tmp:#}" ) diff --git a/Completion/User/_netscape b/Completion/User/_netscape index 82fa4509a..ed2bccc75 100644 --- a/Completion/User/_netscape +++ b/Completion/User/_netscape @@ -56,16 +56,14 @@ if [[ "$state" = "remote" ]]; then fi ;; *) - if _wanted commands; then - if [[ -z "$QIPREFIX" ]]; then - _all_labels commands expl 'remote commands' \ - compadd -s'(' -S '' -M 'm:{a-zA-Z}={A-Za-z}' - \ - $remote_commands && ret=0 - else - _all_labels commands expl 'remote commands' \ - compadd -qS '(' -M 'm:{a-zA-Z}={A-Za-z}' - \ - $remote_commands && ret=0 - fi + if [[ -z "$QIPREFIX" ]]; then + _wanted commands expl 'remote commands' \ + compadd -s'(' -S '' -M 'm:{a-zA-Z}={A-Za-z}' - \ + $remote_commands && ret=0 + else + _wanted commands expl 'remote commands' \ + compadd -qS '(' -M 'm:{a-zA-Z}={A-Za-z}' - \ + $remote_commands && ret=0 fi ;; esac @@ -78,12 +76,14 @@ if [[ "$state" = "urls" ]]; then compadd authors blank cache document fonts global hype image-cache \ license logo memory-cache mozilla plugins && ret=0 else - if _wanted prefixes; then + _tags prefixes + while _tags; do while _next_label prefixes expl 'URL prefix'; do compadd "$expl[@]" -S '' about: mocha: javascript: && ret=0 _urls "$@" && ret=0 done - fi + (( ret )) || return 0 + done fi fi diff --git a/Completion/User/_nslookup b/Completion/User/_nslookup index 7d2a12142..44ab4cacc 100644 --- a/Completion/User/_nslookup +++ b/Completion/User/_nslookup @@ -19,9 +19,7 @@ # other characters than lower case letters, we try to call the function # `_nslookup_host'. -setopt localoptions extendedglob - -local state expl ret=1 setopts +local context curstate="$curcontext" expl ret=1 setopts setopts=( 'all[print current values]' \ @@ -40,7 +38,7 @@ setopts=( '(noignoretc)ignoretc[ignore packet truncation errors]' \ '(ignoretc)noignoretc[don'"'"'t ignore packet truncation errors]' \ 'class[change query class]:query class:((in\:Internet\ class chaos\:CHAOS\ class hesiod\:MIT\ Athena\ Hesiod\ class any\:wildcard\ \(any\ of\ the\ above\)))' - 'domain[change default domain]:default domain:_hosts' + "domain[change default domain]:default domain:_domains" 'srchlist[change default domain and search list]: :->srchlist' 'port[change name server port]:name server port:' {query,}type'[change type of information query]:query information type:((a\:internet\ address cname\:canonical\ name\ for\ alias hinfo\:CPU\ and\ operating\ system\ type minfo\:mailbox\ or\ mail\ list\ information mx\:mail\ exchanger ns\:name\ server\ for\ zone ptr\:host\ name\ or\ other\ information soa\:domain\'"'"'s\ \`start-of-authority\'"'"'\ information txt\:text\ information uinfo\:user\ information wks\:supported\ well-known\ services))' @@ -52,23 +50,25 @@ setopts=( if [[ -n "$compcontext" ]]; then if [[ CURRENT -eq 1 ]]; then - funcall ret _nslookup_command && return ret + _funcall ret _nslookup_command && return ret - _description expl 'command' - compadd "$expl[@]" - server lserver root finger ls view help set && ret=0 - _hosts && ret=0 + _alternative \ + 'commands:command:(server lserver root finger ls view help set exit)' \ + 'hosts:: _hosts' && ret=0 return ret elif [[ "$compstate[context]" = redirect ]]; then - funcall ret _nslookup_redirect && return ret + _funcall ret _nslookup_redirect && return ret + + _tags -C redirection files || return 1 if [[ "$words[1]" != (finger|ls) ]]; then _message "redirection not allowed for command \`$words[1]'" return 1 elif [[ "$compstate[redirect]" = '>' ]]; then - _description expl 'write to file' + _description files expl 'write to file' elif [[ "$compstate[redirect]" = '>>' ]]; then - _description expl 'append to file' + _description files expl 'append to file' else _message "unknown redirection operator \`$compstate[redirect]'" return 1 @@ -79,15 +79,14 @@ if [[ -n "$compcontext" ]]; then fi if [[ "$words[1]" = [a-z]## ]]; then - funcall ret _nslookup_$words[1] && return ret + _funcall ret _nslookup_$words[1] && return ret else - funcall ret _nslookup_host && return ret + _funcall ret _nslookup_host && return ret fi case "$words[1]" in (|l)server) - _description expl 'new default server' - _hosts "$expl[@]" + _wanted hosts expl 'new default server' _hosts return ;; root|exit|help|\?) @@ -104,24 +103,23 @@ if [[ -n "$compcontext" ]]; then '-d[all records]' \ '-h[CPU and operating system information]' \ '-s[well-known services]' \ - ':domain:_hosts' + ":domain:_domains" return ;; view) - _description expl 'view file' + _description files expl 'view file' _files "$expl[@]" return ;; set) - typeset -A values + typeset -A val_args _values 'state information' "$setopts[@]" && ret=0 [[ -z "$state" ]] && return ret ;; *) - _description expl 'server' - _hosts "$expl[@]" + _wanted hosts expl 'server' _hosts return esac fi @@ -130,9 +128,9 @@ fi if [[ -z "$state" ]]; then local line - typeset -A options + typeset -A opt_args - _arguments \ + _arguments -C \ "-${(@)^${(@M)setopts:#*\]:*}/\[/=[}" \ "-${(@)^setopts:#(\(|*\]:)*}" \ "${(@)^${(@)${(@M)setopts:#\(*}/\)/)-}/\(/(-}" \ @@ -143,15 +141,17 @@ fi # This is completion after `srchlist' for both types. if [[ -n "$state" ]]; then + _tags domains || return 1 + if compset -P '*/'; then - _description expl 'search list entry' + _description domains expl 'search list entry' else - _description expl 'default domain name and first search list entry' + _description domains expl 'default domain name and first search list entry' fi if [[ -n "$_vals_cache_multi" ]]; then - _hosts "$expl[@]" -qS/ -r "/\\- \\t\\n$_vals_cache_multi" + _domains "$expl[@]" -qS/ -r "/\\- \\t\\n$_vals_cache_multi" else - _hosts "$expl[@]" -qS/ + _domains "$expl[@]" -qS/ fi return fi diff --git a/Completion/User/_rlogin b/Completion/User/_rlogin index bf8ff751d..2509bd79c 100644 --- a/Completion/User/_rlogin +++ b/Completion/User/_rlogin @@ -28,7 +28,7 @@ _rlogin () { return ret ;; rcp) - local curcontext="$curcontext" state line ret=1 + local curcontext="$curcontext" state line ret=1 expl typeset -A opt_args _arguments -C -s \ @@ -40,7 +40,7 @@ _rlogin () { if compset -P '*:'; then _files && ret=0 elif compset -P '*@'; then - _wanted hosts && _rlogin_hosts -S: -q && ret=0 + _wanted hosts expl host _rlogin_hosts -S: -q && ret=0 else _alternative \ 'files:: _files' \ @@ -54,11 +54,11 @@ _rlogin () { } _rlogin_users () { - _wanted users && _combination -s '[:@]' my-accounts users-hosts users "$@" + _tags users && _combination -s '[:@]' my-accounts users-hosts users "$@" } _rlogin_hosts () { - _wanted hosts && + _tags hosts && if [[ "$IPREFIX" == *@ ]]; then _combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@" else diff --git a/Completion/User/_socket b/Completion/User/_socket index 353a66fd5..af9c8ab0a 100644 --- a/Completion/User/_socket +++ b/Completion/User/_socket @@ -1,34 +1,55 @@ #compdef socket -local state line expl -typeset -A options +# Style used: +# +# hosts-ports +# The style that contains pairs `host:port'. -_arguments -s \ - -{b,c,f,q,r,v,w} \ - -{s,l} \ - '-p:command:->command' \ +local curcontext="$curcontext" state line expl +typeset -A opt_args + +[[ $CURRENT -eq 2 ]] && + { ! zstyle -T ":completion:${curcontext}:options" prefix-needed || + [[ "$PREFIX" = -* ]] } && + _wanted options expl option \ + compadd -M 'r:|[_-]=* r:|=*' "$expl[@]" - -version + +_arguments -C -s \ + '-b[background]' \ + '-c[crlf]' \ + '-f[fork]' \ + '-q[quit]' \ + '-r[read only]' \ + '-v[verbose]' \ + '-w[write only]' \ + '-s[server]' \ + '-l[loop]' \ + '-p[program]:command:->command' \ ':arg1:->arg1' \ ':arg2:->arg2' case "$state" in command) compset -q - _normal + if [[ $CURRENT -eq 1 ]]; then + _command_names -e "$@" + else + _normal + fi ;; arg1) - if (( $+options[-s] )); then - _message 'port' + if (( $+opt_args[-s] )); then + _ports else - _description expl 'host' - _hosts "$expl[@]" + _wanted hosts expl 'host' _combination '' hosts-ports hosts - fi ;; arg2) - if (( ! $+options[-s] )); then - _description expl 'port' - _hostports $line[2] "$expl[@]" + if (( ! $+opt_args[-s] )); then + _wanted ports expl 'port to connect' \ + _combination '' hosts-ports hosts="${line[1]:q}" ports - fi ;; esac diff --git a/Completion/User/_tiff b/Completion/User/_tiff index 9616009c3..608325fdf 100644 --- a/Completion/User/_tiff +++ b/Completion/User/_tiff @@ -195,12 +195,14 @@ if [[ -n "$state" ]]; then ;; esac else - if _wanted values; then + _tags values + while _tags; do while _next_label values expl 'compression scheme'; do compadd "$expl[@]" - none g4 packbits && ret=0 compadd "$expl[@]" -qS: - lzw zip jpeg g3 && ret=0 done - fi + (( ret )) || return 0 + done fi fi diff --git a/Completion/User/_urls b/Completion/User/_urls index 3989f2219..4234aa274 100644 --- a/Completion/User/_urls +++ b/Completion/User/_urls @@ -49,18 +49,22 @@ local localhttp_userdir="$localhttp[3]" if [[ "$1" = -f ]]; then shift - _wanted -C -f files && _files "$@" && return + _wanted -C -f files _files "$@" && return 0 fi ipre="$IPREFIX" -if ! compset -P '(#b)([-+.a-z0-9]#):' && _wanted -C argument prefixes; then - while _next_label prefixes expl 'URL prefix' "$@"; do - [[ -d $urls_path/bookmark ]] && - compadd "$expl[@]" -S '' bookmark: && ret=0 - compadd "$expl[@]" -S '' file: ftp:// gopher:// http:// && ret=0 +if ! compset -P '(#b)([-+.a-z0-9]#):'; then + _tags -C argument prefixes + while _tags; do + while _next_label prefixes expl 'URL prefix' "$@"; do + [[ -d $urls_path/bookmark ]] && + compadd "$expl[@]" -S '' bookmark: && ret=0 + compadd "$expl[@]" -S '' file: ftp:// gopher:// http:// && ret=0 + done + (( ret )) || return 0 done - return ret + return 1 fi scheme="$match[1]" @@ -73,17 +77,19 @@ case "$scheme" in ;; file) if ! compset -P //; then - _wanted -C file files || return 1 - - while _next_label files expl 'local file' "$@"; do - if [[ -prefix / ]]; then - _path_files "$expl[@]" -S '' -g '*(^/)' && ret=0 - _path_files "$expl[@]" -S/ -r '/' -/ && ret=0 - elif [[ -z "$PREFIX" ]]; then - compadd "$expl[@]" -S '/' -r '/' - "${PWD%/}" && ret=0 - fi + _tags -C file files + while _tags; do + while _next_label files expl 'local file' "$@"; do + if [[ -prefix / ]]; then + _path_files "$expl[@]" -S '' -g '*(^/)' && ret=0 + _path_files "$expl[@]" -S/ -r '/' -/ && ret=0 + elif [[ -z "$PREFIX" ]]; then + compadd "$expl[@]" -S '/' -r '/' - "${PWD%/}" && ret=0 + fi + done + (( ret )) || return 0 done - return ret + return 1 fi ;; bookmark) @@ -93,34 +99,40 @@ case "$scheme" in compadd "$@" -U - \ "$ipre$(<"$urls_path/$scheme/${(Q)PREFIX}${(Q)SUFFIX}")" && ret=0 else - if _wanted -C bookmark files; then + _tags -C bookmark files + while _tags; do while _next_label files expl 'bookmark'; do _path_files -W "$urls_path/$scheme" "$expl[@]" -S '' -g '*(^/)' && ret=0 _path_files -W "$urls_path/$scheme" -S/ -r '/' -/ && ret=0 done - fi + (( ret )) || return 0 + done fi return ret ;; esac # Complete hosts -if ! compset -P '(#b)([^/]#)/' && _wanted hosts; then +if ! compset -P '(#b)([^/]#)/'; then uhosts=($urls_path/$scheme/$PREFIX*$SUFFIX(/:t)) - while _next_label hosts expl host "$@"; do - (( $#uhosts )) || _hosts -S/ && ret=0 - [[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername) - compadd "$expl[@]" -S/ - $uhosts && ret=0 + _tags hosts + while _tags; do + while _next_label hosts expl host "$@"; do + (( $#uhosts )) || _hosts -S/ && ret=0 + [[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername) + compadd "$expl[@]" -S/ - $uhosts && ret=0 + done + (( ret )) || return 0 done - return ret + return 1 fi host="$match[1]" # Complete part after hostname -_wanted -C local files || return 1 +_tags -C local files || return 1 if [[ "$localhttp_servername" = "$host" ]]; then if compset -P \~; then @@ -129,20 +141,29 @@ if [[ "$localhttp_servername" = "$host" ]]; then return fi user="$match[1]" - while _next_label files expl 'local file'; do - _path_files "$expl[@]" -W ~$user/$localhttp_userdir -g '*(^/)' && ret=0 - _path_files "$expl[@]" -W ~$user/$localhttp_userdir -S/ -r '/' -/ && ret=0 + while _tags; do + while _next_label files expl 'local file'; do + _path_files "$expl[@]" -W ~$user/$localhttp_userdir -g '*(^/)' && ret=0 + _path_files "$expl[@]" -W ~$user/$localhttp_userdir -S/ -r '/' -/ && ret=0 + done + (( ret )) || return 0 done else - while _next_label files expl 'local file'; do - _path_files "$expl[@]" -W $localhttp_documentroot -g '*(^/)' && ret=0 - _path_files "$expl[@]" -W $localhttp_documentroot -S/ -r '/' -/ && ret=0 + while _tags; do + while _next_label files expl 'local file'; do + _path_files "$expl[@]" -W $localhttp_documentroot -g '*(^/)' && ret=0 + _path_files "$expl[@]" -W $localhttp_documentroot -S/ -r '/' -/ && ret=0 + done + (( ret )) || return 0 done fi else - while _next_label files expl 'local file'; do - _path_files "$expl[@]" -W $urls_path/$scheme/$host -g '*(^/)' && ret=0 - _path_files "$expl[@]" -W $urls_path/$scheme/$host -S/ -r '/' -/ && ret=0 + while _tags; do + while _next_label files expl 'local file'; do + _path_files "$expl[@]" -W $urls_path/$scheme/$host -g '*(^/)' && ret=0 + _path_files "$expl[@]" -W $urls_path/$scheme/$host -S/ -r '/' -/ && ret=0 + done + (( ret )) || return 0 done fi return $ret diff --git a/Completion/User/_users b/Completion/User/_users index d04731af9..dce0fd584 100644 --- a/Completion/User/_users +++ b/Completion/User/_users @@ -2,9 +2,7 @@ local expl users -_wanted users || return 1 - zstyle -a ":completion:${curcontext}:" users users && - _all_labels users expl user compadd "$@" - "$users[@]" && return 0 + _wanted users expl user compadd "$@" - "$users[@]" && return 0 -_all_labels users expl user compadd "$@" - "${(@k)userdirs}" +_wanted users expl user compadd "$@" - "${(@k)userdirs}" diff --git a/Completion/User/_users_on b/Completion/User/_users_on index b19cff6e7..b5c05e12b 100644 --- a/Completion/User/_users_on +++ b/Completion/User/_users_on @@ -2,10 +2,8 @@ local expl -_wanted users || return 1 - -if which users >/dev/null; then - _all_labels users expl 'users logged on' \ +if (( $+commands[users] )); then + _wanted users expl 'users logged on' \ compadd "$@" - $(_call users users) && return 0 else # Other methods of finding out users logged on should be added here diff --git a/Completion/User/_whois b/Completion/User/_whois index 827ebe627..4b6d73b86 100644 --- a/Completion/User/_whois +++ b/Completion/User/_whois @@ -1,12 +1,14 @@ -#compdef whois +#compdef whois fwhois _whois () { - setopt localoptions extendedglob _whois_setup - $_whois_comp + case "$0" in + fwhois) _whois_fwhois;; + *) $_whois_comp;; + esac } -builtin functions _whois_setup >&- || +(( $+functions[_whois_setup] )) || _whois_setup () { (( $+_whois_defaultserver )) || _whois_defaultserver='whois.internic.net' @@ -65,6 +67,7 @@ _whois_setup () { (( $+_whois_arguments )) || { local help="$(whois </dev/null 2>&1)" local tmp opt opts + local hostopt=-h+ if [[ $help = *"user[@<whois.server>]"* ]]; then _whois_comp=_whois_fwhois @@ -72,6 +75,7 @@ _whois_setup () { _whois_comp=_whois_multi else _whois_comp=_whois_single + hostopt=-h fi _whois_arguments=() @@ -96,25 +100,29 @@ _whois_setup () { for opt in $tmp; do opts=(-${^tmp:#$opt}) if (( $#opts )); then opts="($opts)"; else opts=; fi - _whois_arguments=("$_whois_arguments[@]" - "${opts}-${opt}[${${${(@M)_whois_servers:#*:$opt}%:?}:-specify host}]${(M)${(M)opt:#h}/h/:host:_whois_hosts}" - ) + if [[ $opt = h ]]; then + _whois_arguments=("$_whois_arguments[@]" + "${opts}${hostopt}:host:_whois_hosts") + else + _whois_arguments=("$_whois_arguments[@]" + "${opts}-${opt}[${${(@M)_whois_servers:#*:$opt}%:?}]") + fi done } } _whois_single () { - local state line expl + local curcontext="$curcontext" state line expl typeset -A opt_args local tmp host - _arguments \ + _arguments -C \ "$_whois_arguments[@]" \ ':identifier:->identifier' case "$state" in identifier) - if [[ -z "$QIPREFIX" ]]; then + if [[ -z "$QIPREFIX" && -z "$PREFIX" ]]; then compadd -QS '' \' return fi @@ -126,7 +134,7 @@ _whois_single () { break fi done - if builtin functions "_whois:$host" >&-; then + if (( $+functions[_whois:$host] )); then "_whois:$host" "$expl[@]" else _message "identifier" @@ -136,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' @@ -153,7 +161,7 @@ _whois_multi () { break fi done - if builtin functions "_whois:$host" >&-; then + if (( $+functions[_whois:$host] )); then "_whois:$host" "$expl[@]" else _message "identifier" @@ -166,13 +174,13 @@ _whois_fwhois () { if compset -P '*@'; then _whois_hosts "$@" else - if [[ -z "$QIPREFIX" ]]; then + if [[ -z "$QIPREFIX" && -z "$PREFIX" ]]; then compadd -QS '' \' return fi compset -q host="$_whois_defaultserver" - if builtin functions "_whois:$host" >&-; then + if (( $+functions[_whois:$host] )); then "_whois:$host" "$@" else _message "identifier" @@ -181,28 +189,33 @@ _whois_fwhois () { } _whois_hosts () { - compadd "$@" \ - -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' \ - - ${_whois_servers%:?} || _hosts "$@" + _tags hosts && + compadd "$@" \ + -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' \ + - ${_whois_servers%:?} || _hosts "$@" } _whois_ports () { - compadd "$@" - whois || _ports "$@" + _tags ports && compadd "$@" - whois || _ports "$@" } -builtin functions _whois:whois.internic.net >&- || +(( $+functions[_whois:whois.internic.net] )) || _whois:whois.internic.net () { if (( CURRENT == 1 )); then - compadd HELP DOMAIN HOST + local expl + + _wanted strings expl string compadd HELP DOMAIN HOST else _message 'string' fi } -builtin functions _whois:whois.nic.ad.jp >&- || +(( $+functions[_whois:whois.nic.ad.jp] )) || _whois:whois.nic.ad.jp () { if (( CURRENT == 1 )); then - compadd HELP DOM NET HOST PERSON CONN COM + local expl + + _wanted strings expl string compadd HELP DOM NET HOST PERSON CONN COM else _message 'string' fi |