summaryrefslogtreecommitdiffstats
path: root/Completion
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-03-24 12:37:56 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-03-24 12:37:56 +0000
commitb0226d3cc8393bb4dd57d9e2e8f04ef885c43ab9 (patch)
tree9b9357f56affeb7e8e3c368c0396cf850ff0174b /Completion
parentzsh-workers/10230 (diff)
downloadzsh-b0226d3cc8393bb4dd57d9e2e8f04ef885c43ab9.tar
zsh-b0226d3cc8393bb4dd57d9e2e8f04ef885c43ab9.tar.gz
zsh-b0226d3cc8393bb4dd57d9e2e8f04ef885c43ab9.tar.bz2
zsh-b0226d3cc8393bb4dd57d9e2e8f04ef885c43ab9.tar.lz
zsh-b0226d3cc8393bb4dd57d9e2e8f04ef885c43ab9.tar.xz
zsh-b0226d3cc8393bb4dd57d9e2e8f04ef885c43ab9.tar.zst
zsh-b0226d3cc8393bb4dd57d9e2e8f04ef885c43ab9.zip
zsh-workers/10231
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Builtins/_zstyle1
-rw-r--r--Completion/Commands/_next_tags45
-rw-r--r--Completion/Core/_tags60
3 files changed, 83 insertions, 23 deletions
diff --git a/Completion/Builtins/_zstyle b/Completion/Builtins/_zstyle
index 2c9f6be3b..40a66a364 100644
--- a/Completion/Builtins/_zstyle
+++ b/Completion/Builtins/_zstyle
@@ -55,6 +55,7 @@ styles=(
remove-all-dups c:bool
single-ignored c:single-ignored
sort c:bool
+ tag-aliases c:tag
tag-order c:tag
special-dirs c:sdirs
squeeze-slashes c:bool
diff --git a/Completion/Commands/_next_tags b/Completion/Commands/_next_tags
index 028ba4d61..6d3389ff1 100644
--- a/Completion/Commands/_next_tags
+++ b/Completion/Commands/_next_tags
@@ -46,7 +46,7 @@ _next_tags_pre() {
# Helper function for sorting tags. Most of this is copied from _tags.
_next_tags_sort() {
- local order tags tag nodef
+ local order tags tag nodef tmp tmp2
if ! zstyle -a ":completion:${curcontext}:" tag-order order; then
if (( $+_comp_default_tags )); then
@@ -69,12 +69,49 @@ _next_tags_sort() {
case $tag in
-) nodef=yes;;
*\(\)) "${${tag%%[ ]#\(\)}##[ ]#}" "$@";;
- \!*) comptry "${(@)argv:#(${(j:|:)~${=tag[2,-1]}})}";;
- ?*) comptry ${=tag};;
+ \!*) comptry "${(@)argv:#(${(j:|:)~${=~tag[2,-1]}})}";;
+ ?*) tmp=( ${${(s: :)${tag//\\\\ /$'\0'}}//$'\0'/ } ) tmp2=() tmp3=()
+ for tag in "$tmp[@]"; do
+ if [[ "$tag" = *:* ]]; then
+ tmp2=( "$tmp2[@]" "${(@M)^argv:#${~tag%%:*}}:${tag#*:}" )
+ else
+ for atag in "${(@M)argv:#${~tag}}"; do
+ if zstyle -a ":completion:${curcontext}:${atag}" tag-aliases als; then
+ tmp3=( "$tmp3[@]" "$als[@]" )
+ tmp=( "${(@)tmp:#${atag}}" )
+ else
+ tmp2=( "$tmp2[@]" "$atag" )
+ fi
+ done
+ fi
+ done
+
+ comptry "${(@)tmp2:#(${(j:|:)~${(q)tmp%%:*}})}" "$tmp3[@]" "$tmp[@]"
+ ;;
esac
done
- [[ -z "$nodef" ]] && comptry "$@"
+ if [[ -z "$nodef" ]]; then
+ if (( $+_comp_default_tags )); then
+ for tag in "$_comp_default_tags[@]"; do
+ if zstyle -a ":completion:${curcontext}:${tag}" tag-aliases als; then
+ comptry "$als[@]"
+ else
+ comptry "$tag"
+ fi
+ done
+ else
+ tmp2=()
+ for tag; do
+ if zstyle -a ":completion:${curcontext}:${tag}" tag-aliases als; then
+ tmp2=( "$tmp2[@]" "$als[@]" )
+ else
+ tmp2=( "$tmp2[@]" "$tag" )
+ fi
+ done
+ comptry "$tmp2[@]"
+ fi
+ fi
}
[[ -o kshautoload ]] || _next_tags "$@"
diff --git a/Completion/Core/_tags b/Completion/Core/_tags
index 2dfa56f9d..a617776d4 100644
--- a/Completion/Core/_tags
+++ b/Completion/Core/_tags
@@ -16,7 +16,7 @@ if (( $# )); then
# We have arguments: the tags supported in this context.
- local curcontext="$curcontext" order tag nodef
+ local curcontext="$curcontext" order tag nodef tmp tmp2 tmp3 als atag
if [[ "$1" = -C?* ]]; then
curcontext="${curcontext%:*}:${1[3,-1]}"
@@ -51,7 +51,13 @@ if (( $# )); then
if [[ -n "$_sort_tags" ]]; then
"$_sort_tags" "$@"
- elif zstyle -a ":completion:${curcontext}:" tag-order order; then
+ else
+ zstyle -a ":completion:${curcontext}:" tag-order order ||
+ if [[ "$*" = *(arguments|values)* || "$*" = *options* ]] ;then
+ order=( 'arguments values' options )
+ else
+ order=()
+ fi
for tag in $order; do
case $tag in
@@ -61,33 +67,49 @@ if (( $# )); then
break
fi
;;
- \!*) comptry "${(@)argv:#(${(j:|:)~${=tag[2,-1]}})}";;
- ?*) comptry ${${(ps: :)${tag//\\\\ /$'\0'}}//$'\0'/ };;
+ \!*) comptry "${(@)argv:#(${(j:|:)~${=~tag[2,-1]}})}";;
+ ?*) tmp=( ${${(s: :)${tag//\\\\ /$'\0'}}//$'\0'/ } ) tmp2=() tmp3=()
+ for tag in "$tmp[@]"; do
+ if [[ "$tag" = *:* ]]; then
+ tmp2=( "$tmp2[@]" "${(@M)^argv:#${~tag%%:*}}:${tag#*:}" )
+ else
+ for atag in "${(@M)argv:#${~tag}}"; do
+ if zstyle -a ":completion:${curcontext}:${atag}" tag-aliases als; then
+ tmp3=( "$tmp3[@]" "$als[@]" )
+ tmp=( "${(@)tmp:#${atag}}" )
+ else
+ tmp2=( "$tmp2[@]" "$atag" )
+ fi
+ done
+ fi
+ done
+
+ comptry "${(@)tmp2:#(${(j:|:)~${(q)tmp%%:*}})}" "$tmp3[@]" "$tmp[@]"
+ ;;
esac
done
if [[ -z "$nodef" ]]; then
if (( $+_comp_default_tags )); then
for tag in "$_comp_default_tags[@]"; do
- comptry "$tag"
+ if zstyle -a ":completion:${curcontext}:${tag}" tag-aliases als; then
+ comptry "$als[@]"
+ else
+ comptry "$tag"
+ fi
done
else
- comptry "$@"
+ tmp2=()
+ for tag; do
+ if zstyle -a ":completion:${curcontext}:${tag}" tag-aliases als; then
+ tmp2=( "$tmp2[@]" "$als[@]" )
+ else
+ tmp2=( "$tmp2[@]" "$tag" )
+ fi
+ done
+ comptry "$tmp2[@]"
fi
fi
- else
-
- # Use default tags...
-
- if (( $+_comp_default_tags )); then
- for tag in "$_comp_default_tags[@]"; do
- comptry "$tag"
- done
- else
- comptry arguments values
- comptry options
- fi
- comptry "$@"
fi
# Return non-zero if at least one set of tags should be used.