From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18807 invoked from network); 7 Jul 2003 09:45:42 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 7 Jul 2003 09:45:42 -0000 Received: (qmail 29023 invoked by alias); 7 Jul 2003 09:45:37 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18822 Received: (qmail 29004 invoked from network); 7 Jul 2003 09:45:36 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 7 Jul 2003 09:45:36 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [212.125.75.4] by sunsite.dk (MessageWall 1.0.8) with SMTP; 7 Jul 2003 9:45:36 -0000 Received: (qmail 15130 invoked from network); 7 Jul 2003 09:44:18 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-13.tower-1.messagelabs.com with SMTP; 7 Jul 2003 09:44:18 -0000 Received: from gmcs3.local ([158.234.142.61]) by iris.logica.co.uk (8.12.3/8.12.3/Debian -4) with ESMTP id h679iIHg030139 for ; Mon, 7 Jul 2003 10:44:18 +0100 Received: from gmcs3.local (localhost [127.0.0.1]) by gmcs3.local (8.11.6/8.11.6/SuSE Linux 0.5) with ESMTP id h679jMH02789 for ; Mon, 7 Jul 2003 11:45:22 +0200 X-VirusChecked: Checked From: Oliver Kiddle To: Zsh workers Subject: PATCH: accept-exact style in _expand Date: Mon, 07 Jul 2003 11:45:22 +0200 Message-ID: <2787.1057571122@gmcs3.local> The accept-exact style (with value false) in _expand was bailing out after things like ~/ and ~+/ and even ~/Mail/*. To take the last example, it was looking for named directories or users named '/Mail/*' and returning if it didn't find exactly one. It finds none in this case. Fix is to only return if it found more than one: - ( "$word" = \~* && ${#userdirs[(I)${word[2,-1]}*]}+${#nameddirs[(I)${word[2,-1]}*]} -ne 1 ) || + ( "$word" = \~* && ${#userdirs[(I)${word[2,-1]}*]}+${#nameddirs[(I)${word[2,-1]}*]} -gt 1 ) || I'll commit that to 4.0. The second bug is with the use of [[ -o recexact ]] to determine the default. This was done back-to-front. But should that be fixed in the 4.0 branch? So you may find you want to set the style after this change. The patch below however, adds a new feature too. With it, if you set the accept-exact style to `continue', it will add the expansion as a match but return 1 so other completers will also get a chance. The result is this: % foo=value % foobar=whatever % echo $foo all expansions /usr/local parameter foo foobar Unfortunately, you can't use a tag-order with these because _main_complete doesn't have a tag loop. I've only applied this after something like `~foo' or `$foo' and not after something like just `~', `~+' or `~+1' though because I didn't like that. If you do want those expansons added, let me know and I'll make it more flexible. Oliver Index: Completion/Base/Completer/_expand =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_expand,v retrieving revision 1.7 diff -u -r1.7 _expand --- Completion/Base/Completer/_expand 15 May 2001 13:52:23 -0000 1.7 +++ Completion/Base/Completer/_expand 7 Jul 2003 09:37:04 -0000 @@ -12,6 +12,7 @@ [[ _matcher_num -gt 1 ]] && return 1 local exp word sort expr expl subd suf=" " force opt asp tmp opre pre epre +local continue=0 (( $# )) && while getopts gsco opt; do @@ -37,13 +38,17 @@ "${(e)word}" != *[][^*?\(\)\<\>\{\}\|]* ]] && return 1 -zstyle -t ":completion:${curcontext}:" accept-exact || - [[ $? -eq 2 && ! -o recexact ]] || +zstyle -s ":completion:${curcontext}:" accept-exact tmp || + [[ ! -o recexact ]] || tmp=1 + +if [[ "$tmp" != (yes|true|on|1) ]]; then { [[ "$word" = \~(|[-+]) || - ( "$word" = \~[-+][1-9]## && $word[3,-1] -le $#dirstack ) || - ( "$word" = \~* && ${#userdirs[(I)${word[2,-1]}*]}+${#nameddirs[(I)${word[2,-1]}*]} -ne 1 ) || + ( "$word" = \~[-+][1-9]## && $word[3,-1] -le $#dirstack ) ]] && return 1 } + { [[ ( "$word" = \~* && ${#userdirs[(I)${word[2,-1]}*]}+${#nameddirs[(I)${word[2,-1]}*]} -gt 1 ) || ( "$word" = *\$[a-zA-Z0-9_]## && - ${#parameters[(I)${word##*\$}*]} -ne 1 ) ]] && return 1 } + ${#parameters[(I)${word##*\$}*]} -ne 1 ) ]] && continue=1 } + [[ continue -eq 1 && "$tmp" != continue ]] && return 1 +fi # In exp we will collect the expansions. @@ -217,4 +222,4 @@ compstate[insert]=menu fi -return 0 +return continue Index: Doc/Zsh/compsys.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v retrieving revision 1.170 diff -u -r1.170 compsys.yo --- Doc/Zsh/compsys.yo 5 Jun 2003 09:51:31 -0000 1.170 +++ Doc/Zsh/compsys.yo 7 Jul 2003 09:37:04 -0000 @@ -1034,7 +1034,9 @@ expanded. For example, if there are parameters tt(foo) and tt(foobar), the string `tt($foo)' will only be expanded if tt(accept-exact) is set to `true'; otherwise the completion system will -be allowed to complete tt($foo) to tt($foobar). +be allowed to complete tt($foo) to tt($foobar). If the style is set to +`continue', _expand will add the expansion as a match and the completion +system will also be allowed to continue. ) kindex(add-space, completion style) item(tt(add-space))(