diff options
-rw-r--r-- | Completion/Base/_arguments | 37 | ||||
-rw-r--r-- | Completion/Builtins/_vars_eq | 6 | ||||
-rw-r--r-- | Doc/Zsh/compsys.yo | 5 |
3 files changed, 38 insertions, 10 deletions
diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments index 6343bc477..2a2eb1b25 100644 --- a/Completion/Base/_arguments +++ b/Completion/Base/_arguments @@ -7,7 +7,7 @@ setopt localoptions extendedglob local long 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 +local beg optbeg argbeg nargbeg inopt # Associative arrays used to collect information about the options. @@ -82,6 +82,16 @@ while (( $# )); do opts[$tmp]='' fi unset "oneshot[$tmp]" + elif [[ "$1" = \*::* ]]; then + + # This is `*:...', describing `all other arguments', with argument + # range restriction. + + if [[ "$1" = \*:::* ]]; then + rest="*${1[3,-1]}" + else + rest="$1" + fi elif [[ "$1" = \*:* ]]; then # This is `*:...', describing `all other arguments'. @@ -125,8 +135,9 @@ cur=$(( CURRENT-2 )) nth=1 line=( "$words[1]" ) beg=2 -argbeg=2 -optbeg=2 +argbeg=1 +optbeg=1 +nargbeg=1 # ...until the current word is reached. @@ -190,6 +201,7 @@ while [[ cur -gt 0 ]]; do def="$opts[$ws[1]]" optbeg="$beg" argbeg="$beg" + inopt=yes [[ -n "$oneshot[$ws[1]]" ]] && unset "opts[$ws[1]]" else uns='' @@ -199,6 +211,7 @@ while [[ cur -gt 0 ]]; do def="$opts[$tmp]" optbeg="$beg" argbeg="$beg" + inopt=yes uns="${ws[1][2,-1]}" opt='' fi @@ -242,6 +255,7 @@ while [[ cur -gt 0 ]]; do [[ -n "$oneshot[$tmp[1]]" ]] && unset "dopts[$tmp[1]]" if [[ "$def" = [^*]*[^\\]:*[^\\]:* ]]; then def="${def#?*[^\\]:*[^\\]:}" + inopt=yes else def='' fi @@ -279,6 +293,7 @@ while [[ cur -gt 0 ]]; do def="${def#?*[^\\]:*[^\\]:}" optbeg="$beg" argbeg="$beg" + inopt=yes else def='' fi @@ -303,6 +318,8 @@ while [[ cur -gt 0 ]]; do if [[ -n "$opt" && -n "$arg" ]]; then def='' line=( "$line[@]" "$ws[1]" ) + [[ -n "$inopt" ]] && nargbeg=$(( beg - 1 )) + inopt='' (( nth++ )) fi fi @@ -313,6 +330,8 @@ while [[ cur -gt 0 ]]; do (( beg++ )) done +[[ -n "$inopt" ]] && nargbeg="$beg" + # Now generate the matches. if [[ $#long -ne 0 && "$PREFIX" = --* ]]; then @@ -339,12 +358,10 @@ else # If we have none at all, use the one for this argument position. def="$args[nth]" - [[ -z "$def" ]] && def="$rest" - - if [[ "$def" = \** ]]; then - def="${def#*[^\\]:}" - [[ "$def" = :* ]] && def="$def[2,-1]" - [[ "$def" = :* ]] && def="$def[2,-1]" + if [[ -z "$def" ]]; then + def="$rest" + optbeg="$nargbeg" + argbeg="$nargbeg" fi fi @@ -457,6 +474,8 @@ else beg=$optbeg fi + [[ beg -ge $#words ]] && beg=$(( $#words - 1 )) + shift beg words (( CURRENT -= beg )) diff --git a/Completion/Builtins/_vars_eq b/Completion/Builtins/_vars_eq index d2cac8741..b5b120ff4 100644 --- a/Completion/Builtins/_vars_eq +++ b/Completion/Builtins/_vars_eq @@ -1,3 +1,7 @@ #compdef declare export integer local readonly typeset -_parameters -q -S '=' +if compset -P '*='; then + _default +else + _parameters -q -S '=' +fi diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index dbd1823cf..e1cca1337 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -902,6 +902,11 @@ item(tt(*:)var(message)tt(:)var(action))( This describes how arguments are to be completed for which no description with one of the first two forms was given. This also means 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. ) item(var(opt-spec)[var(description) ...])( This describes an option and (if at least one var(description) is |