1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-03 10:21:46 +02:00

allow brace expansion on patterns for file-patterns and tag-order (10695)

This commit is contained in:
Sven Wischnowsky 2000-04-12 12:35:38 +00:00
parent 4a250fe1dd
commit 4a3b94ca40
4 changed files with 24 additions and 13 deletions

View file

@ -1,5 +1,9 @@
2000-04-12 Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
* 10695: Completion/Core/_files, Completion/Core/_tags,
Doc/Zsh/compsys.yo: allow brace expansion on patterns for
file-patterns and tag-order
* 10692: Src/builtin.c: missing initialisation for next field in
assignments for substitutions for fc builtin

View file

@ -6,7 +6,11 @@ zparseopts -a opts \
'/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+:
type="${(@j::M)${(@)tmp#-}#?}"
(( $tmp[(I)-g*] )) && glob="${(j:,:)${(@M)tmp:#-g*}#-g}"
if (( $tmp[(I)-g*] )); then
glob="${${${${(@M)tmp:#-g*}#-g}##[[:blank:]]#}%%[[:blank:]]#}"
[[ "$glob" = *[^\\][[:blank:]]* ]] &&
glob="{${glob//(#b)([^\\])[[:blank:]]##/${match[1]},}}"
fi
ign=$opts[(I)-F]
if (( ign )); then
ign=( $=opts[ign+1] )
@ -22,7 +26,7 @@ fi
if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
[[ "$type" = */* ]] && glob="$glob,*(-/)"
pats=()
for i in ${tmp//\\%p/ ${${glob:-\*}//:/\\:} }; do
for i in ${tmp//\\%p/${${glob:-\*}//:/\\:} }; do
if [[ $i = *[^\\]:* ]]; then
pats=( "$pats[@]" " $i " )
else
@ -45,9 +49,9 @@ else
fi
for def in "$pats[@]"; do
def="${def##[[:blank:]]#}"
while [[ "$def" = *[^\\][[:blank:]]* ]]; do
sdef="${${(M)def#*[^\\][[:blank:]]}%%[[:blank:]]#}"
eval "def=( ${${def:s/\\:/\\\\\\\\\\\\:}//(#b)([][()|*?^#~<>])/\\${match[1]}} )"
for sdef in "$def[@]"; do
tag="${${sdef#*[^\\]:}%%:*}"
pat="${${${sdef%%:${tag}*}//\\\\:/:}//,/ }"
@ -70,7 +74,6 @@ for def in "$pats[@]"; do
fi
done
done
def="${${def#${sdef}}##[[:blank:]]#}"
done
(( ret )) || return 0
done

View file

@ -64,7 +64,8 @@ if (( $# )); then
fi
;;
\!*) comptry "${(@)argv:#(${(j:|:)~${=~tag[2,-1]}})}";;
?*) comptry -m "$tag";;
?*) eval "tag=( ${${tag:s/\\:/\\\\\\\\\\\\:}//(#b)([][()|*?^#~<>])/\\${match[1]}} )"
comptry -m "${${(@)tag// /\\ }}";;
esac
done

View file

@ -947,13 +947,15 @@ If the tt(file-patterns) style is set, the default tags are not
used. Instead, the value of the style says which tags and which
patterns are to be offered. The strings in the value contain
specifications of the form
`var(patterns)tt(:)var(tag)'; each string may contain any number of
such specifications. The var(patterns) give one or more glob
patterns separated by commas that are to be used to generate
`var(pattern)tt(:)var(tag)'; each string may contain any number of
such specifications. The var(pattern) gives a glob
pattern that is to be used to generate
filenames. If it contains the sequence `tt(%p)', that is replaced by
the pattern(s) given by the calling function.
Colons in the pattern have to be preceded by a backslash to
make them distinguishable from the colon before the var(tag). The
make them distinguishable from the colon before the var(tag). If more
than one pattern is needed, the patterns can be given inside braces,
separated by commas. The
var(tag)s of all strings in the value will be offered by tt(_files)
(again, one after another) and used when looking up other styles. For
strings containing more than one specification, the filenames for all
@ -1707,8 +1709,9 @@ for a description of these special parameters).
)
enditem()
In each of the cases above, the tag may also be a pattern. In this
case all of the offered tags matching this pattern will be used except
In each of the cases above, the tag may also be a pattern or more than
one pattern inside braces and separated by commas. In this
case all of the offered tags matching the pattern(s) will be used except
for those that are given explicitly in the same string. There are
probably two main uses of this. One is the case where one wants to try
one of the tags more than once, setting other styles differently for