From d139ae56432a82a3dbe11f4be89ba7d886f2c177 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Wed, 22 Sep 1999 12:35:20 +0000 Subject: zsh-3.1.6-pws-5 --- Completion/Core/_multi_parts | 62 ++++++++++++++++++++++++++++++-------------- Completion/Core/_path_files | 35 ++++++++++++++++++------- Completion/Core/_sep_parts | 6 ++++- 3 files changed, 73 insertions(+), 30 deletions(-) (limited to 'Completion/Core') diff --git a/Completion/Core/_multi_parts b/Completion/Core/_multi_parts index d51130391..30a68d312 100644 --- a/Completion/Core/_multi_parts +++ b/Completion/Core/_multi_parts @@ -7,7 +7,7 @@ # The parts of words from the array that are separated by the # separator character are then completed independently. -local sep matches pref npref i tmp1 group expl menu pre suf +local sep matches pref npref i tmp1 group expl menu pre suf opre osuf cpre typeset -U tmp2 # Get the options. @@ -40,6 +40,8 @@ fi pre="$PREFIX" suf="$SUFFIX" +opre="$PREFIX" +osuf="$SUFFIX" orig="$PREFIX$SUFFIX" # Special handling for menucompletion? @@ -100,14 +102,17 @@ while true; do matches=( "${(@M)matches:#${tmp1[1]}*}" ) tmp2=( "${(@M)matches:#${tmp1[1]}${sep}*}" ) + PREFIX="${cpre}${pre}" + SUFFIX="$suf" + if (( $#tmp2 )); then - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -p "$pref" -qS "$sep" - "$tmp1[1]" + compadd "$group[@]" "$expl[@]" -p "$pref" -qS "$sep" \ + -M "r:|${sep}=* r:|=*" - "$tmp1[1]" else - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -p "$pref" - "$tmp1[1]" + compadd "$group[@]" "$expl[@]" -p "$pref" \ + -M "r:|${sep}=* r:|=*" - "$tmp1[1]" fi - return 1 + return 0 fi elif (( $#tmp1 )); then @@ -118,6 +123,14 @@ while true; do SUFFIX="$suf" compadd -O matches -M "r:|${sep}=* r:|=*" - "$matches[@]" + if [[ "$pre" = *${sep}* ]]; then + PREFIX="${cpre}${pre%%${sep}*}" + SUFFIX="${sep}${pre#*${sep}}${suf}" + else + PREFIX="${cpre}${pre}" + SUFFIX="$suf" + fi + if [[ -n "$menu" ]]; then # With menucompletion we just add matches for the matching # components with the prefix we collected and the rest from the @@ -125,11 +138,12 @@ while true; do tmp2="$pre$suf" if [[ "$tmp2" = *${sep}* ]]; then - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -p "$pref" -s "${sep}${tmp2#*${sep}}" - "$tmp1[@]" + compadd "$group[@]" "$expl[@]" \ + -p "$pref" -s "${sep}${tmp2#*${sep}}" \ + -M "r:|${sep}=* r:|=*" - "$tmp1[@]" else - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -p "$pref" - "$tmp1[@]" + compadd "$group[@]" "$expl[@]" -p "$pref"\ + -M "r:|${sep}=* r:|=*" - "$tmp1[@]" fi else # With normal completion we add all matches one-by-one with @@ -138,11 +152,12 @@ while true; do for i in "${(@M)matches:#(${(j:|:)~tmp1})*}"; do if [[ "$i" = *${sep}* ]]; then - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -S '' -p "$pref" -s "${i#*${sep}}" - "${i%%${sep}*}${sep}" + compadd "$group[@]" "$expl[@]" -S '' \ + -p "$pref" -s "${i#*${sep}}" \ + -M "r:|${sep}=* r:|=*" - "${i%%${sep}*}${sep}" else - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -S '' -p "$pref" - "$i" + compadd "$group[@]" "$expl[@]" -S '' -p "$pref" \ + -M "r:|${sep}=* r:|=*" - "$i" fi done fi @@ -154,12 +169,15 @@ while true; do [[ "$orig" = "$pref$pre$suf" ]] && return 1 + PREFIX="${cpre}${pre}" + SUFFIX="$suf" + if [[ -n "$suf" ]]; then - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -s "$suf" - "$pref$pre" + compadd "$group[@]" "$expl[@]" -s "$suf" \ + -M "r:|${sep}=* r:|=*" - "$pref$pre" else - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -S '' - "$pref$pre$suf" + compadd "$group[@]" "$expl[@]" -S '' \ + -M "r:|${sep}=* r:|=*" - "$pref$pre" fi return 0 fi @@ -175,8 +193,10 @@ while true; do # Now we set `pre' and `suf' to their new values. if [[ "$pre" = *${sep}* ]]; then + cpre="${cpre}${pre%%${sep}*}${sep}" pre="${pre#*${sep}}" elif [[ "$suf" = *${sep}* ]]; then + cpre="${cpre}${pre}${suf%%${sep}*}${sep}" pre="${suf#*${sep}}" suf="" else @@ -184,9 +204,11 @@ while true; do # unambiguous prefix and that differs from the original string, # we insert it. + PREFIX="${opre}${osuf}" + SUFFIX="" + [[ -n "$pref" && "$orig" != "$pref" ]] && - compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ - -S '' - "$pref" + compadd "$group[@]" "$expl[@]" -S '' -M "r:|${sep}=* r:|=*" - "$pref" return fi diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files index b017d78e5..b4b6fff97 100644 --- a/Completion/Core/_path_files +++ b/Completion/Core/_path_files @@ -24,7 +24,7 @@ # menucompletion. local linepath realpath donepath prepath testpath exppath -local tmp1 tmp2 tmp3 tmp4 i orig pre suf tpre tsuf +local tmp1 tmp2 tmp3 tmp4 i orig pre suf tpre tsuf opre osuf cpre local pats haspats=no ignore group expl addpfx addsfx remsfx local nm=$compstate[nmatches] menu @@ -118,6 +118,8 @@ fi pre="$PREFIX" suf="$SUFFIX" +opre="$PREFIX" +osuf="$SUFFIX" orig="${PREFIX}${SUFFIX}" [[ $compstate[insert] = (*menu|[0-9]*) || -n "$_comp_correct" || @@ -291,6 +293,8 @@ for prepath in "$prepaths[@]"; do if [[ "$haspats" = no && -z "$tpre$tsuf" && "$pre" = */ && -z "$suf" ]]; then + PREFIX="${opre}${osuf}" + SUFFIX="" compadd -nQS '' - "$linepath$donepath$orig" tmp4=- fi @@ -349,19 +353,27 @@ for prepath in "$prepaths[@]"; do # collected as the suffixes to make the completion code expand # it as far as possible. + if [[ "$tmp3" = */* ]]; then + PREFIX="${linepath}${cpre}${tmp3%%/*}" + SUFFIX="/${tmp3#*/}" + else + PREFIX="${linepath}${cpre}${tmp3}" + SUFFIX="" + fi + if [[ -n $menu ]]; then [[ -n "$compconfig[path_cursor]" ]] && compstate[to_end]='' if [[ "$tmp3" = */* ]]; then compadd -QUf -p "$linepath${testpath:q}" -s "/${tmp3#*/}" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" -M 'r:|/=* r:|=*' \ - "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ ++ "$group[@]" "$expl[@]" \ - "${(@)${(@)tmp1%%/*}:q}" else compadd -QUf -p "$linepath${testpath:q}" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \ - "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ + "$group[@]" "$expl[@]" \ - "${(@)tmp1:q}" fi else @@ -370,14 +382,14 @@ for prepath in "$prepaths[@]"; do compadd -QUf -p "$linepath${testpath:q}" -s "/${${i#*/}:q}" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" -M 'r:|/=* r:|=*' \ - "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ + "$group[@]" "$expl[@]" \ - "${${i%%/*}:q}" done else compadd -QUf -p "$linepath${testpath:q}" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \ - "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ + "$group[@]" "$expl[@]" \ - "${(@)tmp1:q}" fi fi @@ -399,14 +411,17 @@ for prepath in "$prepaths[@]"; do testpath="${testpath}${tmp1[1]%%/*}/" tmp1=( "${(@)tmp1#*/}" ) + cpre="${cpre}${tmp3%%/*}/" tmp3="${tmp3#*/}" done - if [[ -z "$tmp4" ]]; then - compadd -QUf -p "$linepath${testpath:q}" \ + if [[ -z "$tmp4" ]]; then + PREFIX="${opre}${osuf}" + SUFFIX="" + compadd -QUf -p "$linepath${testpath:q}" \ -W "$prepath$realpath$testpath" "$ignore[@]" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \ - "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ + "$group[@]" "$expl[@]" \ - "${(@)tmp1:q}" fi done @@ -419,7 +434,9 @@ exppaths=( "${(@)exppaths:#$orig}" ) if [[ -n "$compconfig[path_expand]" && $#exppaths -gt 0 && nm -eq compstate[nmatches] ]]; then - compadd -QU -S '' "$group[@]" "$expl[@]" -i "$IPREFIX" -I "$ISUFFIX" \ + PREFIX="${opre}${osuf}" + SUFFIX="" + compadd -Q -S '' "$group[@]" "$expl[@]" \ -M 'r:|/=* r:|=*' -p "$linepath" - "$exppaths[@]" fi diff --git a/Completion/Core/_sep_parts b/Completion/Core/_sep_parts index 6f2595120..0a8cae28f 100644 --- a/Completion/Core/_sep_parts +++ b/Completion/Core/_sep_parts @@ -18,7 +18,7 @@ # `-X explanation' options. local str arr sep test testarr tmparr prefix suffixes matchers autosuffix -local matchflags opt group expl nm=$compstate[nmatches] +local matchflags opt group expl nm=$compstate[nmatches] opre osuf # Get the options. @@ -34,6 +34,8 @@ shift OPTIND-1 # Get the string from the line. +opre="$PREFIX" +osuf="$SUFFIX" str="$PREFIX$SUFFIX" SUFFIX="" prefix="" @@ -144,6 +146,8 @@ done # Add the matches for each of the suffixes. +PREFIX="$pre" +SUFFIX="$suf" for i in "$suffixes[@]"; do compadd -U "$group[@]" "$expl[@]" "$matchers[@]" "$autosuffix[@]" \ -i "$IPREFIX" -I "$ISUFFIX" -p "$prefix" -s "$i" - "$testarr[@]" -- cgit 1.4.1