From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20123 invoked from network); 1 Dec 1998 18:15:31 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 1 Dec 1998 18:15:31 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id NAA19934; Tue, 1 Dec 1998 13:11:44 -0500 (EST) Resent-Date: Tue, 1 Dec 1998 13:11:44 -0500 (EST) From: "Bart Schaefer" Message-Id: <981201100955.ZM5808@candle.brasslantern.com> Date: Tue, 1 Dec 1998 10:09:55 -0800 In-Reply-To: <199812011252.NAA10850@beta.informatik.hu-berlin.de> Comments: In reply to Sven Wischnowsky "Re: cdablevars and cd completion in 3.1.5" (Dec 1, 1:52pm) References: <199812011252.NAA10850@beta.informatik.hu-berlin.de> X-Mailer: Z-Mail (4.0b.820 20aug96) To: Sven Wischnowsky , zsh-workers@math.gatech.edu Subject: Re: cdablevars and cd completion in 3.1.5 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"XIFTw1.0.Pt4.V53Ps"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4696 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Dec 1, 1:52pm, Sven Wischnowsky wrote: } Subject: Re: cdablevars and cd completion in 3.1.5 } } Bart Schaefer wrote: } > ... } > compctl -x 'S[/][~][./][../]' -/ \ } > - 'n[-1,/], s[]' -K cdmatch -S '/' -q \ } > -- cd pushd } > ... } > zsh% cd HE/zshfun } > ^ } > With the cursor here, pressing tab does NOT call cdmatch! } > Why not? } } 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. If the current word can't be completed because of the position of the cursor, then shouldn't the position of the cursor also determine whether the pattern matches the word in the first place? Why would you ever WANT a pattern to match and then NOT call the corresponding completion? } 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,/]'. Hm; I'd have expected them to be cumulative (though possibly overlapping), but I can see where that'd be a mess particularly for something strange like compctl -x 'n[1,/] n[-1,/]' ... However, that doesn't work, because it stops ignoring the stuff up to the last /, so now all the completions cdmatch puts in $reply have to include that prefix when completing anything *after* that slash. I.e. zsh% cd HOME/z feeps because reply=(zshfun) and the code wants reply=(HOME/zshfun). Your alternate compctl has the same problem. It's probably possible to fix my cdmatch to handle that, but it isn't straightforward, as it can't simply use tilde-expansion and then lop off the path tail; instead it has to convert the path head back into the corresponding named dir. I suppose a trick with print -P could be used, but that's another $(). (The other possibility would be to use the -U option and thus expand the variable name into the full path it represents.) } 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)...}'). That can complete to impossible paths because it doesn't check whether the stuff in $2 really is a subdirectory of the named dir in $pref. To check correctly again requires tilde-expanding and then converting back into a named dir. So I think, all things considered, I'd give up completeinword on cdable variables and take my original function and compctl. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com