From 8ceb54fbc2f879e0e80f58c18761bd54db07e5f7 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Thu, 15 Apr 1999 18:25:40 +0000 Subject: zsh-3.1.5-pws-15 --- Completion/Base/_brace_parameter | 2 +- Completion/Base/_command_names | 2 +- Completion/Base/_condition | 2 +- Completion/Base/_default | 2 +- Completion/Base/_equal | 2 +- Completion/Base/_long_options | 86 +++++++++++++++++++++++++++------------- Completion/Base/_math | 4 +- Completion/Base/_parameter | 2 +- Completion/Base/_precommand | 2 +- Completion/Base/_redirect | 2 +- Completion/Base/_subscript | 2 +- Completion/Base/_tilde | 2 +- Completion/Base/_vars | 2 +- 13 files changed, 72 insertions(+), 40 deletions(-) (limited to 'Completion/Base') diff --git a/Completion/Base/_brace_parameter b/Completion/Base/_brace_parameter index 3d663a777..d45e317be 100644 --- a/Completion/Base/_brace_parameter +++ b/Completion/Base/_brace_parameter @@ -1,4 +1,4 @@ -#defcomp -brace-parameter- +#compdef -brace-parameter- if [[ "$SUFFIX" = *\}* ]]; then ISUFFIX="${SUFFIX#*\}}$ISUFFIX" diff --git a/Completion/Base/_command_names b/Completion/Base/_command_names index f21af674c..8f75f1a77 100644 --- a/Completion/Base/_command_names +++ b/Completion/Base/_command_names @@ -1,4 +1,4 @@ -#defcomp -command- +#compdef -command- local nm=$compstate[nmatches] ret=1 diff --git a/Completion/Base/_condition b/Completion/Base/_condition index df1bf913e..c617d9d90 100644 --- a/Completion/Base/_condition +++ b/Completion/Base/_condition @@ -1,4 +1,4 @@ -#defcomp -condition- +#compdef -condition- local prev="$words[CURRENT-1]" diff --git a/Completion/Base/_default b/Completion/Base/_default index 9ea1a09db..b49ca7115 100644 --- a/Completion/Base/_default +++ b/Completion/Base/_default @@ -1,4 +1,4 @@ -#defcomp -default- +#compdef -default- # We first try the `compctl's. This is without first (-T) and default (-D) # completion. If you want them add `-T' and/or `-D' to this command. diff --git a/Completion/Base/_equal b/Completion/Base/_equal index f407014fe..0e2a11e46 100644 --- a/Completion/Base/_equal +++ b/Completion/Base/_equal @@ -1,3 +1,3 @@ -#defcomp -equal- +#compdef -equal- compgen -am diff --git a/Completion/Base/_long_options b/Completion/Base/_long_options index 97b11f2dc..6288fc3a0 100644 --- a/Completion/Base/_long_options +++ b/Completion/Base/_long_options @@ -32,12 +32,25 @@ # for option descriptions containing `=FILE' and paths for option # descriptions that contain `=DIR' or `=PATH'. These builtin patterns # can be overridden by patterns given as arguments, though. +# +# This function accepts following options: +# +# -t do completion only on words starting with two hyphens +# +# -i list of patterns. Options, matching these patterns, are ignored. +# The list may be given as array name or as literal list in braces. +# E.g. _long_options -i '(--(enable|disable)-FEATURE*)' will ignore +# --enable-FEATURE, that is listed in configure help output +# +# -s list of pattern/replacement pairs. The argument is the same as above. +# E.g. configure often lists only --enable but accepts both +# --enable and --disable options. +# _long_options -s '(#--enable- --disable)' will accept both forms. # # This function also accepts the `-X', `-J', and `-V' options which -# are given to `compadd'. Finally, it accepts the option `-t'. If this -# is given, completion is only done on words starting with two hyphens. +# are given to `compadd'. -local opt expl group test i name action ret=1 tmp suffix +local opt expl group test i name action ret=1 tmp suffix iopts sopts setopt extendedglob @@ -46,11 +59,23 @@ setopt extendedglob group=() expl=() if [[ $1 = -*~--* ]]; then - while getopts "J:V:X:t" opt; do + while getopts "J:V:X:ti:s:" opt; do case "$opt" in [JV]) group=("-$opt" "$OPTARG");; X) expl=(-X "$OPTARG");; t) test=yes;; + i) if [[ "$OPTARG[1]" = '(' ]]; then + iopts=( ${=OPTARG[2,-2]} ) + else + iopts=( ${(P)${OPTARG}} ) + fi + ;; + s) if [[ "$OPTARG[1]" = '(' ]]; then + sopts=( ${=OPTARG[2,-2]} ) + else + sopts=( ${(P)${OPTARG}} ) + fi + ;; esac done shift OPTIND-1 @@ -77,6 +102,7 @@ if [[ "$tmp" != $_lo_cache_cmd ]]; then (( $+_lo_cache_actions )) && unset "$_lo_cache_names[@]" _lo_cache_actions _lo_cache_names local opts pattern anum=1 tmpo str + typeset -U opts # Now get the long option names by calling the command with `--help'. # The parameter expansion trickery first gets the lines as separate @@ -87,11 +113,24 @@ if [[ "$tmp" != $_lo_cache_cmd ]]; then # 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. Finally all elements with option strings - # that contain uppercase letters are removed. + # option up to the end. + + opts=("--${(@)^${(@)${(@M)${(@ps:\n:j:\n:)${(@)${(@M)${(@f)$("$words[1]" --help)}:#[ ]#-*}//,/ +}}:#[ ]#--*}#*--}%%[, ]*}") - opts=("--${(@)^${(@)${(@)${(@M)${(@ps:\n:j:\n:)${(@)${(@M)${(@f)$("$words[1]" --help)}:#[ ]#-*}//,/ -}}:#[ ]#--*}#*--}%%[, ]*}:#(*-[A-Z]*|)}") + # Now remove all ignored options ... + + while (($#iopts)) ; do + opts=( ${opts:#$~iopts[1]} ) + shift iopts + done + + # ... and add "same" options + + while (($#sopts)) ; do + opts=( $opts ${opts/$sopts[1]/$sopts[2]} ) + shift 2 sopts + done # The interpretation of the options is completely table driven. We # use the positional parameters we were given and a few standard @@ -173,7 +212,7 @@ if [[ "$tmp" != $_lo_cache_cmd ]]; then # Now filter out any option strings we don't like and stuff them # in an array, if there are still some. - tmp=("${(@)${(@)tmp%%\=*}//[^a-z0-9-]}") + tmp=("${(@)${(@)tmp%%\=*}//[^a-zA-Z0-9-]}") if (( $#tmp )); then _lo_cache_names[anum]="$name" _lo_cache_actions[anum]="$action" @@ -200,20 +239,6 @@ if [[ "$str" = *\=* ]]; then osuf="$SUFFIX" pre="${str%%\=*}" - IPREFIX="${IPREFIX}${pre}=" - PREFIX="${str#*\=}" - SUFFIX="" - - # We will check if the arrays contain an option matching what's on - # the line. To do this good, we build a pattern. - - [[ -n "$_comp_correct" && $#pre -le _comp_correct ]] && return 1 - - pat="${pre}*" - patflags='' - _match_pattern _long_options pat patflags - - [[ -n "$_comp_correct" ]] && patflags="$patflags(#a$_comp_correct)" # Then we walk through the array names. For each array we test if it # contains the option string. If so, we `invoke' the action stored @@ -223,6 +248,9 @@ if [[ "$str" = *\=* ]]; then for name in "$_lo_cache_names[@]"; do action="$_lo_cache_actions[anum]" if (( ${(@)${(@P)name}[(I)$pre]} )); then + IPREFIX="${oipre}${pre}=" + PREFIX="${str#*\=}" + SUFFIX="" if [[ "$action[1]" = (\[|\() ]]; then compadd - ${=action[2,-2]} elif (( $#action )); then @@ -240,7 +268,10 @@ if [[ "$str" = *\=* ]]; then # element from `_lo_actions' in `parta'. If we find more than one # such option or if we already had one, we set `parto' to `-'. - tmp=("${(@M)${(@P)name}:#${~pat}}") + PREFIX="${str%%\=*}" + SUFFIX="" + compadd -O tmp -M 'r:|-=* r:|=*' - "${(@P)name}" + if [[ $#tmp -eq 1 ]]; then if [[ -z "$parto" ]]; then parto="$tmp[1]" @@ -258,8 +289,9 @@ if [[ "$str" = *\=* ]]; then # try to complete the string after the `='. if [[ -n "$parto" && "$parto" != - ]]; then - IPREFIX="${parto}=" - + IPREFIX="${oipre}${parto}=" + PREFIX="${str#*\=}" + SUFFIX="" if (( $#parta )); then if [[ "$parta[1]" = (\[|\() ]]; then compadd - ${=parta[2,-2]} @@ -281,7 +313,7 @@ fi # The string on the line did not contain a `=', or we couldn't # complete the option string since there were more than one matching -# what's on the line. So we just ad the option string as possible +# what's on the line. So we just add the option strings as possible # matches, giving the string from the `=' on as a suffix. if [[ "$str" = *\=* ]]; then diff --git a/Completion/Base/_math b/Completion/Base/_math index f7f4c360f..90a2c5f7b 100644 --- a/Completion/Base/_math +++ b/Completion/Base/_math @@ -1,4 +1,4 @@ -#defcomp -math- +#compdef -math- if [[ "$PREFIX" = *[^a-zA-Z0-9_]* ]]; then IPREFIX="$IPREFIX${PREFIX%%[a-zA-Z0-9_]#}" @@ -10,7 +10,7 @@ if [[ "$SUFFIX" = *[^a-zA-Z0-9_]* ]]; then fi compgen -v -#defcomp -math- +#compdef -math- IPREFIX="$IPREFIX${PREFIX%[a-zA-Z0-9_]*}" PREFIX="${PREFIX##*[^a-zA-Z0-9_]}" diff --git a/Completion/Base/_parameter b/Completion/Base/_parameter index 2bd66ec93..7200ae440 100644 --- a/Completion/Base/_parameter +++ b/Completion/Base/_parameter @@ -1,3 +1,3 @@ -#defcomp -parameter- +#compdef -parameter- compgen -v diff --git a/Completion/Base/_precommand b/Completion/Base/_precommand index c13cd7465..bcda9fc8b 100644 --- a/Completion/Base/_precommand +++ b/Completion/Base/_precommand @@ -1,4 +1,4 @@ -#defcomp - nohup nice eval time rusage noglob nocorrect exec +#compdef - nohup nice eval time rusage noglob nocorrect exec shift words (( CURRENT-- )) diff --git a/Completion/Base/_redirect b/Completion/Base/_redirect index 32113ad7c..6e02636da 100644 --- a/Completion/Base/_redirect +++ b/Completion/Base/_redirect @@ -1,3 +1,3 @@ -#defcomp -redirect- +#compdef -redirect- _files diff --git a/Completion/Base/_subscript b/Completion/Base/_subscript index e783d04e7..abaabec8c 100644 --- a/Completion/Base/_subscript +++ b/Completion/Base/_subscript @@ -1,4 +1,4 @@ -#defcomp -subscript- +#compdef -subscript- if [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then compgen -S ']' -k "( ${(kP)${compstate[parameter]}} )" diff --git a/Completion/Base/_tilde b/Completion/Base/_tilde index c5ebb66d5..c24c65701 100644 --- a/Completion/Base/_tilde +++ b/Completion/Base/_tilde @@ -1,4 +1,4 @@ -#defcomp -tilde- +#compdef -tilde- # We use all named directories and user names here. If this is too slow # for you or if there are too many of them, you may want to use diff --git a/Completion/Base/_vars b/Completion/Base/_vars index 497a9316f..f06562694 100644 --- a/Completion/Base/_vars +++ b/Completion/Base/_vars @@ -1,3 +1,3 @@ -#defcomp getopts read unset vared +#compdef getopts read unset vared compgen -v -- cgit 1.4.1