From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16660 invoked from network); 7 Aug 2004 15:02:00 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 7 Aug 2004 15:02:00 -0000 Received: (qmail 38273 invoked from network); 7 Aug 2004 15:01:54 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 7 Aug 2004 15:01:54 -0000 Received: (qmail 4828 invoked by alias); 7 Aug 2004 15:01:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20236 Received: (qmail 4818 invoked from network); 7 Aug 2004 15:01:44 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by 130.225.247.90 with SMTP; 7 Aug 2004 15:01:44 -0000 Received: (qmail 36956 invoked from network); 7 Aug 2004 14:59:46 -0000 Received: from mail36.messagelabs.com (193.109.254.211) by a.mx.sunsite.dk with SMTP; 7 Aug 2004 14:59:45 -0000 X-VirusChecked: Checked X-Env-Sender: okiddle@yahoo.co.uk X-Msg-Ref: server-3.tower-36.messagelabs.com!1091890784!8291417 X-StarScan-Version: 5.2.10; banners=-,-,- X-Originating-IP: [158.234.9.163] Received: (qmail 2125 invoked from network); 7 Aug 2004 14:59:44 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-3.tower-36.messagelabs.com with SMTP; 7 Aug 2004 14:59:44 -0000 Received: from trentino.logica.co.uk ([158.234.142.61]) by iris.logica.co.uk (8.12.3/8.12.3/Debian -4) with ESMTP id i77Exhf6006355 for ; Sat, 7 Aug 2004 15:59:43 +0100 Received: from trentino.logica.co.uk (localhost [127.0.0.1]) by trentino.logica.co.uk (Postfix) with ESMTP id A55F2791B004 for ; Sat, 7 Aug 2004 16:58:59 +0200 (CEST) X-VirusChecked: Checked X-StarScan-Version: 5.1.13; banners=.,-,- From: Oliver Kiddle To: Zsh workers Subject: PATCH: modifiers with _expand and keep-prefix Date: Sat, 07 Aug 2004 16:58:59 +0200 Message-ID: <10540.1091890739@trentino.logica.co.uk> X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.0 required=6.0 tests=BAYES_44 autolearn=no version=2.63 X-Spam-Hits: -0.0 With the keep-prefix style set, if a modifier in an expansion has the effect of removing or changing the prefix, _expand adds it back. For example: % echo ~/.z*(:t) expands to: % echo ~.zcompdump ~.zfunc ~.zshenv ... Fix is below. I check whether ${exp[1]} starts with $pre. Before allowing the code which does exp=( ${opre}${^exp#${pre}} ). Makes sense to check that the old prefix can be removed before adding the old. Strictly speaking the test should be something like: [[ -z $exp[(r)$pre*] ]] but we already have a test which assumes that what is right for ${exp[1]} is right for the rest of the array. Oliver Index: Completion/Base/Completer/_expand =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_expand,v retrieving revision 1.8 diff -u -r1.8 _expand --- Completion/Base/Completer/_expand 7 Jul 2003 09:48:46 -0000 1.8 +++ Completion/Base/Completer/_expand 7 Aug 2004 14:40:36 -0000 @@ -133,8 +133,9 @@ if [[ -n "$epre" && $#epre -eq 1 ]]; then pre="${(q)epre[1]}" - [[ "$tmp" != changed || $#exp -gt 1 || - "${opre}${exp[1]#${pre}}" != "$word" ]] && exp=( ${opre}${^exp#${pre}} ) + [[ ( "$tmp" != changed || $#exp -gt 1 || + "${opre}${exp[1]#${pre}}" != "$word" ) && "${exp[1]}" = $pre* ]] && + exp=( ${opre}${^exp#${pre}} ) fi [[ $#exp -eq 1 && "$exp[1]" = "$word" ]] && return 1 fi