From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15824 invoked from network); 1 Dec 1998 13:00:36 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 1 Dec 1998 13:00:36 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id HAA10031; Tue, 1 Dec 1998 07:54:23 -0500 (EST) Resent-Date: Tue, 1 Dec 1998 07:54:23 -0500 (EST) Date: Tue, 1 Dec 1998 13:52:30 +0100 (MET) Message-Id: <199812011252.NAA10850@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@math.gatech.edu In-reply-to: "Bart Schaefer"'s message of Tue, 1 Dec 1998 04:11:39 -0800 Subject: Re: cdablevars and cd completion in 3.1.5 Resent-Message-ID: <"uRj0O3.0.dS2.-R-Os"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4692 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Bart Schaefer wrote: > > ... > > compctl -x 'S[/][~][./][../]' -/ \ > - 'n[-1,/], s[]' -K cdmatch -S '/' -q \ > -- cd pushd > > ... > > Now the obligatory bit of zsh arcana that still confuses me: > > zsh% echo ~/zshfun > /home/schaefer/zshfun > zsh% cd HE > ^ > With cursor here, this calls cdmatch and completes HOME/. > But if instead I have > zsh% cd HE/zshfun > ^ > With the cursor here, pressing tab does NOT call cdmatch! > Why not? I have completeinword set. The word under the > cursor contains a /, so it should match n[-1,/]. I expected > it to call cdmatch with 1=H 2=E/zshfun and to be able to > read HE/zshfun into $pref. If Instead I have > zsh% cd HOME/zn > ^ > with the cursor here, I can complete to HOME/zshfun. > > I have the feeling this is something I once knew, but maybe it needs to > be written down somewhere. The reason was that the `n[-1,/]' makes the part before the `/' be ignored so that the cursor isn't in a part that is considered for completion. Interestingly I first parsed your compctl wrongly and that led me to a nice little workaround for this: compctl -x 'S[/][~][./][../]' -/ \ - 'n[-1,/] s[], s[]' -K cdmatch -S '/' -q \ -- cd pushd The interesting bit is the `s[]' before the comma. It makes the completion code use the prefix specified by `s[]' be ignored instead of the prefix specified by `n[-1,/]'. So with this the function will be called and we only have to change it accordingly, i.e.: reply=( ${${${(M)$(set):#${pref:-[A-Za-z]}*${2:h}*\=/*}:#*(PWD|:)*}%\=/*}${(M)2%%/*} ) (adding the last `${(M)...}'). Btw. I would use this compctl instead: compctl -/ -K cdmatch -S/ -q -x 'S[/][~][./][../]' -/ -- cd pushd Bye Sven P.S.: Yes, we probably should document the above, but I'm terribly busy the next few days... -- Sven Wischnowsky wischnow@informatik.hu-berlin.de