about summary refs log tree commit diff
path: root/Completion/Core
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-12-15 17:35:20 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-12-15 17:35:20 +0000
commit8bc41ba869dbbd3c6bc2c8f2338c740311074f23 (patch)
treed595aeb0a5e399d4cb6a7dfd3818c395e9118ec0 /Completion/Core
parente401df24821d873eba579d2961a0886881b0acf6 (diff)
downloadzsh-8bc41ba869dbbd3c6bc2c8f2338c740311074f23.tar.gz
zsh-8bc41ba869dbbd3c6bc2c8f2338c740311074f23.tar.xz
zsh-8bc41ba869dbbd3c6bc2c8f2338c740311074f23.zip
manual/9058
Diffstat (limited to 'Completion/Core')
-rw-r--r--Completion/Core/_path_files11
-rw-r--r--Completion/Core/_sort_tags59
-rw-r--r--Completion/Core/_tags21
-rw-r--r--Completion/Core/compinit2
4 files changed, 52 insertions, 41 deletions
diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files
index bbed17a1f..dd9934506 100644
--- a/Completion/Core/_path_files
+++ b/Completion/Core/_path_files
@@ -4,7 +4,7 @@
 # to complete to `/usr/local/bin'.
 
 local linepath realpath donepath prepath testpath exppath
-local tmp1 tmp2 tmp3 tmp4 i orig pre suf tpre tsuf opre osuf cpre
+local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre
 local pats haspats=no ignore group expl addpfx addsfx remsfx
 local nm=$compstate[nmatches] menu match matcher mopts atmp
 
@@ -108,6 +108,7 @@ suf="$SUFFIX"
 opre="$PREFIX"
 osuf="$SUFFIX"
 orig="${PREFIX}${SUFFIX}"
+eorig="$orig"
 
 [[ $compstate[insert] = (*menu|[0-9]*) || -n "$_comp_correct" ||
    ( $#compstate[pattern_match] -ne 0 &&
@@ -265,7 +266,11 @@ for prepath in "$prepaths[@]"; do
 	  if [[ "$tmp2[1]" = */* ]]; then
 	    tmp2=( "${(@)tmp2:h}" )
 	    compquote tmp2
-	    exppaths=( "$exppaths[@]" ${^tmp2}/${tpre}${tsuf} )
+	    if [[ "$tmp2" = */ ]]; then
+	      exppaths=( "$exppaths[@]" ${^tmp2}${tpre}${tsuf} )
+	    else
+	      exppaths=( "$exppaths[@]" ${^tmp2}/${tpre}${tsuf} )
+	    fi
           else
 	    exppaths=( "$exppaths[@]" ${tpre}${tsuf} )
 	  fi
@@ -453,7 +458,7 @@ done
 # expanded paths that are different from the string on the line, we add
 # them as possible matches.
 
-exppaths=( "${(@)exppaths:#$orig}" )
+exppaths=( "${(@)exppaths:#$eorig}" )
 
 if zstyle -t ":completion${curcontext}:paths" expand prefix &&
    [[ $#exppaths -gt 0 && nm -eq compstate[nmatches] ]]; then
diff --git a/Completion/Core/_sort_tags b/Completion/Core/_sort_tags
index 20897823a..6f07eec1c 100644
--- a/Completion/Core/_sort_tags
+++ b/Completion/Core/_sort_tags
@@ -1,39 +1,28 @@
 #autoload
 
-local stags tag
+comptry arguments values
+comptry options
 
-if zstyle -a ":completion${curcontext}" sort-tags stags; then
+case "$curcontext" in
+# Some silly examples commented out:
+#
+# *::*p[bgpn]m:*)           # change the order for file-completion
+#   comptry globbed-files directories
+#   comptry all-files
+#   ;;
+# *::dvips::-o*)            # automatic context set by _arguments
+#   comptry all-files
+#   return
+#   ;;
+# *::kill:*)
+#   comptry processes
+#   return                  # this return ensures that we use only processes
+#   ;;
+*)
+  comptry globbed-files
+  comptry directories
+  comptry all-files
+  ;;
+esac
 
-  for tag in $stags; do
-    [[ $tag != '' ]] && comptry ${=tag}
-  done
-
-else
-
-  comptry arguments values
-  comptry options
-
-  case "$curcontext" in
-  # Some silly examples commented out:
-  #
-  # *::*p[bgpn]m:*)           # change the order for file-completion
-  #   comptry globbed-files directories
-  #   comptry all-files
-  #   ;;
-  # *::dvips::-o*)            # automatic context set by _arguments
-  #   comptry all-files
-  #   return
-  #   ;;
-  # *::kill:*)
-  #   comptry processes
-  #   return                  # this return ensures that we use only processes
-  #   ;;
-  *)
-    comptry globbed-files
-    comptry directories
-    comptry all-files
-    ;;
-  esac
-
-  comptry "$@"
-fi
+comptry "$@"
diff --git a/Completion/Core/_tags b/Completion/Core/_tags
index fcef91061..e913095c4 100644
--- a/Completion/Core/_tags
+++ b/Completion/Core/_tags
@@ -4,7 +4,7 @@ if (( $# )); then
 
   # We have arguments: the tags supported in this context.
 
-  local curcontext="$curcontext" order
+  local curcontext="$curcontext" order tag nodef
 
   if [[ "$1" = -C?* ]]; then
     curcontext="${curcontext}:${1[3,-1]}"
@@ -38,9 +38,24 @@ if (( $# )); then
   _offered_tags=( "$_offered_tags[@]" "$@" )
   _last_tags=()
 
-  # Call the function that sorts the tags into sets.
+  # Sort the tags.
 
-  "${_sort_tags:-_sort_tags}" "$@"
+  if [[ -n "$_sort_tags" ]]; then
+    "$_sort_tags" "$@"
+  elif zstyle -a ":completion${curcontext}" tag-order order; then
+
+    for tag in $order; do
+      case $tag in
+      -)     nodef=yes;;
+      *\(\)) "${${tag%%[ 	]#\(\)}##[ 	]#}" "$@";;
+      ?*)    comptry ${=tag};;
+      esac
+    done
+
+    [[ -z "$nodef" ]] && comptry "$@"
+  else
+    comptry "$@"
+  fi
 
   # Return non-zero if at least one set of tags should be used.
 
diff --git a/Completion/Core/compinit b/Completion/Core/compinit
index 09fb68467..8d6d20459 100644
--- a/Completion/Core/compinit
+++ b/Completion/Core/compinit
@@ -479,6 +479,8 @@ zstyle ':completion:correct'  max-errors    '2' numeric
 zstyle ':completion:correct'  prompt        'correct to:'
 zstyle ':completion:*'        completer     '_complete'
 zstyle ':completion*:default' list-colors   no=0 fi=0 di=0 ln=0 pi=0 so=0 bd=0 cd=0 ex=0
+zstyle ':completion:*' tag-order 'arguments values' options \
+                                 globbed-files directories all-files
 
 # Now we automatically make the definition files autoloaded.