From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6705 invoked from network); 24 Apr 2001 16:52:33 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 24 Apr 2001 16:52:33 -0000 Received: (qmail 8337 invoked by alias); 24 Apr 2001 16:52:25 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14083 Received: (qmail 8251 invoked from network); 24 Apr 2001 16:52:23 -0000 From: "Bart Schaefer" Message-Id: <1010424165026.ZM5732@candle.brasslantern.com> Date: Tue, 24 Apr 2001 16:50:25 +0000 In-Reply-To: Comments: In reply to Wayne Davison "Another keep-prefix problem" (Apr 23, 5:46pm) References: X-Mailer: Z-Mail (5.0.0 30July97) To: Wayne Davison , Zsh Workers Subject: Re: Another keep-prefix problem MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 23, 5:46pm, Wayne Davison wrote: } Subject: Another keep-prefix problem } } I noticed one other problem with the current zsh (in CVS) and how it } handles keeping the prefix. After Bart's last set of tweaks, this } works: } } % ls $var1/foo/$var2/bar } } But leaving off the leading variable results in a useless expansion: } } % ls /full/path/foo/$var/bar } } When the filename only has an embedded variable, it is expanded. I suspect this is because of the `suffix' style: suffix This is used by the _expand completer if the word starts with a tilde or parameter expansion. If it is set to `true', the word will only be expanded if it doesn't have a suffix, i.e. if it is something like `~foo' or `$foo', but not if it is `~foo/' or `$foo/bar', unless that suffix itself contains characters eligible ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ for expansion. The default for this style is `true'. In your example, $var2 is in the suffix and eligible for expansion, so expansion is tried, and keep-prefix only preserves the leading $var1 in that case. } Here's a (completely usless) failure case: } } zsh -f } % autoload -U compinit } % compinit } % zstyle ':completion:*' completer _expand _complete } % zstyle ':completion:*:expand:*' keep-prefix true } % bindkey '\t' complete-word } % www=/var/www/html } % mkdir $www/subdir } % echo ~ } /home/wayne } % ls -l ~/../..$www/sub } } ... properly expands to 'subdir' ... You don't mean "expands", you mean "completes", right? } % ls -l /home/wayne/../..$www/sub } } ... does not. Exactly how does it not work? For me, it expands (not completes) to `/home/wayne/../../var/www/html/sub' and completion can continue from there. keep-prefix only applies to words that begin with `~' or `$', not to words that have a `$' anywhere in the prefix; the `suffix' style is for the words with a `$' somewhere else (which is a slight misnomer, as it means the file-path-suffix of the completion-prefix, and not the completion-suffix (which is the stuff to the right of the cursor)). Maybe you want to look at the `subst-globs-only' and/or `substitute' styles, if you haven't already done so. -- 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