diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Completion/Core/_expand | 25 | ||||
-rw-r--r-- | Doc/Zsh/compsys.yo | 14 |
3 files changed, 35 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog index 42c3cc23c..13a6fcc51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2000-06-13 Sven Wischnowsky <wischnow@zsh.org> + * ?????: Completion/Core/_expand, Doc/Zsh/compsys.yo: new style + `suffix', use accept-exact style in _expand + * ?????: Src/Zle/complist.c: fix for longer capability strings; very bad diff --git a/Completion/Core/_expand b/Completion/Core/_expand index 25145f752..9ba055a6e 100644 --- a/Completion/Core/_expand +++ b/Completion/Core/_expand @@ -18,12 +18,6 @@ local exp word sort expr expl subd suf=" " force opt asp tmp opre pre epre 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* ]] || @@ -34,7 +28,24 @@ if [[ "$force" = *c* ]] || return 1 fi -# In exp we will collect the expansion. +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 expansions. exp=("$word") diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 24ada7446..82975e0fd 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -779,6 +779,12 @@ This is tested for the default tag and the tags used when generating 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))( @@ -1786,6 +1792,14 @@ example(zstyle ':completion:*:expand:::' substitute '${NUMERIC:-1} != 1') 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))( This provides a mechanism for sorting how the tags available in a |