diff options
Diffstat (limited to 'Completion/Base/Utility')
-rw-r--r-- | Completion/Base/Utility/_arguments | 22 | ||||
-rw-r--r-- | Completion/Base/Utility/_call_program | 16 | ||||
-rw-r--r-- | Completion/Base/Utility/_values | 7 |
3 files changed, 31 insertions, 14 deletions
diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments index 687c0c4ed..d2c0d33de 100644 --- a/Completion/Base/Utility/_arguments +++ b/Completion/Base/Utility/_arguments @@ -105,7 +105,10 @@ if (( long )); then continue else # Still no comment, add the previous options anyway. - lopts+=("${tmp[@]}") + # Add a ':' after the option anyways, to make the matching of + # the options lateron work as intended. + # It will be removed again later. + lopts+=("${^tmp[@]}":) tmp=() fi fi @@ -147,7 +150,7 @@ if (( long )); then done # Tidy up any remaining uncommented options. if (( ${#tmp} )); then - lopts+=("${tmp[@]}") + lopts+=("${^tmp[@]}":) fi # Remove options also described by user-defined specs. @@ -220,19 +223,22 @@ if (( long )); then # Ignore :descriptions at the ends of lopts for matching this; # they aren't in the patterns. - tmp=("${(@M)lopts:##$~pattern(|:*)}") - lopts=("${(@)lopts:##$~pattern(|:*)}") + tmp=("${(@M)lopts:##$~pattern:*}") + lopts=("${(@)lopts:##$~pattern:*}") (( $#tmp )) || continue opt='' + # Clean suffix ':' added earlier + tmp=("${(@)tmp%:}") + # If there are option strings with a `[=', we take these to get an # optional argument. - tmpo=("${(@M)tmp:#*\[\=*}") + tmpo=("${(@M)tmp:#[^:]##\[\=*}") if (( $#tmpo )); then - tmp=("${(@)tmp:#*\[\=*}") + tmp=("${(@)tmp:#[^:]##\[\=*}") for opt in "$tmpo[@]"; do # Look for --option:description and turn it into @@ -263,9 +269,9 @@ if (( long )); then # Basically the same as the foregoing. # TODO: could they be combined? - tmpo=("${(@M)tmp:#*\=*}") + tmpo=("${(@M)tmp:#[^:]##\=*}") if (( $#tmpo )); then - tmp=("${(@)tmp:#*\=*}") + tmp=("${(@)tmp:#[^:]##\=*}") for opt in "$tmpo[@]"; do if [[ $opt = (#b)(*):([^:]#) ]]; then diff --git a/Completion/Base/Utility/_call_program b/Completion/Base/Utility/_call_program index 010e09476..9a44f2d8e 100644 --- a/Completion/Base/Utility/_call_program +++ b/Completion/Base/Utility/_call_program @@ -1,6 +1,16 @@ #autoload +X -local tmp err_fd=-1 +local curcontext="${curcontext}" tmp err_fd=-1 +local -a prefix + +if [[ "$1" = -p ]]; then + shift + if (( $#_comp_priv_prefix )); then + curcontext="${curcontext%:*}/${${(@M)_comp_priv_prefix:#^*[^\\]=*}[1]}:" + zstyle -t ":completion:${curcontext}:${1}" gain-privileges && + prefix=( $_comp_priv_prefix ) + fi +fi if (( ${debug_fd:--1} > 2 )) || [[ ! -t 2 ]] then exec {err_fd}>&2 # debug_fd is saved stderr, 2 is trace or redirect @@ -13,10 +23,10 @@ if zstyle -s ":completion:${curcontext}:${1}" command tmp; then if [[ "$tmp" = -* ]]; then eval "$tmp[2,-1]" "$argv[2,-1]" else - eval "$tmp" + eval $prefix "$tmp" fi else - eval "$argv[2,-1]" + eval $prefix "$argv[2,-1]" fi 2>&$err_fd } always { diff --git a/Completion/Base/Utility/_values b/Completion/Base/Utility/_values index ab0e46a9c..6e38e00f4 100644 --- a/Completion/Base/Utility/_values +++ b/Completion/Base/Utility/_values @@ -1,13 +1,14 @@ #autoload -local subopts opt usecc garbage +local subopts opt usecc garbage keep subopts=() -zparseopts -D -E -a garbage C=usecc O:=subopts M: J: V: 1 2 n F: X: +zparseopts -D -a garbage s+:=keep S+:=keep w+=keep C=usecc O:=subopts \ + M: J: V: 1 2 n F: X: (( $#subopts )) && subopts=( "${(@P)subopts[2]}" ) -if compvalues -i "$@"; then +if compvalues -i "$keep[@]" "$@"; then local noargs args opts descr action expl sep argsep subc test='*' local oldcontext="$curcontext" |