about summary refs log tree commit diff
path: root/Completion/Core
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-02-15 09:07:09 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-02-15 09:07:09 +0000
commite6cc1ece7fed93fd31ca4e7f7726de034ede887c (patch)
tree93087d3edf5eb27836ba9bbdfb687b416fb7c629 /Completion/Core
parentbf990125d18effbf111fd6a30ff5bf90c4c263ae (diff)
downloadzsh-e6cc1ece7fed93fd31ca4e7f7726de034ede887c.tar.gz
zsh-e6cc1ece7fed93fd31ca4e7f7726de034ede887c.tar.xz
zsh-e6cc1ece7fed93fd31ca4e7f7726de034ede887c.zip
zsh-workers/9731
Diffstat (limited to 'Completion/Core')
-rw-r--r--Completion/Core/_approximate2
-rw-r--r--Completion/Core/_files13
-rw-r--r--Completion/Core/_main_complete32
-rw-r--r--Completion/Core/_normal13
-rw-r--r--Completion/Core/_path_files12
-rw-r--r--Completion/Core/_setup5
-rw-r--r--Completion/Core/_tags30
-rw-r--r--Completion/Core/compinit13
8 files changed, 35 insertions, 85 deletions
diff --git a/Completion/Core/_approximate b/Completion/Core/_approximate
index 989eeba11..ac2b69aad 100644
--- a/Completion/Core/_approximate
+++ b/Completion/Core/_approximate
@@ -17,7 +17,7 @@ local curcontext="${curcontext}" oldcontext opm="$compstate[pattern_match]"
 
 oldcontext="$curcontext"
 
-zstyle -s ":completion:${curcontext}:" max-errors cfgacc
+zstyle -s ":completion:${curcontext}:" max-errors cfgacc || cfgacc='2 numeric'
 
 # Get the number of errors to accept.
 
diff --git a/Completion/Core/_files b/Completion/Core/_files
index 821d324d8..1e139bc6b 100644
--- a/Completion/Core/_files
+++ b/Completion/Core/_files
@@ -16,17 +16,14 @@ else
 fi
 (( $opts[(I)-F] )) && hasign=yes
 
-if [[ "$group[2]" = files ]]; then
-  opts=("$opts[@]" "$group[@]")
-  group=()
-fi
+[[ "$group[2]" = files ]] && opts=("$opts[@]" "$group[@]") group=()
 
 ign=()
 
-if zstyle -s ":completion:${curcontext}:all-files" file-patterns tmp &&
-   [[ -n "$tmp" ]]; then
-  aopts=(-g "$tmp")
-fi
+zstyle -s ":completion:${curcontext}:all-files" file-patterns tmp &&
+    [[ -n "$tmp" ]] &&
+        aopts=(-g "$tmp")
+
 if zstyle -s ":completion:${curcontext}:directories" file-patterns tmp &&
    [[ -n "$tmp" ]]; then
   dopts=(-g "$tmp")
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index 2381ae76d..62ba446b0 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -19,7 +19,7 @@
 setopt localoptions nullglob rcexpandparam extendedglob
 unsetopt markdirs globsubst shwordsplit nounset ksharrays
 
-local comp post ret=1 _compskip _prio_num=1 format _comp_ignore \
+local comp post ret=1 _compskip format _comp_ignore \
       _completers _completers_left _comp_matcher \
       context state line opt_args val_args curcontext="$curcontext" \
       _last_nmatches=-1 _last_menu_style _def_menu_style _menu_style sel \
@@ -28,12 +28,6 @@ local comp post ret=1 _compskip _prio_num=1 format _comp_ignore \
       _saved_list="${compstate[list]}" \
       _saved_insert="${compstate[insert]}"
 
-typeset -U _offered_tags _tried_tags _failed_tags _used_tags _unused_tags
-
-_offered_tags=()
-_tried_tags=()
-_failed_tags=()
-
 typeset -U _lastdescr
 
 [[ -z "$curcontext" ]] && curcontext=:::
@@ -50,17 +44,13 @@ fi
 # Initial setup.
 
 _setup default
-_def_menu_style=( "$_last_menu_style[@]" )
+_def_menu_style=( "$_last_menu_style[@]"
+                  ${SELECTMIN+select${SELECTMIN:+\=$SELECTMIN}} )
 _last_menu_style=()
 
 # Get the names of the completers to use in the positional parameters.
 
