From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23426 invoked by alias); 3 Aug 2010 13:00:05 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15232 Received: (qmail 778 invoked from network); 3 Aug 2010 13:00:00 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,MISSING_HEADERS, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=no version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Tue, 3 Aug 2010 13:59:51 +0100 From: Peter Stephenson Cc: zsh-users@zsh.org Subject: Re: Zsh autocompletion with no access to a parent directory Message-ID: <20100803135951.4794fc36@csr.com> In-Reply-To: <548B2AA0-8397-4292-A41B-156FDC42B886@sysctl.co.uk> References: <3663DC29-7A8F-4A0C-8262-5FFE701C8E3A@sysctl.co.uk> <20100413174533.5a15043a@news01> <361816B9-75B6-4C88-8BE9-097B33CA2283@sysctl.co.uk> <201004140914.o3E9EPkL009936@news01.csr.com> <201004140947.o3E9llgG010201@news01.csr.com> <20100423224428.7479faa8@pws-pc> <20100429223850.14143862@pws-pc> <04C31B8F-4588-4DA0-93E6-EB175CEFA6F6@sysctl.co.uk> <20100430093251.4fcd8c45@csr.com> <548B2AA0-8397-4292-A41B-156FDC42B886@sysctl.co.uk> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.6 (GTK+ 2.18.9; i686-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 03 Aug 2010 12:59:51.0312 (UTC) FILETIME=[C2A01900:01CB330B] X-Scanned-By: MailControl A_09_40_00 (www.mailcontrol.com) on 10.68.0.120 On Thu, 29 Jul 2010 08:46:47 -0700 Matt Wright wrote: > Apologies for necroing this thread but I've hit a snag with this > stuff and I can't work out whats going on. I threw some debug in > around the code you changed in _path_files but all the paths look > sane. After that it barrels off down compfiles code and my brain > leapt out my left armpit. > > If I do the following, using the _path_files changes you supplied me > long ago: > > # mkdir -p /tmp/foo\~bar/test > # ls /tmp/foo~bar/te > > All I get is: > > [caesium: ~]$ ls /tmp/foo~bar/te > No matches found for: `files' > > If I back up and TAB at the end of "foo~bar", zsh changes my prompt > to: > > [caesium: ~]$ ls /tmp/foo\~bar/ Er, I think you'll find it's all completely, er... anyway, I've run out of armpits. I think the following might be better (patch against the version in the archive). There's still one oddity where /tmp/foo~bar/te completes to /tmp/foo\~bar/test but doesn't get recognised as a directory until you hit tab again. I think that's due to code down later on: probably because it's found that the result doesn't match what was on the command line so refuses to look and see if it's a directory. I can't see where that's happening but I think within compadd or compresult. Index: Completion/Unix/Type/_path_files =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v retrieving revision 1.52 diff -p -u -r1.52 _path_files --- Completion/Unix/Type/_path_files 5 May 2010 09:54:38 -0000 1.52 +++ Completion/Unix/Type/_path_files 3 Aug 2010 12:52:01 -0000 @@ -367,17 +367,24 @@ for prepath in "$prepaths[@]"; do # Explanation of substitution: For tmp1 and tpre, which are used further # on, we need to remove quotes from everything that's not a pattern # character, because the code that does the file generation only - # strips qutoes from pattern characters (you know better than + # strips quotes from pattern characters (you know better than # to ask why). Because we need to test for a real directory, # however, for tmp2 we unquote everything. tmp1=${match[1]} tpre=${match[2]} tmp2=${(Q)tmp1} - tmp1=${tmp1//(#b)\\([^\\\]\[\^\~\(\)\#\*\?])/$match[1]} + tmp1=${tmp1//(#b)\\(?)/$match[1]} tpre=${tpre//(#b)\\([^\\\]\[\^\~\(\)\#\*\?])/$match[1]} + # Theory: donepath needs the quoting of special characters + # still in it. However, we need it without at this point. + # (I think.) Note this is different from the above where we're + # doing something a bit different. + tmp3=${donepath//(#b)\\(?)/$match[1]} while true; do - if [[ -z $path_completion || -d $prepath$realpath$donepath$tmp2 ]]; then - donepath=$donepath$tmp1/ + if [[ -z $path_completion || -d $prepath$realpath$tmp3$tmp2 ]]; then + tmp3=$tmp3$tmp1/ + # Now put donepath back the way it should be. (I think.) + donepath=${tmp3//(#b)([\\\]\[\^\~\(\)\#\*\?])/\\$match[1]} pre=$tpre break elif [[ $tmp1 = (#b)(*)/([^/]#) ]]; then -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom