summaryrefslogtreecommitdiffstats
path: root/Completion/Core
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-11 07:57:56 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-04-11 07:57:56 +0000
commitfac3086d9782e73dcaf1aa65fd36a0b63a374719 (patch)
tree7bab35e2787ca17f02ec932dffae1bfff2ffcfe3 /Completion/Core
parent10628: Check for GNU make using "_call version ..." as was done for GNU diff. (diff)
downloadzsh-fac3086d9782e73dcaf1aa65fd36a0b63a374719.tar
zsh-fac3086d9782e73dcaf1aa65fd36a0b63a374719.tar.gz
zsh-fac3086d9782e73dcaf1aa65fd36a0b63a374719.tar.bz2
zsh-fac3086d9782e73dcaf1aa65fd36a0b63a374719.tar.lz
zsh-fac3086d9782e73dcaf1aa65fd36a0b63a374719.tar.xz
zsh-fac3086d9782e73dcaf1aa65fd36a0b63a374719.tar.zst
zsh-fac3086d9782e73dcaf1aa65fd36a0b63a374719.zip
_wanted now tests both tags and labels; change places where _wanted was called without a command; allow multiple patterns per string in file-patterns; update _next_tags to work with labels (10632)
Diffstat (limited to 'Completion/Core')
-rw-r--r--Completion/Core/_all_labels30
-rw-r--r--Completion/Core/_files59
-rw-r--r--Completion/Core/_next_label5
-rw-r--r--Completion/Core/_requested1
-rw-r--r--Completion/Core/_wanted19
5 files changed, 52 insertions, 62 deletions
diff --git a/Completion/Core/_all_labels b/Completion/Core/_all_labels
index fa7118ec4..a03112ee4 100644
--- a/Completion/Core/_all_labels
+++ b/Completion/Core/_all_labels
@@ -1,11 +1,7 @@
#autoload
-local gopt=-J len tmp pre suf tloop ret=1 descr
+local gopt=-J len tmp pre suf ret=1 descr spec
-if [[ "$1" = -t ]]; then
- tloop=yes
- shift
-fi
if [[ "$1" = -([12]|)[VJ] ]]; then
gopt="$1"
shift
@@ -24,21 +20,19 @@ else
suf=5
fi
-while [[ -z "$tloop" ]] || comptags -N; do
- while comptags -A "$1" curtag; do
- if [[ "$curtag" = *:* ]]; then
- zformat -f descr "${curtag#*:}" "d:$3"
- _description "$gopt" "${curtag%:*}" "$2" "$descr"
- curtag="${curtag%:*}"
+while comptags -A "$1" curtag spec; do
+ _comp_tags="$_comp_tags $spec "
+ if [[ "$curtag" = *:* ]]; then
+ zformat -f descr "${curtag#*:}" "d:$3"
+ _description "$gopt" "${curtag%:*}" "$2" "$descr"
+ curtag="${curtag%:*}"
- "$4" "${(P@)2}" "${(@)argv[5,-1]}"
- else
- _description "$gopt" "$curtag" "$2" "$3"
+ "$4" "${(P@)2}" "${(@)argv[5,-1]}"
+ else
+ _description "$gopt" "$curtag" "$2" "$3"
- "${(@)argv[4,pre]}" "${(P@)2}" "${(@)argv[suf,-1]}" && ret=0
- fi
- done
- [[ -z "$tloop" || ret -eq 0 ]] && break
+ "${(@)argv[4,pre]}" "${(P@)2}" "${(@)argv[suf,-1]}" && ret=0
+ fi
done
return ret
diff --git a/Completion/Core/_files b/Completion/Core/_files
index 8a9bbfc95..a64e5c093 100644
--- a/Completion/Core/_files
+++ b/Completion/Core/_files
@@ -6,7 +6,7 @@ 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}"
+(( $tmp[(I)-g*] )) && glob="${(j:,:)${(@M)tmp:#-g*}#-g}"
ign=$opts[(I)-F]
if (( ign )); then
ign=( $=opts[ign+1] )
@@ -20,56 +20,59 @@ else
fi
if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
- [[ "$type" = */* ]] && glob="$glob *(-/)"
+ [[ "$type" = */* ]] && glob="$glob,*(-/)"
pats=()
for i in ${tmp//\\%p/ ${${glob:-\*}//:/\\:} }; do
if [[ $i = *[^\\]:* ]]; then
- pats=( "$pats[@]" " $i" )
+ pats=( "$pats[@]" " $i " )
else
- pats=( "$pats[@]" " ${i}:files" )
+ pats=( "$pats[@]" " ${i}:files " )
fi
done
else
if [[ "$type" = *g* ]]; then
if [[ "$type" = */* ]]; then
- pats=( " ${glob//:/\\:} *(-/):globbed-files" '*:all-files' )
+ pats=( " ${glob//:/\\:}:globbed-files *(-/):directories" '*:all-files ' )
else
- pats=( " ${glob//:/\\:}:globbed-files"
- '*(-/):directories' '*:all-files' )
+ pats=( " ${glob//:/\\:}:globbed-files "
+ '*(-/):directories ' '*:all-files ' )
fi
elif [[ "$type" = */* ]]; then
- pats=( '*(-/):directories' '*:all-files' )
+ pats=( '*(-/):directories ' '*:all-files ' )
else
- pats=( '*:all-files' )
+ pats=( '*:all-files ' )
fi
fi
-for def in "$pats[@]"; do ###"${(@)${(@)pats#*[^\\]:}%%:*}"; do
+for def in "$pats[@]"; do
+ def="${def##[[:blank:]]#}"
+ while [[ "$def" = *[^\\][[:blank:]]* ]]; do
+ sdef="${(M)def#*[^\\][[:blank:]]}"
+ tag="${${sdef#*[^\\]:}%%:*}"
+ pat="${${${sdef%%:${tag}*}//\\\\:/:}//,/ }"
- tag="${${def#*[^\\]:}%%:*}"
- pat="${${def%%:${tag}*}//\\\\:/:}"
-
- if [[ "$pat" != \ # ]]; then
- if [[ "$def" = *:${tag}:* ]]; then
- descr="${def#*:${tag}:}"
+ if [[ "$sdef" = *:${tag}:* ]]; then
+ descr="${(Q)sdef#*:${tag}:}"
else
descr=file
end=yes
fi
- fi
- if _wanted "$tag"; then
- _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
+ _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
done
- (( ret )) || return 0
- fi
+ def="${${def#${sdef}}##[[:blank:]]#}"
+ done
+ (( ret )) || return 0
done
return 1
diff --git a/Completion/Core/_next_label b/Completion/Core/_next_label
index e309e53ea..d2d698171 100644
--- a/Completion/Core/_next_label
+++ b/Completion/Core/_next_label
@@ -1,13 +1,14 @@
#autoload
-local gopt=-J descr
+local gopt=-J descr spec
if [[ "$1" = -([12]|)[VJ] ]]; then
gopt="$1"
shift
fi
-if comptags -A "$1" curtag; then
+if comptags -A "$1" curtag spec; then
+ _comp_tags="$_comp_tags $spec "
if [[ "$curtag" = *:* ]]; then
zformat -f descr "${curtag#*:}" "d:$3"
_description "$gopt" "${curtag%:*}" "$2" "$descr"
diff --git a/Completion/Core/_requested b/Completion/Core/_requested
index bd838a28e..90fdec279 100644
--- a/Completion/Core/_requested
+++ b/Completion/Core/_requested
@@ -8,7 +8,6 @@ if [[ "$1" = -([12]|)[VJ] ]]; then
fi
if comptags -R "$1"; then
- _comp_tags="$_comp_tags $1"
if [[ $# -gt 3 ]]; then
_all_labels "$gopt" "$@"
elif [[ $# -gt 1 ]]; then
diff --git a/Completion/Core/_wanted b/Completion/Core/_wanted
index 32875ec57..958f9e18e 100644
--- a/Completion/Core/_wanted
+++ b/Completion/Core/_wanted
@@ -17,17 +17,10 @@ if [[ "$1" = -([12]|)[VJ] ]]; then
shift
fi
-if [[ $# -gt 3 ]]; then
- if _tags "$targs[@]" "$1"; then
- _comp_tags="$_comp_tags $1"
+_tags "$targs[@]" "$1"
- _all_labels -t "$gopt" "$@"
- else
- return 1
- fi
-elif [[ $# -gt 1 ]]; then
- _tags -- "$targs[@]" "$1" && _comp_tags="$_comp_tags $1" &&
- _description "$gopt" "$@"
-else
- _tags -- "$targs[@]" "$1" && _comp_tags="$_comp_tags $1"
-fi
+while _tags; do
+ _all_labels "$gopt" "$@" && return 0
+done
+
+return 1