-if (( ! $# )); then
-  local tmp
-
-  zstyle -a ":completion:${curcontext}:" completer tmp
-  set -- "$tmp[@]"
-fi
+(( $# )) || zstyle -a ":completion:${curcontext}:" completer argv || set _complete
 
 # And now just call the completer functions defined.
 
@@ -75,7 +65,7 @@ for comp; do
   shift 1 _completers_left
 done
 
-if (( $compstate[nmatches] )); then
+if [[ $compstate[nmatches] -gt 1 ]]; then
   [[ _last_nmatches -ge 0 && _last_nmatches -ne compstate[nmatches] ]] &&
       _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" )
 
@@ -128,7 +118,7 @@ if (( $compstate[nmatches] )); then
       fi
     fi
   fi
-elif [[ $#_lastdescr -ne 0 ]] &&
+elif [[ $compstate[nmatches] -eq 0 && $#_lastdescr -ne 0 ]] &&
      zstyle -s ":completion:${curcontext}:warnings" format format; then
   local str
 
@@ -147,11 +137,6 @@ elif [[ $#_lastdescr -ne 0 ]] &&
   compadd -UX "$format" -n ''
 fi
 
-# See which tags were or were not used.
-
-_used_tags=( "${(@)_tried_tags:#${(j:|:)~${(@)_failed_tags//\[/\\[}//\]/\\]}}" )
-_unused_tags=( "${(@)_offered_tags:#${(j:|:)~${(@)_used_tags//\[/\\[}//\]/\\]}}" )
-
 # Now call the post-functions.
 
 for post in "$comppostfuncs[@]"; do
@@ -167,10 +152,5 @@ _lastcomp[iprefix]="$IPREFIX"
 _lastcomp[isuffix]="$ISUFFIX"
 _lastcomp[qiprefix]="$QIPREFIX"
 _lastcomp[qisuffix]="$QISUFFIX"
-_lastcomp[offered_tags]="${(j.:.)_offered_tags}"
-_lastcomp[tried_tags]="${(j.:.)_tried_tags}"
-_lastcomp[failed_tags]="${(j.:.)_failed_tags}"
-_lastcomp[unused_tags]="${(j.:.)_unused_tags}"
-_lastcomp[used_tags]="${(j.:.)_used_tags}"
 
 return ret
diff --git a/Completion/Core/_normal b/Completion/Core/_normal
index c3315610f..1791d2471 100644
--- a/Completion/Core/_normal
+++ b/Completion/Core/_normal
@@ -66,10 +66,7 @@ fi
 name="$cmd1"
 comp="$_comps[$cmd1]"
 
-if [[ -z "$comp" ]]; then
-  name="$cmd2"
-  comp="$_comps[$cmd2]"
-fi
+[[ -z "$comp" ]] && name="$cmd2" comp="$_comps[$cmd2]"
 
 # And generate the matches, probably using default completion.
 
@@ -77,11 +74,9 @@ if [[ -n "$comp" ]]; then
   _compskip=patterns
   "$comp" && ret=0
   [[ "$_compskip" = (all|*patterns*) ]] && return ret
-else
-  if [[ "$_compskip" != *default* ]]; then
-    name=-default-
-    comp="$_comps[-default-]"
-  fi
+elif [[ "$_compskip" != *default* ]]; then
+  name=-default-
+  comp="$_comps[-default-]"
 fi
 
 if [[ "$_compskip" != (all|*patterns*) ]]; then
diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files
index 07e75052f..62c52e3c4 100644
--- a/Completion/Core/_path_files
+++ b/Completion/Core/_path_files
@@ -290,7 +290,7 @@ for prepath in "$prepaths[@]"; do
         tmp2=( "$tmp1[@]" )
         builtin compadd -D tmp1 -F _comp_ignore "$matcher[@]" - "${(@)tmp1:t}"
 
-        if [[ $#tmp1 -eq 0 && -n "$_comp_correct" ]]; then
+        if [[ $#tmp1 -eq 0 ]]; then
           tmp1=( "$tmp2[@]" )
 	  compadd -D tmp1 -F _comp_ignore "$matcher[@]" - "${(@)tmp2:t}"
         fi
@@ -334,7 +334,7 @@ for prepath in "$prepaths[@]"; do
 
       if [[ -z "$tpre$tsuf" && -n "$pre$suf" ]]; then
 	pfxsfx=(-S '' "$pfxsfx[@]")
-	break;
+	break
       elif [[ "$haspats" = no && -z "$tpre$tsuf" &&
 	"$pre" = */ && -z "$suf" ]]; then
 	PREFIX="${opre}"
@@ -352,8 +352,8 @@ for prepath in "$prepaths[@]"; do
       if [[ "$rem" = *parent* ]]; then
 	for i in ${(M)^tmp1:#*/*}(-/); do
 	  remt="${${i#$prepath$realpath$donepath}%/*}"
-	  while [[ "$remt" = */* ]]; do
-	    [[ "$prepath$realpath$donepath$remt" -ef "$i" ]] && break
+	  while [[ "$remt" = */* &&
+	           ! "$prepath$realpath$donepath$remt" -ef "$i" ]]; do
 	    remt="${remt%/*}"
 	  done
 	  [[ "$remt" = */* || "$remt" -ef "$i" ]] &&
@@ -406,9 +406,7 @@ for prepath in "$prepaths[@]"; do
 
     if [[ "$tmp3" = */* ]]; then
       tmp4=( "${(@M)tmp1:#${tmp3%%/*}/*}" )
-      if (( $#tmp4 )); then
-        tmp1=( "$tmp4[@]" )
-      fi
+      (( $#tmp4 )) && tmp1=( "$tmp4[@]" )
     fi
 
     # Next we see if this component is ambiguous.
diff --git a/Completion/Core/_setup b/Completion/Core/_setup
index b3b2bdb33..4c45cc271 100644
--- a/Completion/Core/_setup
+++ b/Completion/Core/_setup
@@ -3,12 +3,15 @@
 local val nm="$compstate[nmatches]"
 
 if zstyle -a ":completion:${curcontext}:$1" list-colors val; then
-  zmodload -e zsh/complist || zmodload -i zsh/complist
+  zmodload -i zsh/complist
   if [[ "$1" = default ]]; then
     ZLS_COLORS="${(j.:.)${(@)val:gs/:/\\\:}}"
   else
     eval "ZLS_COLORS=\"(${1})\${(j.:(${1}).)\${(@)val:gs/:/\\\:}}:\${ZLS_COLORS}\""
   fi
+elif [[ "$1" = default && -n "$ZLS_COLORS$ZLS_COLOURS" ]]; then
+  zmodload -i zsh/complist
+  ZLS_COLORS="$ZLS_COLORS$ZLS_COLOURS"
 fi
 
 if zstyle -s ":completion:${curcontext}:$1" list-packed val; then
diff --git a/Completion/Core/_tags b/Completion/Core/_tags
index d2d5555fa..1884717e2 100644
--- a/Completion/Core/_tags
+++ b/Completion/Core/_tags
@@ -35,9 +35,6 @@ if (( $# )); then
 
   comptags -i "$curcontext" "$@"
 
-  _offered_tags=( "$_offered_tags[@]" "$@" )
-  _last_tags=()
-
   # Sort the tags.
 
   if [[ -n "$_sort_tags" ]]; then
@@ -55,6 +52,15 @@ if (( $# )); then
 
     [[ -z "$nodef" ]] && comptry "$@"
   else
+
+    # The first ones give the default behaviour.
+
+    comptry arguments values
+    comptry options
+    comptry globbed-files
+    comptry directories
+    comptry all-files
+
     comptry "$@"
   fi
 
@@ -67,20 +73,4 @@ fi
 
 # The other mode: switch to the next set of tags.
 
-local tags
-
-_failed_tags=( "$_failed_tags[@]" "$_last_tags[@]" )
-
-# Return failure if no sets remaining.
-
-comptags -N || return 1
-
-# Otherwise get the next tags.
-
-comptags -S _last_tags
-
-_tried_tags=( "$_tried_tags[@]" "$_last_tags[@]" )
-
-shift 1 "$prios"
-
-return 0
+comptags -N
diff --git a/Completion/Core/compinit b/Completion/Core/compinit
index cd9ec7c2f..1555a9b2f 100644
--- a/Completion/Core/compinit
+++ b/Completion/Core/compinit
@@ -470,19 +470,6 @@ compstyle() {
   return 0
 }
 
-# Default styles. This should be executed conditionally somehow.
-
-zstyle ':completion:*'                      verbose       'yes'
-zstyle ':completion:*'                      prefix-needed 'yes'
-zstyle ':completion:*'                      prefix-hidden 'no'
-zstyle ':completion:*:(correct|approximate):*' max-errors    '2' numeric
-zstyle ':completion:*:correct:*'               prompt        'correct to:'
-zstyle ':completion:*::::'                      completer     '_complete'
-zstyle ':completion:*::::default'               list-colors   "${(s.:.)ZLS_COLORS:-${ZLS_COLOURS:-no=0:fi=0:di=0:ln=0:pi=0:so=0:bd=0:cd=0:ex=0}}"
-(( $+SELECTMIN )) && zstyle ':completion:*::::default' menu "select=$SELECTMIN"
-zstyle ':completion:*' tag-order 'arguments values' options \
-                                 globbed-files directories all-files
-
 # Now we automatically make the definition files autoloaded.
 
 typeset -U _i_files