From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6629 invoked from network); 28 Jan 2000 10:05:51 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 28 Jan 2000 10:05:51 -0000 Received: (qmail 29287 invoked by alias); 28 Jan 2000 10:05:46 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9454 Received: (qmail 29276 invoked from network); 28 Jan 2000 10:05:45 -0000 Date: Fri, 28 Jan 2000 11:05:44 +0100 (MET) Message-Id: <200001281005.LAA20292@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Andrej Borsenkow"'s message of Thu, 27 Jan 2000 19:31:40 +0300 Subject: Re: match again Andrej Borsenkow wrote: > This does not work: > > bor@itsrm2% patch -p0 --dry-run < /u/p/u/z/p/*/9441 > > with settings > > bor@itsrm2% compstyle -L > compstyle ':correct:' prompt 'correct to:' > ... [ Time to use zstyle instead of compstyle (but maybe you just used it for output?). ] > > But this one does > > bor@itsrm2% patch -p0 --dry-run < > /u2/pub/unix/zsh/patches/3.1.6-dev-16/<9440-> > bor@itsrm2% patch -p0 --dry-run < /u2/pub/unix/zsh/patches/3.1.6-dev-16/9441 > 9441 9442 I've already explained this at least twice. The problem is that the completion code gets a PREFIX of the form f/*/b with `compadd -p foo/baz/ - bar'. It tries to match `foo/baz/' with `f/*' which doesn't work, because we can only either match the whole thing with pattern matching (messing up braces and things) or do what we do now, i.e. try to match the prefix (and suffix) normally and use pattern matching for the strings (like `bar' in the example). But we can try to make _path_files a bit cleverer... the patch below makes it stop its ambiguous-part searching loop if it arrives at a part with a pattern. It then changes the way the cursor style is tested to hopefully give more sensible behaviour. Andrej, is this, finally, acceptable for you? Bye Sven diff -ru ../z.old/Completion/Core/_path_files Completion/Core/_path_files --- ../z.old/Completion/Core/_path_files Fri Jan 28 10:23:55 2000 +++ Completion/Core/_path_files Fri Jan 28 10:58:33 2000 @@ -172,7 +172,7 @@ eorig="$orig" [[ $compstate[insert] = (*menu|[0-9]*) || -n "$_comp_correct" || - ( $#compstate[pattern_match] -ne 0 && + ( -n "$compstate[pattern_match]" && "${orig#\~}" != "${${orig#\~}:q}" ) ]] && menu=yes # If given no `-F' option, we may want to use $fignore, turned into patterns. @@ -442,7 +442,17 @@ tmp4=( "${(@)tmp1:#${tmp1[1]}}" ) fi - if (( $#tmp4 )); then + if [[ "$tpre" = */* ]]; then + PREFIX="${donepath}${linepath}${cpre}${tpre%%/*}" + SUFFIX="/${tsuf#*/}" + else + PREFIX="${donepath}${linepath}${cpre}${tpre}" + SUFFIX="${tsuf}" + fi + + if (( $#tmp4 )) || + [[ -n "$compstate[pattern_match]" && + "$PREFIX$SUFFIX" != "${(q)PREFIX}${(q)SUFFIX}" ]]; then # It is. For menucompletion we now add the possible completions # for this component with the unambigous prefix we have built @@ -451,29 +461,21 @@ # collected as the suffixes to make the completion code expand # it as far as possible. - if [[ "$tpre" = */* ]]; then - PREFIX="${donepath}${linepath}${cpre}${tpre%%/*}" - SUFFIX="/${tsuf#*/}" - else - PREFIX="${donepath}${linepath}${cpre}${tpre}" - SUFFIX="${tsuf}" - fi - - tmp4="$testpath" - compquote tmp1 tmp4 + tmp2="$testpath" + compquote tmp1 tmp2 if [[ -n $menu ]] || ! zstyle -t ":completion${curcontext}:paths" expand suffix; then - zstyle -t ":completion${curcontext}:paths" cursor && + (( $#tmp4 )) && zstyle -t ":completion${curcontext}:paths" cursor && compstate[to_end]='' if [[ "$tmp3" = */* ]]; then - compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -s "/${tmp3#*/}" \ + compadd -Qf "$mopts[@]" -p "$linepath$tmp2" -s "/${tmp3#*/}" \ -W "$prepath$realpath$testpath" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \ -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" \ - "${(@)tmp1%%/*}" else - compadd -Qf "$mopts[@]" -p "$linepath$tmp4" \ + compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \ -W "$prepath$realpath$testpath" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \ -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" \ @@ -481,7 +483,7 @@ fi else if [[ "$tmp3" = */* ]]; then - atmp=( -Qf "$mopts[@]" -p "$linepath$tmp4" + atmp=( -Qf "$mopts[@]" -p "$linepath$tmp2" -W "$prepath$realpath$testpath" "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" ) @@ -489,7 +491,7 @@ compadd "$atmp[@]" -s "/${i#*/}" - "${i%%/*}" done else - compadd -Qf "$mopts[@]" -p "$linepath$tmp4" \ + compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \ -W "$prepath$realpath$testpath" \ "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \ -M "r:|/=* r:|=* $mspec" "$group[@]" "$expl[@]" \ -- Sven Wischnowsky wischnow@informatik.hu-berlin.de