1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-28 05:00:59 +01:00

users/10989: add fake-always pattern that overrides ignored-patterns

This commit is contained in:
Peter Stephenson 2006-11-15 16:27:14 +00:00
parent e12c3e2dc9
commit 181e491deb
3 changed files with 47 additions and 8 deletions

View file

@ -1,3 +1,9 @@
2006-11-15 Peter Stephenson <pws@csr.com>
* users/10989: Completion/Base/Core/_description,
Doc/Zsh/compsys.yo: add fake-always style that overrides
ignored-patterns.
2006-11-14 Peter Stephenson <pws@csr.com> 2006-11-14 Peter Stephenson <pws@csr.com>
* users/10981: Jean-Rene David <jrdavid@magma.ca>: * users/10981: Jean-Rene David <jrdavid@magma.ca>:

View file

@ -58,7 +58,9 @@ if [[ -z "$_comp_no_ignore" ]]; then
"${(@)words[CURRENT+1,-1]}" );; "${(@)words[CURRENT+1,-1]}" );;
esac esac
(( $#_comp_ignore )) && opts=( $opts -F _comp_ignore ) # Ensure the ignore option is first so we can override it
# for fake-always.
(( $#_comp_ignore )) && opts=( -F _comp_ignore $opts )
else else
_comp_ignore=() _comp_ignore=()
fi fi
@ -86,15 +88,21 @@ else
fi fi
fi fi
if ! (( ${funcstack[2,-1][(I)_description]} )) && if ! (( ${funcstack[2,-1][(I)_description]} )); then
zstyle -a ":completion:${curcontext}:$tag" fake match; then local fakestyle descr
for fakestyle in fake fake-always; do
zstyle -a ":completion:${curcontext}:$tag" $fakestyle match ||
continue
local descr descr=( "${(@M)match:#*[^\\]:*}" )
descr=( "${(@M)match:#*[^\\]:*}" ) opts=("${(@P)name}")
if [[ $fakestyle = fake-always && $opts[1,2] = "-F _comp_ignore" ]]; then
compadd "${(@P)name}" - "${(@)${(@)match:#*[^\\]:*}:s/\\:/:/}" shift 2 opts
(( $#descr )) && _describe -t "$tag" '' descr "${(@P)name}" fi
compadd "${(@)opts}" - "${(@)${(@)match:#*[^\\]:*}:s/\\:/:/}"
(( $#descr )) && _describe -t "$tag" '' descr "${(@)opts}"
done
fi fi
return 0 return 0

View file

@ -1308,6 +1308,31 @@ It is important to use a sufficiently restrictive context when specifying
fake strings. Note that the styles tt(fake-files) and tt(fake-parameters) fake strings. Note that the styles tt(fake-files) and tt(fake-parameters)
provide additional features when completing files or parameters. provide additional features when completing files or parameters.
) )
kindex(fake-always, completion style)
item(tt(fake-always))(
This works identically to the tt(fake) style except that
the tt(ignored-patterns) style is not applied to it. This makes it
possible to override a set of matches completely by setting the
ignored patterns to `tt(*)'.
The following shows a way of supplementing any tag with arbitrary data, but
having it behave for display purposes like a separate tag. In this example
we use the features of the tt(tag-order) style to divide the
tt(named-directories) tag into two when performing completion with
the standard completer tt(complete) for arguments of tt(cd). The tag
tt(named-directories-normal) behaves as normal, but the tag
tt(named-directories-mine) contains a fixed set of directories.
This has the effect of adding the match group `tt(extra directories)' with
the given completions.
example(zstyle ':completion::complete:cd:*' tag-order \
'named-directories:-mine:extra\ directories
named-directories:-normal:named\ directories *'
zstyle ':completion::complete:cd:*:named-directories-mine' \
fake-always mydir1 mydir2
zstyle ':completion::complete:cd:*:named-directories-mine' \
ignored-patterns '*')
)
kindex(fake-files, completion style) kindex(fake-files, completion style)
item(tt(fake-files))( item(tt(fake-files))(
This style is used when completing files and looked up This style is used when completing files and looked up