1999-04-15 20:05:38 +02:00
|
|
|
#autoload
|
|
|
|
|
2000-06-15 11:06:21 +02:00
|
|
|
local opts tmp glob pat pats expl tag i def descr end ign ret=1 match tried
|
2001-03-11 23:53:41 +01:00
|
|
|
local type sdef
|
1999-04-15 20:05:38 +02:00
|
|
|
|
2000-04-01 22:43:43 +02:00
|
|
|
zparseopts -a opts \
|
|
|
|
'/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+:
|
1999-04-15 20:05:38 +02:00
|
|
|
|
2000-04-01 22:43:43 +02:00
|
|
|
type="${(@j::M)${(@)tmp#-}#?}"
|
2000-04-12 14:35:38 +02:00
|
|
|
if (( $tmp[(I)-g*] )); then
|
|
|
|
glob="${${${${(@M)tmp:#-g*}#-g}##[[:blank:]]#}%%[[:blank:]]#}"
|
|
|
|
[[ "$glob" = *[^\\][[:blank:]]* ]] &&
|
|
|
|
glob="{${glob//(#b)([^\\])[[:blank:]]##/${match[1]},}}"
|
|
|
|
fi
|
2000-04-03 17:27:14 +02:00
|
|
|
ign=$opts[(I)-F]
|
|
|
|
if (( ign )); then
|
|
|
|
ign=( $=opts[ign+1] )
|
|
|
|
if [[ $ign = _comp_ignore ]]; then
|
|
|
|
ign=( $_comp_ignore )
|
|
|
|
else
|
|
|
|
opts[tmp+1]=_comp_ignore
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
ign=
|
|
|
|
fi
|
1999-04-15 20:05:38 +02:00
|
|
|
|
2000-04-06 13:36:33 +02:00
|
|
|
if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
|
2000-04-11 09:57:56 +02:00
|
|
|
[[ "$type" = */* ]] && glob="$glob,*(-/)"
|
2000-04-06 13:36:33 +02:00
|
|
|
pats=()
|
2000-06-15 11:06:21 +02:00
|
|
|
|
|
|
|
for i in ${tmp//%p/${${glob:-\*}//:/\\:}}; do
|
2000-04-06 13:36:33 +02:00
|
|
|
if [[ $i = *[^\\]:* ]]; then
|
2000-04-11 09:57:56 +02:00
|
|
|
pats=( "$pats[@]" " $i " )
|
2000-04-06 13:36:33 +02:00
|
|
|
else
|
2000-04-11 09:57:56 +02:00
|
|
|
pats=( "$pats[@]" " ${i}:files " )
|
2000-04-06 13:36:33 +02:00
|
|
|
fi
|
|
|
|
done
|
2000-04-01 22:43:43 +02:00
|
|
|
else
|
|
|
|
if [[ "$type" = *g* ]]; then
|
|
|
|
if [[ "$type" = */* ]]; then
|
2000-04-11 09:57:56 +02:00
|
|
|
pats=( " ${glob//:/\\:}:globbed-files *(-/):directories" '*:all-files ' )
|
2000-04-01 22:43:43 +02:00
|
|
|
else
|
2000-04-11 09:57:56 +02:00
|
|
|
pats=( " ${glob//:/\\:}:globbed-files "
|
|
|
|
'*(-/):directories ' '*:all-files ' )
|
2000-04-01 22:43:43 +02:00
|
|
|
fi
|
|
|
|
elif [[ "$type" = */* ]]; then
|
2000-04-11 09:57:56 +02:00
|
|
|
pats=( '*(-/):directories ' '*:all-files ' )
|
2000-04-01 22:43:43 +02:00
|
|
|
else
|
2000-04-11 09:57:56 +02:00
|
|
|
pats=( '*:all-files ' )
|
2000-04-01 22:43:43 +02:00
|
|
|
fi
|
|
|
|
fi
|
1999-04-15 20:05:38 +02:00
|
|
|
|
2000-06-15 11:06:21 +02:00
|
|
|
tried=()
|
2000-04-11 09:57:56 +02:00
|
|
|
for def in "$pats[@]"; do
|
2000-04-12 14:35:38 +02:00
|
|
|
eval "def=( ${${def:s/\\:/\\\\\\\\\\\\:}//(#b)([][()|*?^#~<>])/\\${match[1]}} )"
|
|
|
|
for sdef in "$def[@]"; do
|
|
|
|
|
2000-04-11 09:57:56 +02:00
|
|
|
tag="${${sdef#*[^\\]:}%%:*}"
|
2000-10-05 09:31:00 +02:00
|
|
|
pat="${${sdef%%:${tag}*}//\\:/:}"
|
1999-04-15 20:05:38 +02:00
|
|
|
|
2000-06-15 11:06:21 +02:00
|
|
|
(( $tried[(I)${(q)pat}] )) && continue
|
|
|
|
|
|
|
|
tried=( "$tried[@]" "$pat" )
|
|
|
|
|
2000-04-11 09:57:56 +02:00
|
|
|
if [[ "$sdef" = *:${tag}:* ]]; then
|
|
|
|
descr="${(Q)sdef#*:${tag}:}"
|
2000-04-01 22:43:43 +02:00
|
|
|
else
|
|
|
|
descr=file
|
2000-04-03 17:27:14 +02:00
|
|
|
end=yes
|
2000-04-01 22:43:43 +02:00
|
|
|
fi
|
|
|
|
|
2000-04-11 09:57:56 +02:00
|
|
|
_tags "$tag"
|
|
|
|
while _tags; do
|
|
|
|
_comp_ignore=()
|
|
|
|
while _next_label "$tag" expl "$descr"; do
|
|
|
|
_comp_ignore=( $_comp_ignore $ign )
|
|
|
|
if [[ -n "$end" ]]; then
|
|
|
|
_path_files -g "$pat" "$opts[@]" "$expl[@]" && ret=0
|
|
|
|
else
|
|
|
|
_path_files "$expl[@]" -g "$pat" "$opts[@]" && ret=0
|
|
|
|
fi
|
|
|
|
done
|
2000-05-11 11:12:57 +02:00
|
|
|
(( ret )) || break
|
2000-04-03 17:27:14 +02:00
|
|
|
done
|
2000-06-15 11:06:21 +02:00
|
|
|
[[ "$pat" = '*' ]] && return ret
|
2000-04-11 09:57:56 +02:00
|
|
|
done
|
|
|
|
(( ret )) || return 0
|
2000-04-01 22:43:43 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
return 1
|