From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10130 invoked from network); 13 Apr 2001 04:50:52 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 13 Apr 2001 04:50:52 -0000 Received: (qmail 29443 invoked by alias); 13 Apr 2001 04:50:52 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13973 Received: (qmail 29432 invoked from network); 13 Apr 2001 04:50:51 -0000 From: "Bart Schaefer" Message-Id: <1010413045004.ZM1107@candle.brasslantern.com> Date: Fri, 13 Apr 2001 04:50:04 +0000 In-Reply-To: Comments: In reply to Wayne Davison ""keep-prefix true" feature request" (Apr 12, 7:30pm) References: X-Mailer: Z-Mail (5.0.0 30July97) To: Zsh Workers Subject: Re: "keep-prefix true" feature request MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 12, 7:30pm, Wayne Davison wrote: } Subject: "keep-prefix true" feature request } } % cd ~xpkg/apache$htd/ } } Now it's just beeping at me unless I change the '~' into a '$'. This comes from the test at line 193 of _path_files. If there's a leading tilde, it expands the tilde-expression but never expands the stuff to the right of the first slash. If there's no leading tilde, the branch at line 244 is taken and everything gets expanded. (This is also why your "automatic hash -d" doesn't work: it expands the tilde-expression by checking whether there is already a dirstack entry, not by actually evaluating the expression.) It *seems* to work just to swap those two branches (test for $ first, then leading tilde), and in fact that *also* seems to handle this: } I'd like the "keep-prefix true" setting to work a little differently. } It keeps a variable from expanding only if it is the first item in the } filename, and I'd like it to avoid expanding any variable that has } text after it (like the old completion system does). I'm sure somebody can explain to me why the following is wrong. Index: Completion/Unix/Type/_path_files =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v retrieving revision 1.1 diff -u -r1.1 _path_files --- Completion/Unix/Type/_path_files 2001/04/02 11:36:27 1.1 +++ Completion/Unix/Type/_path_files 2001/04/13 04:44:16 @@ -190,7 +190,23 @@ # Now let's have a closer look at the string to complete. -if [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then +if [[ "$pre" = *\$*/* && "$compstate[quote]" != \" ]]; then + + # If there is a parameter expansion in the word from the line, we try + # to complete the beast by expanding the prefix and completing anything + # after the first slash after the parameter expansion. + # This fails for things like `f/$foo/b/' where the first `f' is + # meant as a partial path. + + linepath="${(M)pre##*\$[^/]##/}" + eval 'realpath=${(e)~linepath}' 2>/dev/null + [[ -z "$realpath" || "$realpath" = "$linepath" ]] && return 1 + pre="${pre#${linepath}}" + i="${#linepath//[^\\/]}" + orig="${orig[1,(in:i:)/][1,-2]}" + donepath= + prepaths=( '' ) +elif [[ "$pre[1]" = \~ && -z "$compstate[quote]" ]]; then # It begins with `~', so remember anything before the first slash to be able # to report it to the completion code. Also get an expanded version of it # (in `realpath'), so that we can generate the matches. Then remove that @@ -239,22 +255,6 @@ [[ "$realpath" = "$linepath" ]] && return 1 pre="${pre#*/}" orig="${orig#*/}" - donepath= - prepaths=( '' ) -elif [[ "$pre" = *\$*/* && "$compstate[quote]" != \" ]]; then - - # If there is a parameter expansion in the word from the line, we try - # to complete the beast by expanding the prefix and completing anything - # after the first slash after the parameter expansion. - # This fails for things like `f/$foo/b/' where the first `f' is - # meant as a partial path. - - linepath="${(M)pre##*\$[^/]##/}" - eval 'realpath=${(e)~linepath}' 2>/dev/null - [[ -z "$realpath" || "$realpath" = "$linepath" ]] && return 1 - pre="${pre#${linepath}}" - i="${#linepath//[^\\/]}" - orig="${orig[1,(in:i:)/][1,-2]}" donepath= prepaths=( '' ) else -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net