From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24723 invoked from network); 1 Sep 2008 17:14:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 1 Sep 2008 17:14:57 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 41341 invoked from network); 1 Sep 2008 17:14:48 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 1 Sep 2008 17:14:48 -0000 Received: (qmail 4354 invoked by alias); 1 Sep 2008 17:14:36 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25582 Received: (qmail 4345 invoked from network); 1 Sep 2008 17:14:34 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 1 Sep 2008 17:14:34 -0000 Received: from cluster-g.mailcontrol.com (cluster-g.mailcontrol.com [208.87.233.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 9B418801E2B4 for ; Mon, 1 Sep 2008 19:14:30 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly30g.srv.mailcontrol.com (MailControl) with ESMTP id m81HEQoV020046 for ; Mon, 1 Sep 2008 18:14:27 +0100 Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Mon, 1 Sep 2008 18:14:25 +0100 Date: Mon, 1 Sep 2008 18:14:25 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: "pws non-canonical hack" problems Message-ID: <20080901181425.48494272@news01> In-Reply-To: <080825181954.ZM27367@torch.brasslantern.com> References: <20080823072446.GM8612@altlinux.org> <080823075551.ZM5496@torch.brasslantern.com> <20080825174751.38323d18@pws-pc> <080825181954.ZM27367@torch.brasslantern.com> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 01 Sep 2008 17:14:25.0366 (UTC) FILETIME=[2F190760:01C90C56] X-Scanned-By: MailControl A-08-50-13 (www.mailcontrol.com) on 10.71.0.140 X-Virus-Scanned: ClamAV 0.92.1/8131/Mon Sep 1 15:33:22 2008 on bifrost X-Virus-Status: Clean On Mon, 25 Aug 2008 18:19:54 -0700 Bart Schaefer wrote: > It's pretty difficult for me to test because I don't have a file > system that behaves in this magical way. But the answer, I think, is > to skip the tmp1+= inside the loop and call compfiles again after the > loop is finished. I think this works for the simple case of automounted directories... at least it triggered and generated the right completions after I eventually found all the styles I needed to change to check it (accept-exact-dirs, fake-files, completer). Index: Completion/Unix/Type/_path_files =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v retrieving revision 1.34 diff -u -r1.34 _path_files --- Completion/Unix/Type/_path_files 30 Jul 2008 14:57:29 -0000 1.34 +++ Completion/Unix/Type/_path_files 1 Sep 2008 17:10:25 -0000 @@ -7,7 +7,8 @@ local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre local pats haspats ignore pfx pfxsfx sopt gopt opt sdirs ignpar cfopt listsfx local nm=$compstate[nmatches] menu matcher mopts sort mid accex fake -local listfiles listopts tmpdisp +local listfiles listopts tmpdisp origtmp1 +integer npathcheck local -a match mbegin mend typeset -U prepaths exppaths @@ -351,8 +352,11 @@ tmp1=( "$prepath$realpath$donepath$tmp2" ) + # count of attemps for pws non-canonical hack + (( npathcheck = 0 )) while true; do + origtmp1=("${tmp1[@]}") # Get the prefix and suffix for matching. if [[ "$tpre" = */* ]]; then @@ -403,15 +407,26 @@ # something to match by explicit name. This is for # `clever' filing systems where names pop into existence # when referenced. - if (( ! $#tmp1 )); then - for tmp3 in "$tmp2[@]"; do - if [[ -n $tmp3 && $tmp3 != */ ]]; then - tmp3+=/ - fi - if [[ -e "$tmp3${(Q)PREFIX}${(Q)SUFFIX}" ]] then - tmp1+=("$tmp3${(Q)PREFIX}${(Q)SUFFIX}") - fi - done + # + # As suggested by Bart, to make sure the "compfiles" checks + # still work we repeat the tests above if we successfully + # find something that might need adding, but we make sure + # we only do this once for completion of each path segment. + if (( ! $#tmp1 && npathcheck == 0 )); then + (( npathcheck = 1 )) + for tmp3 in "$tmp2[@]"; do + if [[ -n $tmp3 && $tmp3 != */ ]]; then + tmp3+=/ + fi + if [[ -e "$tmp3${(Q)PREFIX}${(Q)SUFFIX}" ]] then + (( npathcheck = 2 )) + fi + done + if (( npathcheck == 2 )); then + # repeat loop with same arguments + tmp1=("$origtmp1[@]") + continue + fi fi if (( ! $#tmp1 )); then @@ -518,6 +533,7 @@ else skipped=/ fi + (( npathcheck = 0 )) done # The next loop searches the first ambiguous component. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070