From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by coral.primenet.com.au (8.7.5/8.7.3) with ESMTP id NAA08102 for ; Fri, 13 Sep 1996 13:05:32 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id WAA25131; Thu, 12 Sep 1996 22:43:20 -0400 (EDT) Resent-Date: Thu, 12 Sep 1996 22:43:20 -0400 (EDT) X400-Received: by mta bnr.ca in /PRMD=BNR/ADMD=TELECOM.CANADA/C=CA/; Relayed; Thu, 12 Sep 1996 22:39:45 -0400 X400-Received: by /PRMD=BNR/ADMD=TELECOM.CANADA/C=CA/; Relayed; Thu, 12 Sep 1996 18:01:17 -0400 X400-Received: by /PRMD=BNR/ADMD=TELECOM.CANADA/C=CA/; Relayed; Thu, 12 Sep 1996 15:38:00 -0400 Date: Thu, 12 Sep 1996 15:38:00 -0400 X400-Originator: /dd.id=1569151/g=alain/i=a/s=caron/@bnr.ca X400-MTS-Identifier: [/PRMD=BNR/ADMD=TELECOM.CANADA/C=CA/;bcars735.b.901:12.08.96.22.01.17] X400-Content-Type: P2-1984 (2) Content-Identifier: re:[zash-3.0.... From: "alain (a.) caron" Sender: "alain (a.) caron" Message-ID: <"9653 Thu Sep 12 18:01:31 1996"@bnr.ca> To: mdb@cdc.noaa.gov Cc: zsh-workers@math.gatech.edu Subject: re:[zash-3.0.0] bug in cdmatch for dirs w/ embedded space? Resent-Message-ID: <"TrDsQ2.0.b86.7fCEo"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2137 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu In message "[zash-3.0.0] bug in cdmatch for dirs w/ embedded space?", 'mdb@cdc.noaa.gov' writes: >I'm trying to get zsh to complete a directory that has an embedded >space, e.g., `foo bar' (personally I don't like them, but with >mac/win95 filenames it seems to be pretty common to come across). > >I used the versions of compctl, cdmatch, and cdmatch2 distributed with >zsh-3.0.0, and invoked zsh with the -f switch. It fails because too >many backslashes get put in the completion, e.g., > > % cd foo >results in > % cd foo\\\ bar/ > >Is there a more up to date cdmatch/compctl for this sort of thing? Or >is there a (non-default) that needs to be set? > >Thanks. > >Here's exactly what I did: > >charney$ ~/bin/sunos-5.5/zsh-3.0.0 -f >charney% echo $ZSH_VERSION >3.0.0 >charney% ls >foo bar >charney% if [[ -o AUTO_REMOVE_SLASH ]] then >then> compctl -x 'p[2]' -Q -K cdmatch2 - 'S[/][~][./][../]' -g '*(-/)' + \ >then> -g '*(-/D)' - 'n[-1,/], s[]' -K cdmatch -q -S '/' -- cd pushd >then> else >else> compctl -x 'p[2]' -Q -K cdmatch2 - 'S[/][~][./][../]' -g '*(-/)' + \ >else> -g '*(-/D)' - 'n[-1,/], s[]' -K cdmatch -S '/' -- cd pushd >else> fi >charney% fpath=(~/.zfunctions) >charney% autoload cdmatch >charney% autoload cdmatch2 >charney% cd foo\\\ bar/ # typed cd foo here >cd: no such file or directory: foo\ bar/ >charney% cd foo\ bar >charney% pwd >/tmp/mdb/foo bar >charney% cat ~/.zfunctions/cdmatch ># Start of cdmatch. ># Save in your functions directory and autoload, then do ># compctl -x 'S[/][~][./][../]' -g '*(-/)' - \ ># 'n[-1,/], s[]' -K cdmatch -S '/' -- cd pushd ># ># Completes directories for cd, pushd, ... anything which knows about cdpath. ># You do not have to include `.' in your cdpath. ># ># It works properly only if $ZSH_VERSION > 2.6-beta2. For erarlier versions ># it still works if RC_EXPAND_PARAM is not set or when cdpath is empty. >local narg pref cdp >read -nc narg >read -Ac pref >cdp=(. $cdpath) >reply=( ${^cdp}/${pref[$narg]%$2}*$2(-/DN^M:t:gs/ /\\\\ /) ) replace this last line by: reply=( ${^cdp}/${pref[$narg]%$2}*$2(-/DN^M:t) ) and everything should work fine. At least, it does for me. >return ># End of cdmatch. >charney% cat ~/.zfunctions/cdmatch2 ># This function should be called from compctl to complete the ># second argument of cd and pushd. >local from >read -Ac from >from="${from[2]}" >eval "reply=( \${PWD:s@$from@$1*$2@}~$PWD(ND-/:) )" >reply=( "${${reply[@]#${PWD%%$from*}}%${PWD#*$from}}" ) >[[ ${#reply[(r),-1]} != 0 ]] && reply[(r)]="''" >return >charney% >charney$ > >-- > -mb- > Regards, Alain Caron Nortel Technology, Montr?al, Qu?bec, Canada email: alainc@nortel.ca phone: 514-765-7718 or ESN 852-7718