diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-08-30 10:08:13 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-08-30 10:08:13 +0000 |
commit | 1d6c3eaaa0618d35329495a324c9fd2e7ed9843a (patch) | |
tree | 531e2d0e02699b1288ec20a45c0042bf209fb402 | |
parent | e55cf16d1232b54efb80a7861c28cf094eaeedff (diff) | |
download | zsh-1d6c3eaaa0618d35329495a324c9fd2e7ed9843a.tar.gz zsh-1d6c3eaaa0618d35329495a324c9fd2e7ed9843a.tar.xz zsh-1d6c3eaaa0618d35329495a324c9fd2e7ed9843a.zip |
zsh-workers/7533
37 files changed, 686 insertions, 391 deletions
diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments index bcdbde373..12ff025a1 100644 --- a/Completion/Base/_arguments +++ b/Completion/Base/_arguments @@ -5,7 +5,7 @@ setopt localoptions extendedglob -local long args rest ws cur nth def nm expl descr action opt arg tmp +local args rest ws cur nth def nm expl descr action opt arg tmp local single uns ret=1 soptseq soptseq1 sopts prefix line local beg optbeg argbeg nargbeg inopt fromrest @@ -22,7 +22,7 @@ if [[ "$*" != "$_args_cache_descr" ]]; then unset _args_cache_{opts,dopts,odopts,oneshot} typeset -gA _args_cache_{opts,dopts,odopts,oneshot} - unset _args_cache_{long,single,rest,args,sopts,soptseq,soptseq1} + unset _args_cache_{long,longcmd,single,rest,args,sopts,soptseq,soptseq1} # See if we are using single-letter options. @@ -35,10 +35,149 @@ if [[ "$*" != "$_args_cache_descr" ]]; then nth=$argv[(I)--] if (( nth )); then - _args_cache_long=( "${(@)argv[nth+1,-1]}" ) - _args_cache_long_nth=$(( nth - 1 )) - else - _args_cache_long=() + local tmpargv + + if [[ nth -eq 1 ]]; then + tmpargv=() + else + tmpargv=( "${(@)argv[1,nth-1]}" ) + fi + + if [[ "$words[1]" = /* ]]; then + tmp="$words[1]" + else + tmp="$PWD/$words[1]" + fi + + if [[ "$tmp" != "$_args_cache_longcmd" ]]; then + local iopts pattern tmpo + typeset -U lopts + + _args_cache_longcmd="$tmp" + + # We have to build the long-option cache anew, get the `-i' and + # `-s' options. + + iopts=() + sopts=() + while [[ "$1" = -[is]* ]]; do + if [[ "$1" = -??* ]]; then + tmp="${1[3,-1]}" + cur=1 + else + tmp="$2" + cur=2 + fi + if [[ "$tmp[1]" = '(' ]]; then + tmp=( ${=tmp[2,-2]} ) + else + tmp=( "${(@P)tmp}" ) + fi + if [[ "$1" = -i* ]]; then + iopts=( "$iopts[@]" "$tmp[@]" ) + else + sopts=( "$sopts[@]" "$tmp[@]" ) + fi + shift cur + done + + # Now get the long option names by calling the command with `--help'. + # The parameter expansion trickery first gets the lines as separate + # array elements. Then we select all lines whose first non-blank + # character is a hyphen. Since some commands document more than one + # option per line, separated by commas, we convert commas int + # newlines and then split the result again at newlines after joining + # the old array elements with newlines between them. Then we select + # those elements that start with two hyphens, remove anything up to + # those hyphens and anything from the space or comma after the + # option up to the end. + + lopts=("--${(@)^${(@)${(@)${(@M)${(@ps:\n:j:\n:)${(@)${(@M)${(@f)$("$words[1]" --help 2>&1)//\[--/ +--}:#[ ]#-*}//,/ +}}:#[ ]#--*}#*--}%%[, ]*}:#}") + + # Now remove all ignored options ... + + while (( $#iopts )); do + lopts=( ${lopts:#$~iopts[1]} ) + shift iopts + done + + # ... and add "same" options + + while (( $#sopts )); do + lopts=( $lopts ${opts/$sopts[1]/$sopts[2]} ) + shift 2 sopts + done + + # Then we walk through the descriptions plus a few builtin ones. + + set -- "${(@)argv[nth+1,-1]}" '*=FILE*:file:_files' \ + '*=(DIR|PATH)*:directory:_files -/' '*:unknown:' + + while (( $# )); do + + # First, we get the pattern and the action to use and take them + # from the positional parameters. + + pattern="${${${(M)1#*[^\\]:}[1,-2]}//\\\\:/:}" + descr="${1#${pattern}}" + shift + + # We get all options matching the pattern and take them from the + # list we have built. If no option matches the pattern, we + # continue with the next. + + tmp=("${(@M)lopts:##$~pattern}") + lopts=("${(@)lopts:##$~pattern}") + + (( $#tmp )) || continue + + opt='' + + # If there are option strings with a `[=', we take these get an + # optional argument. + + tmpo=("${(@M)tmp:#*\[\=*}") + if (( $#tmpo )); then + tmp=("${(@)tmp:#*\[\=*}") + tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}") + + if [[ "$descr" = ::* ]]; then + _args_cache_long=( "$_args_cache_long[@]" + "${(@)^tmpo}=${descr}" ) + else + _args_cache_long=( "$_args_cache_long[@]" + "${(@)^tmpo}=:${descr}" ) + fi + fi + + # Descriptions with `=': mandatory argument. + + tmpo=("${(@M)tmp:#*\=*}") + if (( $#tmpo )); then + tmp=("${(@)tmp:#*\=*}") + tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}") + + if [[ "$descr" = ::* ]]; then + _args_cache_long=( "$_args_cache_long[@]" + "${(@)^tmpo}=${descr[2,-1]}" ) + else + _args_cache_long=( "$_args_cache_long[@]" + "${(@)^tmpo}=${descr}" ) + fi + fi + + # Everything else is just added as a option without arguments. + + if (( $#tmp )); then + tmp=("${(@)tmp//[^a-zA-Z0-9-]}") + _args_cache_long=( "$_args_cache_long[@]" "$tmp[@]" ) + fi + done + fi + + set -- "$tmpargv[@]" "$_args_cache_long[@]" fi # Now parse the arguments... @@ -47,51 +186,71 @@ if [[ "$*" != "$_args_cache_descr" ]]; then nth=1 while (( $# )); do - # This describes a one-shot option. + # Description for both the `-foo' and `+foo' form? - if [[ "$1" = [-+]* ]]; then - if [[ "$1" = *:* ]]; then + if [[ "$1" = (\*|)(-+|+-)* ]]; then - # If the option name ends in a `-', the first argument comes - # directly after the option, if it ends in a `+', the first - # argument *may* come directly after the option, otherwise it - # is in the next word. + # With a `*' at the beginning, the option may appear more than + # once. - if [[ "$1" = [^:]##-:* ]]; then - tmp="${${1%%:*}[1,-2]}" - _args_cache_dopts[$tmp]="${1#*:}" - elif [[ "$1" = [^:]##+:* ]]; then - tmp="${${1%%:*}[1,-2]}" - _args_cache_odopts[$tmp]="${1#*:}" - else - tmp="${1%%:*}" - _args_cache_opts[$tmp]="${1#*:}" - fi + if [[ "$1" = \** ]]; then + tmp="${1[4,-1]%%:*}" + [[ "$tmp" = *[-+] ]] && tmp="$tmp[1,-2]" + unset "_args_cache_oneshot[-$tmp]" "_args_cache_oneshot[+$tmp]" else - tmp="$1" - _args_cache_opts[$tmp]='' + tmp="${1[3,-1]%%:*}" + [[ "$tmp" = *[-+] ]] && tmp="$tmp[1,-2]" + _args_cache_oneshot[-$tmp]=yes + _args_cache_oneshot[+$tmp]=yes fi - _args_cache_oneshot[$tmp]=yes - elif [[ "$1" = \*[-+]* ]]; then - - # The same for options that may appear more than once. - - if [[ "$1" = *:* ]]; then - if [[ "$1" = [^:]##-:* ]]; then - tmp="${${1[2,-1]%%:*}[1,-2]}" - _args_cache_dopts[$tmp]="${1#*:}" - elif [[ "$1" = [^:]##+:* ]]; then - tmp="${${1[2,-1]%%:*}[1,-2]}" - _args_cache_odopts[$tmp]="${1#*:}" - else - tmp="${1[2,-1]%%:*}" - _args_cache_opts[$tmp]="${1#*:}" - fi + + # If the option name ends in a `-', the first argument comes + # directly after the option, if it ends in a `+', the first + # argument *may* come directly after the option, otherwise it + # is in the next word. + + if [[ "$1" = [^:]##-:* ]]; then + _args_cache_dopts[-$tmp]="${1#*:}" + _args_cache_dopts[+$tmp]="${1#*:}" + elif [[ "$1" = [^:]##[+=]:* ]]; then + _args_cache_odopts[-$tmp]="${1#*:}" + _args_cache_odopts[+$tmp]="${1#*:}" + elif [[ "$1" = *:* ]]; then + _args_cache_opts[-$tmp]="${1#*:}" + _args_cache_opts[+$tmp]="${1#*:}" + else + _args_cache_opts[-$tmp]='' + _args_cache_opts[+$tmp]='' + fi + elif [[ "$1" = (\*|)[-+]* ]]; then + + # With a `*' at the beginning, the option may appear more than + # once. + + if [[ "$1" = \** ]]; then + tmp="${1[2,-1]%%:*}" + [[ "$tmp" = *[-+] ]] && tmp="$tmp[1,-2]" + unset "_args_cache_oneshot[$tmp]" + else + tmp="${1%%:*}" + [[ "$tmp" = *[-+] ]] && tmp="$tmp[1,-2]" + _args_cache_oneshot[$tmp]=yes + fi + + # If the option name ends in a `-', the first argument comes + # directly after the option, if it ends in a `+', the first + # argument *may* come directly after the option, otherwise it + # is in the next word. + + if [[ "$1" = [^:]##-:* ]]; then + _args_cache_dopts[$tmp]="${1#*:}" + elif [[ "$1" = [^:]##[+=]:* ]]; then + _args_cache_odopts[$tmp]="${1#*:}" + elif [[ "$1" = *:* ]]; then + _args_cache_opts[$tmp]="${1#*:}" else - tmp="${1[2,-1]}" _args_cache_opts[$tmp]='' fi - unset "_args_cache_oneshot[$tmp]" elif [[ "$1" = \*::* ]]; then # This is `*:...', describing `all other arguments', with argument @@ -131,7 +290,7 @@ if [[ "$*" != "$_args_cache_descr" ]]; then _args_cache_soptseq='' _args_cache_soptseq1='' fi - _args_cache_sopts="${(@j::)${(@M)${(@k)_args_cache_opts}:#[-+]?}#[-+]}${(@j::)${(@M)${(@k)_args_cache_dopts}:#[-+]?}#[-+]}${(@j::)${(@M)${(@k)_args_cache_odopts}:#[-+]?}#[-+]}" + _args_cache_sopts="${(@j::)${(@)${(@M)${=:-${(k)_args_cache_opts} ${(k)_args_cache_dopts} ${(k)_args_cache_odopts}}:#[-+]?(|=)}#?}%\=}" else _args_cache_soptseq='' _args_cache_soptseq1='' @@ -149,9 +308,6 @@ dopts=( "${(@kv)_args_cache_dopts}" ) odopts=( "${(@kv)_args_cache_odopts}" ) oneshot=( "${(@kv)_args_cache_oneshot}" ) single="$_args_cache_single" -long=( "$_args_cache_long[@]" ) - -argv=( "${(@)argv[1,_args_cache_long_nth]}" ) # Parse the command line... @@ -200,16 +356,10 @@ while [[ cur -gt 0 ]]; do fi elif [[ -z "$def" ]]; then - # If it is empty, and the word starts with `--' and we should - # complete long options, just ignore this word, otherwise make sure - # we test for options below and handle normal arguments. + # Make sure we test for options below and handle normal arguments. - if [[ $#long -eq 0 || "$ws[1]" != --* ]]; then - opt=yes - arg=yes - else - def='' - fi + opt=yes + arg=yes fi if [[ -n "$opt" ]]; then @@ -287,7 +437,7 @@ while [[ cur -gt 0 ]]; do fi fi if [[ -n "$opt" && $#odopts -ne 0 ]]; then - tmp=( "${(@k)odopts}" ) + tmp=( "${(@k)odopts%\=}" ) while (( $#tmp )); do if [[ -n "$sopts" && $tmp[1] = [-+]? ]]; then if [[ "$ws[1]" = ${tmp[1][1]}${~soptseq}${tmp[1][2]}* ]]; then @@ -303,6 +453,7 @@ while [[ cur -gt 0 ]]; do if (( $#tmp )); then opt='' def="$odopts[$tmp[1]]" + [[ -z "$def" ]] && def="$odopts[$tmp[1]=]" optbeg="$beg" argbeg="$beg" inopt=yes @@ -362,132 +513,101 @@ done # Now generate the matches. -if [[ $#long -ne 0 && "$PREFIX" = --* ]]; then +nm="$compstate[nmatches]" - # If the current words starts with `--' and we should use long - # options, just call... +if [[ -z "$def" || "$def" = :* ]]; then + local pre="$PREFIX" - _long_options "$long[@]" + uns='' -else - - nm="$compstate[nmatches]" + # We either don't have a description for an argument of an option + # or we have a description for a optional argument. - if [[ -z "$def" || "$def" = :* ]]; then - local pre="$PREFIX" - - uns='' + if [[ -z "$def" ]]; then - # We either don't have a description for an argument of an option - # or we have a description for a optional argument. + # If we have none at all, use the one for this argument position. + def="$args[nth]" if [[ -z "$def" ]]; then + def="$rest" + optbeg="$nargbeg" + argbeg="$nargbeg" + fromrest=yes + fi + fi - # If we have none at all, use the one for this argument position. + # In any case, we have to complete option names here, but we may + # be in a string that starts with an option name and continues with + # the first argument, test that (again, two loops). - def="$args[nth]" - if [[ -z "$def" ]]; then - def="$rest" - optbeg="$nargbeg" - argbeg="$nargbeg" - fromrest=yes - fi - fi + opt=yes + if (( $#dopts )); then - # In any case, we have to complete option names here, but we may - # be in a string that starts with an option name and continues with - # the first argument, test that (again, two loops). + # Get the option names. - opt=yes - if (( $#dopts )); then + tmp=( "${(@k)dopts}" ) + prefix="$PREFIX" + while (( $#tmp )); do + if [[ -n "$sopts" && $tmp[1] = [-+]? ]] && compset -P "${tmp[1][1]}${~soptseq}${tmp[1][2]}"; then + def="$dopts[$tmp[1]]" + opt='' + uns="${prefix[2,-1]%%${tmp[1][2]}*}${tmp[1][2]}" + break + elif compset -P "$tmp[1]"; then - # Get the option names. + # The current string starts with the option name, so ignore + # that and complete the rest of the string. - tmp=( "${(@k)dopts}" ) - prefix="$PREFIX" - while (( $#tmp )); do - if [[ -n "$sopts" && $tmp[1] = [-+]? ]] && compset -P "${tmp[1][1]}${~soptseq}${tmp[1][2]}"; then - def="$dopts[$tmp[1]]" - opt='' - uns="${prefix[2,-1]%%${tmp[1][2]}*}${tmp[1][2]}" - break - elif compset -P "$tmp[1]"; then + def="$dopts[$tmp[1]]" + opt='' + break + fi + shift 1 tmp + done + fi + if [[ -n "$opt" && $#odopts -ne 0 ]]; then + tmp=( "${(@k)odopts}" ) + prefix="$PREFIX" + while (( $#tmp )); do + if [[ -n "$sopts" && $tmp[1] = [-+]?(|=) ]] && compset -P "${tmp[1][1]}${~soptseq}${tmp[1][2]}${tmp[1][3]}"; then + def="$odopts[$tmp[1]]" + opt='' + uns="${prefix[2,-1]%%${tmp[1][2]}*}${tmp[1][2]}" + break + elif compset -P "$tmp[1]"; then + def="$odopts[$tmp[1]]" + opt='' + break + fi + shift 1 tmp + done + fi - # The current string starts with the option name, so ignore - # that and complete the rest of the string. + [[ -n "$sopts" && -n "$opt" && "$PREFIX" = [-+]${~soptseq}[$sopts] ]] && \ + uns="${PREFIX[2,-1]}" + + if [[ -n "$uns" ]]; then + uns="${(j::)${(@k)oneshot[(I)${ws[1][1]}[$uns]]#[-+]}}" + tmp=( + "opts[${(@)^opts[(I)${pre[1]}[$uns]]}]" + "dopts[${(@)^dopts[(I)${pre[1]}[$uns]]}]" + "odopts[${(@)^odopts[(I)${pre[1]}[$uns](|=)]}]" + ) + (( $#tmp )) && unset "$tmp[@]" + fi - def="$dopts[$tmp[1]]" - opt='' - break - fi - shift 1 tmp - done - fi - if [[ -n "$opt" && $#odopts -ne 0 ]]; then - tmp=( "${(@k)odopts}" ) - prefix="$PREFIX" - while (( $#tmp )); do - if [[ -n "$sopts" && $tmp[1] = [-+]? ]] && compset -P "${tmp[1][1]}${~soptseq}${tmp[1][2]}"; then - def="$odopts[$tmp[1]]" - opt='' - uns="${prefix[2,-1]%%${tmp[1][2]}*}${tmp[1][2]}" - break - elif compset -P "$tmp[1]"; then - def="$odopts[$tmp[1]]" - opt='' - break - fi - shift 1 tmp - done - fi + # If we aren't in an argument directly after a option name, all option + # names are possible matches. - [[ -n "$sopts" && -n "$opt" && "$PREFIX" = [-+]${~soptseq}[$sopts] ]] && \ - uns="${PREFIX[2,-1]}" - - if [[ -n "$uns" ]]; then - uns="${(j::)${(@k)oneshot[(I)${ws[1][1]}[$uns]]#[-+]}}" - tmp=( - "opts[${(@)^opts[(I)${pre[1]}[$uns]]}]" - "dopts[${(@)^dopts[(I)${pre[1]}[$uns]]}]" - "odopts[${(@)^odopts[(I)${pre[1]}[$uns]]}]" - ) - (( $#tmp )) && unset "$tmp[@]" - fi + [[ -z "$opt" || ( "$def" = \** && + ( -z "$fromrest" || CURRENT -ne argbeg+1 ) ) ]] && opt='' +else + opt='' +fi - if [[ -n "$opt" && ( "$def" != \** || - ( -n "$fromrest" && CURRENT -eq argbeg+1 ) ) ]]; then - - # We aren't in an argument directly after a option name, so - # all option names are possible matches. - - if [[ "$compconfig[option_prefix]" != *(short|all)* || - "$PREFIX" = [-+]* ]]; then - _description expl option - if [[ -n "$sopts" && -n "$PREFIX" && "$PREFIX" = [-+]${~soptseq}[$sopts] ]]; then - if [[ "$PREFIX" = [-+]${~soptseq1} ]]; then - compadd "$expl[@]" -Q -M 'r:|_=* r:|=*' \ - -y "( ${(j: :)${(@M)${(@k)opts}:#[-+]?}} ${(j: :)${(@M)${(@k)dopts}:#[-+]?}} ${(j: :)${(@M)${(@k)odopts}:#[-+]?}} )" - \ - "${PREFIX}${(@k)^opts[(I)${PREFIX[1]}?]#?}" \ - "${PREFIX}${(@k)^dopts[(I)${PREFIX[1]}?]#?}" \ - "${PREFIX}${(@k)^odopts[(I)${PREFIX[1]}?]#?}" && ret=0 - else - # The last option takes an argument in the next word. - compadd "$expl[@]" -Q -M 'r:|_=* r:|=*' - "${PREFIX}" && ret=0 - fi - else - compadd "$expl[@]" -Q -M 'r:|_=* r:|=*' - \ - "${(@k)opts}" "${(@k)odopts}" && ret=0 - compadd "$expl[@]" -QS '' -M 'r:|_=* r:|=*' - "${(@k)dopts}" && ret=0 - fi - fi - [[ $#long -ne 0 && - ( "$compconfig[option_prefix]" != *(long|all)* || - "$PREFIX" = --* ) ]] && \ - _long_options "$long[@]" && ret=0 - fi - fi +# Now add the matches from the description, if any. - # Now add the matches from the description, if any. +while true; do if [[ -n "$def" ]]; then @@ -503,20 +623,20 @@ else if [[ "$def" = ::* ]]; then def="$def[3,-1]" beg=$argbeg - else + else def="$def[2,-1]" beg=$optbeg - fi + fi - [[ beg -ge $#words ]] && beg=$(( $#words - 1 )) + [[ beg -ge $#words ]] && beg=$(( $#words - 1 )) - shift beg words - (( CURRENT -= beg )) + shift beg words + (( CURRENT -= beg )) - if [[ -n "$tmp" ]]; then + if [[ -n "$tmp" ]]; then tmp="$words[(ib:CURRENT:)${~tmp}]" [[ tmp -le $#words ]] && words=( "${(@)words[1,tmp-1]}" ) - fi + fi fi fi @@ -536,7 +656,7 @@ else # An empty action means that we should just display a message. _message "$descr" - return ret + break elif [[ "$action" = \(\(*\)\) ]]; then @@ -587,7 +707,56 @@ ${(r:beg:: :)nth%%:*} -- ${nth#*:}" fi fi - # Set the return value. + if [[ nm -eq compstate[nmatches] && $#_args_cache_long -ne 0 && + "$PREFIX" = --*=* ]]; then + local suffix + + tmp=( "${(@Mk)odopts:#--[^:]#\=}" ) + prefix="${PREFIX#*\=}" + suffix="$SUFFIX" + PREFIX="${PREFIX%%\=*}" + SUFFIX='' + compadd -M 'r:|[_-]=* r:|=*' -D tmp - "${(@)tmp%\=}" + + if [[ $#tmp -eq 1 ]]; then + def="$odopts[$tmp[1]]" + PREFIX="$prefix" + SUFFIX="$suffix" + IPREFIX="$tmp[1]" + continue + fi + fi + break +done + +# Probably add the option names. + +if [[ -n "$opt" && + ( nm -eq compstate[nmatches] || + -z "$compconfig[option_prefix]" || "$PREFIX" = [-+]* ) ]]; then + _description expl option + if [[ -n "$sopts" && -n "$PREFIX" && + "$PREFIX" = [-+]${~soptseq}[$sopts] ]]; then + if [[ "$PREFIX" = [-+]${~soptseq1} ]]; then + compadd "$expl[@]" -Q -M 'r:|[_-]=* r:|=*' \ + -y "( ${(j: :)${(@)${(@M)${=:-${(k)opts} ${(k)dopts} ${(k)odopts}}:#[-+]?(|=)}#?}%=} )" - \ + "${PREFIX}${(@k)^opts[(I)${PREFIX[1]}?]#?}" \ + "${PREFIX}${(@k)^dopts[(I)${PREFIX[1]}?]#?}" \ + "${PREFIX}${(@)^${(@k)odopts[(I)${PREFIX[1]}?(|=)]#?}%=}" && ret=0 + else + # The last option takes an argument in the next word. - [[ nm -ne "$compstate[nmatches]" ]] + compadd "$expl[@]" -Q -M 'r:|[_-]=* r:|=*' - "${PREFIX}" && ret=0 + fi + else + compadd "$expl[@]" -Q -M 'r:|[_-]=* r:|=*' - \ + "${(@k)opts}" "${(@k)odopts[(I)*[^=]]}" && ret=0 + compadd "$expl[@]" -Q -M 'r:|[_-]=* r:|=*' -qS= - \ + "${(@k)odopts[(I)*=]%=}" && ret=0 + compadd "$expl[@]" -QS '' -M 'r:|[_-]=* r:|=*' - "${(@k)dopts}" && ret=0 + fi fi + +# Set the return value. + +[[ nm -ne "$compstate[nmatches]" ]] diff --git a/Completion/Rpm/_rpm b/Completion/Rpm/_rpm new file mode 100644 index 000000000..4a64bbfbb --- /dev/null +++ b/Completion/Rpm/_rpm @@ -0,0 +1,15 @@ +#compdef rpm + +_rpm_arguments \ + '-q:*:query: _rpm_query' \ + -{V,y,-{setperms,setugids,querytags,initdb,showrc}} \ + '-pipe:*:pipe command:_command_names -e' \ + '--verify:*:verify: _rpm_verify' \ + -{i,-install}':*:install: _rpm_install' \ + -{U,-upgrade}':*:upgrade: _rpm_upgrade' \ + -{e,-erase}':*:uninstall: _rpm_uninstall' \ + -'b+:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages)):*:build: _rpm_build -b' \ + -'t+:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages)):*:build: _rpm_build -t' \ + --{rebuild,rmsource,recompile,resign,addsign}':*:RPM package: _rpm_package' \ + -{K,-checksig}':*:sigcheck: _rpm_sigcheck' \ + '--rebuilddb:*:rebuild: _rpm_rebuild' diff --git a/Completion/Rpm/_rpm_arguments b/Completion/Rpm/_rpm_arguments new file mode 100644 index 000000000..caac00b25 --- /dev/null +++ b/Completion/Rpm/_rpm_arguments @@ -0,0 +1,8 @@ +#autoload + +_arguments \ + -{v,vv} \ + '-rcfile:resource file:_files' \ + '--ftpproxy:FTP proxy server:_hosts' \ + '--ftpport:FTP port number:' \ + "$@" diff --git a/Completion/Rpm/_rpm_build b/Completion/Rpm/_rpm_build new file mode 100644 index 000000000..1702e5d8e --- /dev/null +++ b/Completion/Rpm/_rpm_build @@ -0,0 +1,16 @@ +#autoload + +local args + +if [[ "$1" = -b ]]; then + args='*:RPM package:_rpm_package' +else + args='*:tar file:_files -g \*.\(\#i\)tar\(.\*\|\)' +fi + +_rpm_arguments \ + --{short-circuit,clean,rmsource,sign,test} \ + '--buildroot:build root directory:_files -/' \ + '--buildarch:architecture for which to build:' \ + '--buildos:ositecture for which to build:' \ + '--timecheck:time check (seconds):' "$args" diff --git a/Completion/Rpm/_rpm_capability b/Completion/Rpm/_rpm_capability new file mode 100644 index 000000000..5bd8a1afe --- /dev/null +++ b/Completion/Rpm/_rpm_capability @@ -0,0 +1,3 @@ +#autoload + +_message 'RPM capability' diff --git a/Completion/Rpm/_rpm_install b/Completion/Rpm/_rpm_install new file mode 100644 index 000000000..173a5a620 --- /dev/null +++ b/Completion/Rpm/_rpm_install @@ -0,0 +1,10 @@ +#autoload + +_rpm_arguments \ + "$@" \ + -{-{badreloc,excludedocs,force,hash,allfiles,ignorearch,ignoreos,includedocs,justdb,nodeps,noorder,noscripts,notriggers,percent,replacefiles,replacepkgs,test},h} \ + '--relocate:relocate:_rpm_relocate' \ + '--prefix:package prefix directory:_files -/' \ + '--root:RPM root directory:_files -/' \ + '--dbpath:RPM database path:_files -/' \ + '*:pkg file:_rpm_pkg_file' diff --git a/Completion/Rpm/_rpm_package b/Completion/Rpm/_rpm_package new file mode 100644 index 000000000..0cac1c917 --- /dev/null +++ b/Completion/Rpm/_rpm_package @@ -0,0 +1,6 @@ +#autoload + +local expl + +_description expl 'RPM package' +compadd "$expl[@]" -M 'r:|-=* r:|=*' - $(rpm -qa) diff --git a/Completion/Rpm/_rpm_pkg_file b/Completion/Rpm/_rpm_pkg_file new file mode 100644 index 000000000..2a211a28a --- /dev/null +++ b/Completion/Rpm/_rpm_pkg_file @@ -0,0 +1,7 @@ +#autoload + +if compset -P ftp:; then + _hosts -S/ +else + _files -g '*.(#i)rpm' +fi diff --git a/Completion/Rpm/_rpm_pkg_or_file b/Completion/Rpm/_rpm_pkg_or_file new file mode 100644 index 000000000..5af265df6 --- /dev/null +++ b/Completion/Rpm/_rpm_pkg_or_file @@ -0,0 +1,8 @@ +#autoload + +local ret=1 + +_rpm_package && ret=0 +_rpm_pkg_file && ret=0 + +return ret diff --git a/Completion/Rpm/_rpm_query b/Completion/Rpm/_rpm_query new file mode 100644 index 000000000..8721f5498 --- /dev/null +++ b/Completion/Rpm/_rpm_query @@ -0,0 +1,12 @@ +#autoload + +_rpm_arguments \ + '--root:RPM root directory:_files -/' \ + '--dbpath:RPM database path:_files -/' \ + '--queryformat:RPM query format:_rpm_tags' \ + '-f:file:_files' \ + '-p:RPM package file:_rpm_pkg_file' \ + '--triggeredby:RPM package:_rpm_package' \ + '--whatprovides:RPM capability:_rpm_capability' \ + '--whatrequires:RPM capability:_rpm_capability' \ + '*:RPM package:_rpm_pkg_or_file' diff --git a/Completion/Rpm/_rpm_rebuild b/Completion/Rpm/_rpm_rebuild new file mode 100644 index 000000000..e924a3b9f --- /dev/null +++ b/Completion/Rpm/_rpm_rebuild @@ -0,0 +1,6 @@ +#autoload + +_rpm_arguments \ + '--root:RPM root directory:_files -/' \ + '--dbpath:RPM database path:_files -/' \ + '*:RPM source package file:_rpm_pkg_file' diff --git a/Completion/Rpm/_rpm_rebuilddb b/Completion/Rpm/_rpm_rebuilddb new file mode 100644 index 000000000..0ab92aa6f --- /dev/null +++ b/Completion/Rpm/_rpm_rebuilddb @@ -0,0 +1,3 @@ +#autoload + +_rpm_arguments diff --git a/Completion/Rpm/_rpm_relocate b/Completion/Rpm/_rpm_relocate new file mode 100644 index 000000000..fd27bdd99 --- /dev/null +++ b/Completion/Rpm/_rpm_relocate @@ -0,0 +1,11 @@ +#autoload + +local expl + +if compset -P '*\='; then + _description expl 'new path' +else + _description expl 'old path' +fi + +_files "$expl[@]" -/ diff --git a/Completion/Rpm/_rpm_resign b/Completion/Rpm/_rpm_resign new file mode 100644 index 000000000..ef9dd932e --- /dev/null +++ b/Completion/Rpm/_rpm_resign @@ -0,0 +1,4 @@ +#autoload + +_rpm_arguments \ + '*:RPM binary package file:_rpm_pkg_file' diff --git a/Completion/Rpm/_rpm_sigcheck b/Completion/Rpm/_rpm_sigcheck new file mode 100644 index 000000000..a808197a8 --- /dev/null +++ b/Completion/Rpm/_rpm_sigcheck @@ -0,0 +1,5 @@ +#autoload + +_rpm_arguments \ + --no{pgp,md5} \ + '*:RPM package file:_rpm_pkg_or_file' diff --git a/Completion/Rpm/_rpm_tags b/Completion/Rpm/_rpm_tags new file mode 100644 index 000000000..2e65b39f3 --- /dev/null +++ b/Completion/Rpm/_rpm_tags @@ -0,0 +1,11 @@ +#autoload + +if compset -P '*\{'; then + local expl + + _description expl 'RPM tag' + compadd "$expl[@]" -M 'm:{a-z}={A-Z}' -S '}' - \ + "${(@)${(@f)$(rpm --querytags)}#RPMTAG_}" +else + _message 'RPM format' +fi diff --git a/Completion/Rpm/_rpm_uninstall b/Completion/Rpm/_rpm_uninstall new file mode 100644 index 000000000..c33852d50 --- /dev/null +++ b/Completion/Rpm/_rpm_uninstall @@ -0,0 +1,7 @@ +#autoload + +_rpm_arguments \ + --{allmatches,justdb,nodeps,noorder,noscripts,notriggers} \ + '--root:RPM root directory:_files -/' \ + '--dbpath:RPM database path:_files -/' \ + '*:RPM package:_rpm_package' diff --git a/Completion/Rpm/_rpm_upgrade b/Completion/Rpm/_rpm_upgrade new file mode 100644 index 000000000..3417b2b11 --- /dev/null +++ b/Completion/Rpm/_rpm_upgrade @@ -0,0 +1,3 @@ +#autoload + +_rpm_install --oldpackage diff --git a/Completion/Rpm/_rpm_verify b/Completion/Rpm/_rpm_verify new file mode 100644 index 000000000..049933f6f --- /dev/null +++ b/Completion/Rpm/_rpm_verify @@ -0,0 +1,7 @@ +#autoload + +_rpm_arguments \ + --no{deps,md5,files} \ + '--root:RPM root directory:_files -/' \ + '--dbpath:RPM database path:_files -/' \ + '*:RPM package:_rpm_package' diff --git a/Completion/User/_a2ps b/Completion/User/_a2ps index 956e5a0ff..3efbc60e7 100644 --- a/Completion/User/_a2ps +++ b/Completion/User/_a2ps @@ -22,18 +22,18 @@ if [[ "$words[1]" != "$_a2ps_cache_cmd" ]]; then ) fi -_long_options -t '*\*:toggle:(yes no)' \ - '*=DIRECTION:direction:(rows columns)' \ - '*=TYPE:type:(r n nr rn any)' \ - '--highlight-level*:highlight:(none normal heavy)' \ - '--version-control*:version control:(none off t numbered nil - existing never simple)' \ - "--pretty-print*:style:[${_a2ps_cache_values[1]}]" \ - "--encoding*:encoding:(${_a2ps_cache_values[2]})" \ - "--medium*:medium:[${_a2ps_cache_values[3]}]" \ - "--prologue*:prologue:[${_a2ps_cache_values[4]}]" \ - "--ppd*:printer description:[${_a2ps_cache_values[5]}]" \ - "--printer*:printer:[${_a2ps_cache_values[6]}]" \ - "--user-option*:user option:[${_a2ps_cache_values[7]}]" \ - "--variable*:variable:[${_a2ps_cache_values[8]}]" || - _files -F fignore -g '*~*.(ps|PS|eps|EPS)' +_arguments '*:text file:_files -g \*\~\*.\(\#i)\(ps\|eps\)' -- \ + '*\*:toggle:(yes no)' \ + '*=DIRECTION:direction:(rows columns)' \ + '*=TYPE:type:(r n nr rn any)' \ + '--highlight-level*:highlight:(none normal heavy)' \ + '--version-control*:version control:(none off t numbered nil + existing never simple)' \ + "--pretty-print*::style:(${_a2ps_cache_values[1]})" \ + "--encoding*:encoding:(${_a2ps_cache_values[2]})" \ + "--medium*::medium:(${_a2ps_cache_values[3]})" \ + "--prologue*::prologue:(${_a2ps_cache_values[4]})" \ + "--ppd*::printer description:(${_a2ps_cache_values[5]})" \ + "--printer*::printer:(${_a2ps_cache_values[6]})" \ + "--user-option*::user option:(${_a2ps_cache_values[7]})" \ + "--variable*::variable:(${_a2ps_cache_values[8]})" diff --git a/Completion/User/_configure b/Completion/User/_configure index 5861682d0..2a8713599 100644 --- a/Completion/User/_configure +++ b/Completion/User/_configure @@ -1,9 +1,9 @@ #compdef configure -_long_options -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' \ +_arguments -- -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' \ -s '(#--disable- --enable- #--enable- --disable- #--with- --without- #--without- --with-)' \ '*=(E|)PREFIX*:prefix directory:_files -/' \ - '*=PROGRAM*:program:_command_names' + '*=PROGRAM*:program:_command_names -e' diff --git a/Completion/User/_dvi b/Completion/User/_dvi index d49840ae9..2c97a0c00 100644 --- a/Completion/User/_dvi +++ b/Completion/User/_dvi @@ -1,3 +1,3 @@ -#compdef xdvi dvips dvibook dviconcat dvicopy dvidvi dviselect dvitodvi dvitype +#compdef dvips dvibook dviconcat dvicopy dvidvi dviselect dvitodvi dvitype _files -g '*.(dvi|DVI)' diff --git a/Completion/User/_gdb b/Completion/User/_gdb index 57914773c..1f64f0c1f 100644 --- a/Completion/User/_gdb +++ b/Completion/User/_gdb @@ -5,9 +5,10 @@ local cur="$words[CURRENT]" prev w list ret=1 expl -_long_options -t '*=(CORE|SYM)FILE:core file:_files' \ - '*=EXECFILE:executable:_files *(*)' \ - '*=TTY:terminal device:compadd /dev/tty*' && return 0 +[[ "$PREFIX" = --* ]] && + _arguments -- '*=(CORE|SYM)FILE:core file:_files' \ + '*=EXECFILE:executable:_files \*\(\*\)' \ + '*=TTY:terminal device:compadd /dev/tty\*' && return 0 if compset -P '-(cd|directory)='; then _files -/ diff --git a/Completion/User/_gs b/Completion/User/_gs new file mode 100644 index 000000000..8ecd99570 --- /dev/null +++ b/Completion/User/_gs @@ -0,0 +1,19 @@ +#compdef gs ghostscript + +if compset -N --; then + if [[ CURRENT -eq 1 ]]; then + _ps + else + _message 'userdict ARGUMENTS' + return 1 + fi +else + _x_options \ + -q \ + '-g-:device size (<width>x<height>):' \ + '-r-:resolution (<val> or <x>x<y>):' \ + '-I:search paths:_dir_list' \ + \*-{d,D}'-:def: _gs_name -d' \ + \*-{s,S}'-:def: _gs_name -s' \ + '*:PostScript file:_ps' +fi diff --git a/Completion/User/_gs_name b/Completion/User/_gs_name new file mode 100644 index 000000000..3aef646eb --- /dev/null +++ b/Completion/User/_gs_name @@ -0,0 +1,31 @@ +#autoload + +local expl + +if [[ "$1" = -d ]]; then + if [[ "$PREFIX" = *\=* ]]; then + _message 'systemdict definition value' + else + _description expl 'systemdict definition name' + compadd "$expl[@]" -M 'm:{a-z}={A-Z}' - \ + DISKFONTS NOCACHE NOBIND NODISPLAY NOPAUSE PLATFONTS SAFER \ + WRITESYSTEMDICT + fi +elif compset -P '*\='; then + case "$IPREFIX" in + *DEVICE\=) + _description expl 'ghostscript device' + compadd "$expl[@]" - "${(@)${=${$(gs -h)##* devices:}%%Search path:*}:#}" + ;; + *OutputFile\=) + _description expl 'output file' + _files + ;; + *) + _message 'systemdict value' + return 1 + esac +else + _description expl 'systemdict name' + compadd "$expl[@]" -S\= -M 'm:{a-z}={A-Z}' - DEVICE OutputFile +fi diff --git a/Completion/User/_patch b/Completion/User/_patch index 3258e9cee..0c66f99dd 100644 --- a/Completion/User/_patch +++ b/Completion/User/_patch @@ -3,21 +3,17 @@ _arguments -s \ '-p+:number:(0)' \ '-F+:lines:' \ - '-l' '-c' '-e' '-n' '-u' '-N' '-R' \ + -{l,c,e,n,u,N,R,E,Z,T,b,t,f,s,v} \ '-i+:patch file:_files' \ '-o+:output file:_files' \ '-r+:reject file:_files' \ '-D+:name:' \ - '-E' '-Z' '-T' \ - '-b' \ '-V+:version control style:(simple numbered existing)' \ '-B+:backup path prefix:' \ '-Y+:backup basename prefix:_files' \ '-z+:backup file suffix:(.bak)' \ '-g+:NUM:' \ - '-t' '-f' '-s' \ '-d+:chdir to:_files -/' \ - '-v' \ ':original file:_files' \ ':patch file:_files' \ -- \ diff --git a/Completion/User/_pspdf b/Completion/User/_pspdf index ecc4cf82b..b4dadb3d0 100644 --- a/Completion/User/_pspdf +++ b/Completion/User/_pspdf @@ -1,11 +1,12 @@ -#compdef gs gsbj gsdj gsdj500 gslj gslp gsnd ps2ascii ghostview gv gview mgv ggv pstoedit pstotgif +#compdef gsbj gsdj gsdj500 gslj gslp gsnd ps2ascii ghostview mgv ggv pstoedit pstotgif -local ret=1 +local ret=1 expl # ghostscript: # gs gsbj gsdj gsdj500 gslj gslp gsnd ps2ascii _ps && ret=0 -_pdf && ret=0 +_description expl 'PDF file' +_path_files "$expl[@]" -g '*.(#i)pdf' return ret diff --git a/Completion/User/_tar b/Completion/User/_tar index 8135bf006..85cf21566 100644 --- a/Completion/User/_tar +++ b/Completion/User/_tar @@ -72,11 +72,11 @@ if [[ "$PREFIX" = --* ]]; then # ...long options after `--'. - _long_options '--owner*:user:_users' \ - '*=(PROG|COMMAND)*:program:_command_names' \ - '*=ARCHIVE*:archive: _tar_archive' \ - '*=NAME*:file:_files' \ - '*=CONTROL*:version control:[t numbered nil existing never simple]' + _arguements -- '--owner*:user:_users' \ + '*=(PROG|COMMAND)*:program:_command_names -e' \ + '*=ARCHIVE*:archive: _tar_archive' \ + '*=NAME*:file:_files' \ + '*=CONTROL*::version control:(t numbered nil existing never simple)' elif [[ ( CURRENT -gt 2 && "$words[CURRENT-1]" = -*f* && "$words[CURRENT-1]" != --* ) || diff --git a/Completion/User/_use_lo b/Completion/User/_use_lo index a22a5fdb2..56651dd67 100644 --- a/Completion/User/_use_lo +++ b/Completion/User/_use_lo @@ -3,4 +3,6 @@ # This is for GNU-like commands which understand the --help option, # but which do not otherwise require special completion handling. -_long_options -t || _default +[[ "$PREFIX" = --* ]] && _arguments -- && return 0 + +_default diff --git a/Completion/User/_xfig b/Completion/User/_xfig index 2dd7f94f2..a0d36c189 100644 --- a/Completion/User/_xfig +++ b/Completion/User/_xfig @@ -1,42 +1,23 @@ #compdef xfig _x_options \ - '-help' \ - '-Landscape' \ - '-Portrait' \ + -{help,Landscape,Portrait,debug,dontswitchcmap,flushleft,inches,inverse,latexfonts,left,metric,monochrome,multiple,noscalablefonts,notrack,right,scalablefonts,showallbuttons,single,specialtext,tablet,track} \ '-bold:bold font:_x_font' \ '-button:button font:_x_font' \ '-but_per_row:number of buttons:' \ '-cbg:canvas background color:_colors' \ '-cfg:canvas foreground color:_colors' \ - '-debug' \ '-depth:visual depth:_x_visdepth' \ - '-dontswitchcmap' \ '-exportlanguage:export language:(box latex epic eepic eepicemu pictex ibmgl eps ps pstex textyl tpic pic mf acad pcx png gif jpeg tiff ppm xbm xpm)' \ - '-flushleft' \ '-iconGeometry:icon geometry:_x_geometry' \ - '-inches' \ '-internalBW:internal border width:' \ - '-inverse' \ '-keyfile:compose key file:_files' \ - '-latexfonts' \ - '-left' \ '-magnification:magnification factor:' \ '-max_image_colors:maximum number of colors:' \ - '-metric' \ - '-monochrome' \ - '-multiple' \ '-normal:normal font:_x_font' \ - '-noscalablefonts' \ - '-notrack' \ '-papersize:output paper size:((Letter\:8.5\"\ x\ 11\" Legal\:8.5\"\ x\ 14\" Ledger\:17\"\ x\ 11\" Tabloid\:11\"\ x\ 17\" A\:8.5\"\ x\ 11\" B\:11\"\ x\ 17\" C\:17\"\ x\ 22\" D\:22\"\ x\ 34\" E\:34\"\ x\ 44\" A4\:21\ cm\ x\ 29.7\ cm A3\:29.7\ cm\ x\ 42\ cm A2\:42\ cm\ x\ 59.4\ cm A1\:59.4\ cm\ x\ 84.1\ cm A0\:84.1\ cm\ x\ 118.9\ cm B%\:18.2\ cm\ x\ 25.7\ cm))' \ '-pheight:canvas height:' \ '-pwidth:canvas width:' \ - '-right' \ - '-scalablefonts' \ - '-showallbuttons' \ - '-single' \ - '-specialtext' \ '-spellcheckcommand:program: _command_names -e' \ '-startfillstyle:fill style (-1 to 21):' \ '-startfontsize:font size (in points):' \ @@ -46,8 +27,6 @@ _x_options \ '-startposnmode:positioning mode:((0\:any 1\:1/16\ inch\ or\ 1\ mm 2\:1/4\ inch\ or\ 5\ mm 3\:1/2\ inch\ or\ 1\ cm 4\:1\ inch\ or\ 2\ cm))' \ '-startpsfont:postscript font:' \ '-starttextstep:text step:' \ - '-tablet' \ - '-track' \ '-userscale:scale factor:' \ '-userunit:unit string:' \ '-visual:visual:(TrueColor StaticColor DirectColor StaticGray GrayScale PseudoColor)' \ diff --git a/Completion/User/_xsetroot b/Completion/User/_xsetroot index c3440a8ee..a6f62e998 100644 --- a/Completion/User/_xsetroot +++ b/Completion/User/_xsetroot @@ -1,16 +1,12 @@ #compdef xsetroot _x_options \ - '-help' \ - '-def' \ + -{help,def,gray,grey,rv} \ '-cursor:cursor file:_files -g \*.\(\#i\)\(xbm\|curs\(\|or\)\):mask file:_files -g \*.\(\#i\)\(xbm\|curs\(\|or\)\|mask\)' \ '-cursor_name:cursor name:_cursors' \ '-bitmap:bitmap file:_files -g \*.\(\#i\)xbm' \ '-mod:x grid distance (1-16): :y grid distance (1-16):' \ - '-gray' \ - '-grey' \ '-fg:foreground color:_colors' \ '-bg:background color:_colors' \ - '-rv' \ '-solid:screen solid color:_colors' \ '-name:root window name:' diff --git a/Completion/User/_xterm b/Completion/User/_xterm index 379e5a46d..6a7f28fd9 100644 --- a/Completion/User/_xterm +++ b/Completion/User/_xterm @@ -1,60 +1,24 @@ #compdef xterm _xt_arguments \ - '-version' \ - '-help' \ - '-132' \ - '-ah' '+ah' \ - '-ai' '+ai' \ - '-aw' '+aw' \ + -+{ah,ai,aw,bc,bdc,cb,cm,cn,cu,dc,hf,ie,im,j,ls,mb,nul,pc,rw,s,sb,sf,si,sk,sp,t,u8,ulc,ut,vb,wc,wf,samename} \ + -{version,help,132,leftbar,rightbar,C} \ '-b:inner border size:' \ - '-bc' '+bc' \ '-bcf:time text cursor is off when blinking (milliseconds):' \ '-bcn:time text cursor is on when blinking (milliseconds):' \ - '-bdc' '+bdc' \ - '-cb' '+cb' \ '-cc:character class:' \ - '-cm' '+cm' \ - '-cn' '+cn' \ '-cr:text cursor color:_colors' \ - '-cu' '+cu' \ - '-dc' '+dc' \ '-e:program: _command_names -e:*::program arguments: _normal' \ '-fb:bold font:_x_font' \ '-fi:icon font:_x_font' \ '-hc:background color for highlighted text:_colors' \ - '-hf' '+hf' \ - '-ie' '+ie' \ - '-im' '+im' \ - '-j' '+j' \ - '-leftbar' \ - '-ls' '+ls' \ - '-mb' '+mb' \ '-mc:multi-click threshold (milliseconds):' \ '-ms:pointer cursor color:_colors' \ '-nb:margin bell number:' \ - '-nul' '+nul' \ - '-pc' '+pc' \ - '-rightbar' \ - '-rw' '+rw' \ - '-s' '+s' \ - '-samename' '+samename' \ - '-sb' '+sb' \ - '-sf' '+sf' \ - '-si' '+si' \ - '-sk' '+sk' \ '-sl:save lines:' \ - '-sp' '+sp' \ - '-t' '+t' \ '-ti:terminal ID:(vt52 vt100 vt101 vt102 vt220)' \ '-tm:terminal setting:' \ '-tn:terminal type:' \ - '-u8' '+u8' \ - '-ulc' '+ulc' \ - '-ut' '+ut' \ - '-vb' '+vb' \ - '-wc' '+wc' \ - '-wf' '+wf' \ '-ziconbeep:iconbeep (percent):' \ '-C' \ - '-S-:pseudo-terminal and file descriptor:' \ + '-S-:pseudo-terminal and file descriptor:' diff --git a/Completion/X/_gv b/Completion/X/_gv new file mode 100644 index 000000000..887224a0f --- /dev/null +++ b/Completion/X/_gv @@ -0,0 +1,14 @@ +#compdef gv gview + +_xt_arguments \ + -{,no}{safer,quiet,center,swap,antialias,dsc,eof,pixmap,watch,resize} \ + -{monochrome,grayscale,color,portrait,landscape,upsidedown,seascape,h,help,v,spartan} \ + + '-arguments:ghostscript arguments:' \ + '-page:label of first page:' \ + '-media:page size:(Letter Legal Statement Tabloid Ledger Folio Quarto 10x14 Executive A3 A4 A5 B4 B5)' \ + '-scale:scale entry:' \ + '-scalebase:scale base:' \ + '-ad:resource file:_files' \ + '-style:resource file:_files' + '*:file:_pspdf' diff --git a/Completion/X/_xdvi b/Completion/X/_xdvi new file mode 100644 index 000000000..ea08e5110 --- /dev/null +++ b/Completion/X/_xdvi @@ -0,0 +1,30 @@ +#compdef xdvi + +_xt_arguments \ + -+{allowshell,copy,expert,hush{,chars,checksums,specials},keep,l,no{ghostscript,grey,gssafer,makepk,postscript,scan},safer,thorough,underlink,version} \ + +{altfont,base,browser,cr,debug,density,gamma,gspalette,hl,icongeometry,interpreter,margin,mfmode,offsets,p,paper,shrink,S,sidemargin,topmargin,xoffset,yoffset,grid{1,2,3},mgs{,1,2,3,4,5}} \ + '-altfont:default font:' \ + '-base:base URL:' \ + '-browser:WWW browser:_command_names -e' \ + '-cr:cursor color:_colors' \ + '-debug:debugging bitmask:((1\:bitmaps 2\:dvi\ translation 4\:pk\ reading 8\:batch\ operation 16\:events 32\:file\ opening 64\:PostScript\ communication 128\:Kpathsea\ statistics 256\:Kpathsea\ hash\ table\ lookups 512\:Kpathsea\ path\ definitions 1024\:Kpathsea\ path\ expansion 2048\:Kpathsea\ searches))' \ + '-density:font shrink density:' \ + '-gamma:anti-aliasing factor (default 1.0):' \ + -grid{1,2,3}':grid color:_colors' \ + '-gspalette:Ghostscript palette:(Color Greyscale Monochrome)' \ + '-hl:page highlight color:_colors' \ + '-icongeometry:icon geometry:_x_geometry' \ + '-interpreter:Ghostscript program:_command_names -e' \ + '-margin:margin size:' \ + '-mfmode:metafont string:' \ + -mgs{,1,2,3,4,5}':magnifier size:' \ + '-offsets:offset size:' \ + '-p:font size (pixel per inch):' \ + '-paper:paper size (<width>x<height> or ...):(us usr legal foolscap a1 a2 a3 a4 a5 a6 a7 b1 b2 b3 b4 b5 b6 b7 c1 c2 c3 c4 c5 c6 c7 a1r a2r a3r a4r a5r a6r a7r)' \ + '-shrink:shrink factor:' \ + '-S:font shrink density:' \ + '-sidemargin:side margin:' \ + '-topmargin:top margin:' \ + '-xoffset:horizontal offset:' \ + '-yoffset:vertical offset:' \ + '*:DVI file:_files -g \*.\(\#i\)dvi' diff --git a/Completion/X/_xt_arguments b/Completion/X/_xt_arguments index 6324c27e0..14e7b93f0 100644 --- a/Completion/X/_xt_arguments +++ b/Completion/X/_xt_arguments @@ -21,8 +21,8 @@ # cf. XrmParseCommand(3X11), X11R6.4/xc/lib/Xt/Initialize.c, X(5) _arguments \ - '+rv' '-rv' '-reverse' \ - '+synchronous' '-synchronous' \ + -+{rv,synchronous} \ + -{reverse,iconic} \ '-background:background color:_colors' \ '-bd:border color:_colors' \ '-bg:background color:_colors' \ @@ -31,10 +31,10 @@ _arguments \ '-bw:border width:_x_borderwidth' \ '-display:display:_x_display' \ '-fg:foreground color:_colors' \ + '-font:font:_x_font' \ '-fn:font:_x_font' \ '-foreground:foreground color:_colors' \ '-geometry:geometry:_x_geometry' \ - '-iconic' \ '-name:name:_x_name' \ '-selectionTimeout:selection timeout (milliseconds):_x_selection_timeout' \ '-title:title:_x_title' \ diff --git a/Completion/X/_xv b/Completion/X/_xv index ebaee4d8d..4178e1dad 100644 --- a/Completion/X/_xv +++ b/Completion/X/_xv @@ -1,99 +1,45 @@ #compdef xv _x_options \ - '-help' \ + -{help,quick24,slow24,best24,noqcheck,pkludge,RM} \ + -+{fixed,rw,perfect,owncmap,stdcmap,cecmap,ninstall,8,24,root,noresetroot,max,maxpect,quit,clear,cmap,imap,cemap,cmtmap,vsmap,nopos,dither,smooth,raw,acrop,4x3,hflip,vflip,norm,hist,mono,rv,wloop,random,loadclear,nofreecols,rgb,hsv,lbrowse,nostat,2xlimit,nolimits,close,iconic,viewonly,poll,vsperfect,vsdisable,nodecor} \ '-fg:foreground color:_colors' \ '-bg:background color:_colors' \ '-hi:top left shadow color:_colors' \ '-lo:bottom right shadow color:_colors' \ '-bw:border width:' \ '-geometry:geometry:_x_geometry' \ - '-fixed' '+fixed' \ '-expand:expansion factor:' \ '-aspect:aspect ratio (e.g. 4:3):' \ '-ncols:maximum number of colors used:' \ - '-rw' '+rw' \ - '-perfect' '+perfect' \ - '-owncmap' '+owncmap' \ - '-stdcmap' '+stdcmap' \ - '-cecmap' '+cecmap' \ - '-ninstall' '+ninstall' \ - '-8' '+8' \ - '-24' '+24' \ - '-quick24' \ - '-slow24' \ - '-best24' \ - '-noqcheck' \ - '-root' '+root' \ - '-rmode:root display mode:((0\:tiling 1\:integer\ tiling 2\:mirrored\ tiling 3\:integer\ mirrored\ tiling 4\:centered\ tiling 5\:centered\ tiling\ on\ solid\ background 6\:centered\ tiling\ on\ '"'"'warp'"'"'\ background 7\:centered\ tiling\ on\ '"'"'brick'"'"'\ background 8\:symmetrical\ tiling 9\:symmetrical\ mirrored\ tiling))' \ - '-noresetroot' '+noresetroot' \ + '-rmode:root display mode:((0\:tiling 1\:integer\ tiling 2\:mirrored\ tiling 3\:integer\ mirrored\ tiling 4\:centered\ tiling 5\:centered\ tiling\ on\ solid\ background 6\:centered\ tiling\ on\ '\\\''warp'\\\''\ background 7\:centered\ tiling\ on\ '\\\''brick'\\\''\ background 8\:symmetrical\ tiling 9\:symmetrical\ mirrored\ tiling))' \ '-rfg:root foreground color:_colors' \ '-rbg:root background color:_colors' \ - '-max' '+max' \ - '-maxpect' '+maxpect' \ - '-quit' '+quit' \ - '-clear' '+clear' \ - '-cmap' '+cmap' \ '-cgeom:control window geometry:_x_geometry' \ - '-imap' '+imap' \ '-igeom:info window geometry:_x_geometry' \ - '-cemap' '+cemap' \ '-cegeom:color editor window geometry:_x_geometry' \ - '-cmtmap' '+cmtmap' \ '-cmtgeometry:comments window geometry:_x_geometry' \ '-tgeometry:text view window geometry:_x_geometry' \ - '-vsmap' '+vsmap' \ '-vsgeometry:visual schauzer geometry:_x_geometry' \ - '-nopos' '+nopos' \ - '-dither' '+dither' \ - '-smooth' '+smooth' \ - '-raw' '+raw' \ '-crop:left border: :top border: :width: :height:' \ - '-acrop' '+acrop' \ - '-4x3' '+4x3' \ - '-hflip' '+hflip' \ - '-vflip' '+vflip' \ '-rotate:rotation angle:(0 90 -90 +90 180 -180 +180 270 -270 +270)' \ - '-norm' '+norm' \ - '-hist' '+hist' \ '-gamma:gamma value:' \ '-cgamma:red gamma value: :green gamma value: :blue gamma value:' \ '-preset:default preset (1-4):(1 2 3 4)' \ - '-mono' '+mono' \ - '-rv' '+rv' \ '-white:'"'"'white'"'"' color:_colors' \ '-black:'"'"'black'"'"' color:_colors' \ '-wait:seconds to wait:' \ - '-wloop' '+wloop' \ - '-random' '+random' \ - '-loadclear' '+loadclear' \ - '-nofreecols' '+nofreecols' \ - '-rgb' '+rgb' \ - '-hsv' '+hsv' \ - '-lbrowse' '+lbrowse' \ - '-nostat' '+nostat' \ - '-visual:visual:(TrueColor StaticColor DirectColor StaticGray GrayScale PseudoColor)' \ + '-visual:visual:(TrueColor StaticColor DirectColor StaticGray GrayScale PseudoColor)' \ '-cursor:cursor character number:' \ - '-2xlimit' '+2xlimit' \ - '-nolimits' '+nolimits' \ - '-close' '+close' \ - '-iconic' '+iconic' \ '-icgeometry:icon geometry:_x_geometry' \ '-dir:directory:_files -/' \ '-flist:file list file:_files' \ '-drift:x movement correction: :y movement correction:' \ - '-pkludge' \ '-mfn:mono spaced font:_x_font' \ '-name:window name:_x_name' \ - '-viewonly' '+viewonly' \ - '-grabdelay:grab delay (seconds):' '+grabdelay:grab delay (seconds):' \ - '-poll' '+poll' \ - '-vsperfect' '+vsperfect' \ - '-vsdisable' '+vsdisable' \ + '-+grabdelay:grab delay (seconds):' \ '-gsdev:ghostscript device:' \ '-gsres:ghostscript resolution:' \ '-gsgeom:ghostscript page size:' \ - '-nodecor' '+nodecor' \ - '-RM' \ '-DEBUG:debug level:' \ '*:picture file:_files -g \*.\(\#i\)\(gif\|jpeg\|tiff\|pbm\|pgm\|ppm\|xbm\|xpm\|ras\(\|t\)\|tga\|rle\|rgb\|bmp\|pcx\|fits\|pm\)' diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index f3703acda..6186e004a 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -821,8 +821,6 @@ are used to store the option settings in effect before the completion widget locally sets the options it needs. ) item(tt(_long_options))( -This function resides in the tt(Base) subdirectory of the example -completion system because it is not used by the core system. This function is used to complete long options for commands that support the `tt(--help)' option as, for example, most of the GNU @@ -832,53 +830,10 @@ names. Note that this means that you should be careful to make sure that this function is not called for a command that does not support this option. -For options that get an argument after a `tt(=)', the function also tries -to automatically find out what should be completed as the argument. -The possible completions for option-arguments can be described with -the arguments to this function. Each argument contains one description -of the form `tt(<pattern>:<message>:<action>)'. The message will be printed -above the possible completion if the `description_format' configuration -key is set (see above). The actions specify what -should be done to complete arguments of those options that match -the pattern. In both the message and the action a colon can be -included by preceding it with a backslash. The action may be a list of -words in brackets or in -parentheses, separated by spaces. A list in brackets denotes -possible values for an optional argument, a list in parentheses -gives words to complete for mandatory arguments. If the action does -not start with a bracket or parentheses, it should be the name of a -command (probably with arguments) that should be invoked to complete -after the equal sign or a string in braces that will be evaluated. E.g.: - -example(_long_options '*\*' '(yes no)' \ - '*=FILE*' '_files' \ - '*=DIR*' '_files -/') - -Here, `tt(yes)' and `tt(no)' will be completed as the argument of -options whose description ends in a star, file names for options that -contain the substring `tt(=FILE)' in the description, and paths for -options whose description contains `tt(=DIR)'. In fact, the last two -patterns are not needed since this function always completes files -for option descriptions containing `tt(=FILE)' and paths for option -descriptions that contain `tt(=DIR)' or `tt(=PATH)'. These builtin -patterns can be overridden by patterns given as arguments, however. - -If the -option `tt(-t)' is given, completion is only done on words starting -with two hyphens. The option `tt(-i) var(patterns)' can be used to -give patterns for options which should not be completed. The patterns -can be given as the name of an array parameter or as a literal list in -parentheses. E.g. `tt(-i "(--(en|dis)able-FEATURE*)")' will ignore the -options `tt(--enable-FEATURE)' and `tt(--disable-FEATURE)'. Finally, -the option `tt(-s) var(pairs)' can be used to describe options -aliases. Each var(pair) consists of a pattern and a -replacement. E.g. some tt(configure)-scripts describe options only as -`tt(--enable-foo)', but also accept `tt(disable-foo)'. To allow -completion of the second form, one would use -`tt(-s "(#--enable- --disable-)")'. ) item(tt(_arguments))( -Like tt(_long_options), this function is in the tt(Base) subdirectory. +This function resides in the tt(Base) subdirectory of the example +completion system because it is not used by the core system. This function can be used to complete words on the line by simply describing the arguments the command on the line gets. The description @@ -906,7 +861,7 @@ that any number of arguments can be completed. If there are two colons before the message (as in `tt(*::)var(message)tt(:)var(action)') the tt(words) special array and the tt(CURRENT) special parameter will be restricted to only the -normal arguments when the var(Action) is executed or evaluated. +normal arguments when the var(action) is executed or evaluated. ) item(var(opt-spec)[var(description) ...])( This describes an option and (if at least one var(description) is @@ -941,7 +896,10 @@ em(in the same word), a minus sign should be added to the end of the var(opt-spec), as in `tt(-foo-)'. If the first argument may be given in one string with the option name, but may also be given as a separate argument after the option, a plus sign should be used -instead. Finally, if the option may be given more than once, a star +instead. If the argument may be given as the next string or in same +string as the option name but separated by it from an equal sign, a +`tt(=)' should be used instead of the minus or plus sign. +Finally, if the option may be given more than once, a star (`tt(*)') should be added in front of the var(opt-spec). ) enditem() @@ -976,10 +934,57 @@ none). By giving the tt(-s) option to this function (as the first argument), options are considered to be one-character options and the string from the line may contain more than one such option letter. -This function can also be made to automatically call the -tt(_long_options) function where appropriate by giving it the string -`tt(--)' as an argument. All arguments after this will be given -unchanged to the tt(_long_options) function. +The function can also be made to automatically complete long options +for commands that support the `tt(--help)' option as, for example, +most of the GNU commands do. For this, the string `tt(--)' must be +given as one argument and if it is, the command from the line is +invoked with the `tt(--help)' option and its output is parsed to find +possible option names. Note that this means that you should be careful +to make sure that this feature is not used for a command that does not +support this option. + +For options that get an argument after a `tt(=)', the function also tries +to automatically find out what should be completed as the argument. +The possible completions for option-arguments can be described with +the arguments after the `tt(--)' (which are not used as described +above). Each argument contains one description of the form +`var(pattern)tt(:)var(message)tt(:)var(action)'. The var(message) and +the var(action) have the same format as for the normal option +descriptions described above. The var(action) will be executed to +complete arguments of options whose description in the output of the +command from the line with the `tt(--help)' option matches the +var(pattern). For example: + +example(_arguments -- '*\*' '(yes no)' \ + '*=FILE*' '_files' \ + '*=DIR*' '_files -/') + +Here, `tt(yes)' and `tt(no)' will be completed as the argument of +options whose description ends in a star, file names for options that +contain the substring `tt(=FILE)' in the description, and paths for +options whose description contains `tt(=DIR)'. In fact, the last two +patterns are not needed since this function always completes files +for option descriptions containing `tt(=FILE)' and paths for option +descriptions that contain `tt(=DIR)' or `tt(=PATH)'. These builtin +patterns can be overridden by patterns given as arguments, however. + +Note also that tt(_arguments) tries to find out automatically if the +argument for an option is optional. If it fails to automatically +detect this, the colon before the var(message) can be doubled to tell +it about this as described for the normal option descriptions above. + +The option `tt(-i) var(patterns)' (which must be given after the +`tt(--)') can be used to give patterns for options which should not be +completed. The patterns can be given as the name of an array parameter +or as a literal list in parentheses. E.g. `tt(-i +"(--(en|dis)able-FEATURE*)")' will make the options +`tt(--enable-FEATURE)' and `tt(--disable-FEATURE)' be ignored. The +option `tt(-s) var(pairs)' (again, after the `tt(--)') can be used to +describe option aliases. Each var(pair) consists of a pattern and a +replacement. E.g. some tt(configure)-scripts describe options only as +`tt(--enable-foo)', but also accept `tt(disable-foo)'. To allow +completion of the second form, one would use `tt(-s "(#--enable- +--disable-)")'. Finally, this function uses one configuration key: tt(option_prefix). If this is set to a string containing `tt(short)' or `tt(all)' as a |