From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16763 invoked from network); 13 Jun 2000 12:46:30 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 13 Jun 2000 12:46:30 -0000 Received: (qmail 18920 invoked by alias); 13 Jun 2000 12:45:50 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11874 Received: (qmail 18870 invoked from network); 13 Jun 2000 12:45:44 -0000 Date: Tue, 13 Jun 2000 13:24:33 +0200 (MET DST) Message-Id: <200006131124.NAA31140@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk Subject: PATCH: expansion [ sunsite.auc.dk seems to be down, at least I don't get my mails back... I'll just keep on sending patches ;-] We were discussing these... This adds the style `suffix' and makes `accept-exact' be used by _expand: - With `suffix', expansion is not done if there is anything after a `~foo' or `$foo'. I.e. it will not expand `~foo/', but it will expand `~foo'. - With `accept-exact' set it will expand `$MAIL', with it unset, it will not expand it (if there are other parameters starting with `MAIL'). We were using rexexact in the old expansion code, so I thought we should just use `accept-exact' which is the style equivalent of recexact. Note that I've used the same default value in _expand as it has elsewhere (`false'), which means that without further configuring, this now behaves differently. Should we make it default to `true' in _expand? Ok. Is this good enough? Oliver? Bye Sven Index: Completion/Core/_expand =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v retrieving revision 1.15 diff -u -r1.15 _expand --- Completion/Core/_expand 2000/06/08 08:39:51 1.15 +++ Completion/Core/_expand 2000/06/13 11:22:46 @@ -18,12 +18,6 @@ force="$force$opt" done -if [[ "$funcstack[2]" = _prefix ]]; then - word="$IPREFIX$PREFIX$SUFFIX" -else - word="$IPREFIX$PREFIX$SUFFIX$ISUFFIX" -fi - # First, see if we should insert all *completions*. if [[ "$force" = *c* ]] || @@ -33,8 +27,25 @@ [[ "$curcontext" = expand-word:* ]] && _complete && return 0 return 1 fi + +if [[ "$funcstack[2]" = _prefix ]]; then + word="$IPREFIX$PREFIX$SUFFIX" +else + word="$IPREFIX$PREFIX$SUFFIX$ISUFFIX" +fi + +zstyle -t ":completion:${curcontext}:" suffix && + [[ "$word" = (\~*/*|\$[a-zA-Z0-9_]##[^a-zA-Z0-9_]*|\$\{*\}?*) ]] && + return 1 + +zstyle -t ":completion:${curcontext}:" accept-exact || + { [[ "$word" = \~(|[-+]) || + ( "$word" = \~[-+][1-9]## && $word[3,-1] -le $#dirstack ) || + ( "$word" = \~* && ${#userdirs[(I)${word[2,-1]}*]}+${#nameddirs[(I)${word[2,-1]}*]} -ne 1 ) || + ( "$word" = \$[a-zA-Z0-9_]## && + ${#parameters[(I)${word[2,-1]}*]} -ne 1 ) ]] && return 1 } -# In exp we will collect the expansion. +# In exp we will collect the expansions. exp=("$word") Index: Doc/Zsh/compsys.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v retrieving revision 1.60 diff -u -r1.60 compsys.yo --- Doc/Zsh/compsys.yo 2000/06/08 08:39:51 1.60 +++ Doc/Zsh/compsys.yo 2000/06/13 11:22:48 @@ -779,6 +779,12 @@ matches. If it is set to `true' for at least one match which is the same as the string on the line, this match will immediately be accepted. + +Note that this is also used by the tt(_expand) completer to decide if +words beginning with a tilde or parameter expansion should be +expanded. This means that if, for example, there are parameters +tt(foo) and tt(foobar), the string `tt($foo)' will only be expanded if +tt(accept-exact) is set to `true'. ) kindex(add-space, completion style) item(tt(add-space))( @@ -1785,6 +1791,14 @@ substitution will be performed only if given an explicit numeric argument other than `tt(1)', as by typing `tt(ESC 2 TAB)'. +) +kindex(suffix, completion style) +item(tt(suffix))( +This is used by the tt(_expand) completer if the word starts with a +tilde or parameter expansion. If it is set to `true', the word will +only be expanded if it doesn't have a suffix, i.e. if it is something +like `tt(~foo)' or `tt($foo)', but not if it is `tt(~foo/)' or +`tt($foo/bar)'. The default for this style is `false'. ) kindex(tag-order, completion style) item(tt(tag-order))( -- Sven Wischnowsky wischnow@informatik.hu-berlin.de