about summary refs log tree commit diff
path: root/Completion/Core
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-03-25 00:21:44 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-03-25 00:21:44 +0000
commitd8f703027345170c7bc820ed7808e693dd1377d6 (patch)
treef9b1b6ad59f19577c0e1c5b6357cb869b4bebfba /Completion/Core
parentd770c43f14ef6e559aa16da1c1408e006bb2a137 (diff)
downloadzsh-d8f703027345170c7bc820ed7808e693dd1377d6.tar.gz
zsh-d8f703027345170c7bc820ed7808e693dd1377d6.tar.xz
zsh-d8f703027345170c7bc820ed7808e693dd1377d6.zip
zsh-3.1.6-dev-20 zsh-3.1.6-dev-20
Diffstat (limited to 'Completion/Core')
-rw-r--r--Completion/Core/.distfiles4
-rw-r--r--Completion/Core/_description5
-rw-r--r--Completion/Core/_main_complete36
-rw-r--r--Completion/Core/_path_files7
-rw-r--r--Completion/Core/_prefix2
-rw-r--r--Completion/Core/_setup2
-rw-r--r--Completion/Core/_tags60
7 files changed, 57 insertions, 59 deletions
diff --git a/Completion/Core/.distfiles b/Completion/Core/.distfiles
index 0c85315fb..237018b27 100644
--- a/Completion/Core/.distfiles
+++ b/Completion/Core/.distfiles
@@ -1,10 +1,10 @@
 DISTFILES_SRC='
     .distfiles
     _alternative _approximate _call _compalso _complete _correct _description
-    _expand _files _funcall _list _main_complete _match
+    _expand _files _funcall _list _loop _main_complete _match
     _menu _multi_parts _message _normal _oldlist _options
     _parameters _path_files _prefix _requested _sep_parts
-    _set_options _setup _sort_tags _tags
+    _set_options _setup _sort_tags _tags _try
     _unset_options _wanted
     compdump compinit compinstall
 '
diff --git a/Completion/Core/_description b/Completion/Core/_description
index 7db47228b..6326d1f03 100644
--- a/Completion/Core/_description
+++ b/Completion/Core/_description
@@ -29,9 +29,8 @@ zstyle -s ":completion:${curcontext}:$1" matcher match &&
     opts=($opts -M "${(q)match}")
 [[ -n "$_matcher" ]] && opts=($opts -M "${(q)_matcher}")
 
-if [[ -z "$_comp_no_ignore" ]] &&
-   zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore; then
-  opts=( $opts -F _comp_ignore )
+if zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore; then
+  opts=( $opts -F _comp_ignore)
 else
   _comp_ignore=()
 fi
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index 49e66cba7..244f06b7e 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 func funcs ret=1 tmp _compskip format _comp_ignore \
+local ctxt func funcs ret=1 tmp _compskip format _comp_ignore \
       _completers _completer _completer_num curtag \
       _matchers _matcher _matcher_num _comp_tags \
       context state line opt_args val_args curcontext="$curcontext" \
@@ -61,8 +61,7 @@ _last_menu_style=()
 
 # Get the names of the completers to use in the positional parameters.
 
-(( $# )) || zstyle -a ":completion:${curcontext}:" completer argv ||
-    set _complete
+(( $# )) || zstyle -a ":completion:${curcontext}:" completer argv || set _complete
 
 # And now just call the completer functions defined.
 
@@ -78,8 +77,14 @@ for func in "$funcs[@]"; do
 done
 
 for _completer; do
+  ctxt=":completion:${curcontext/::/:${_completer[2,-1]}-${(M)#_completers[1,_completer_num]:#$_completer}:}:"
 
-  zstyle -a ":completion:${curcontext/::/:${_completer[2,-1]}-${(M)#_completers[1,_completer_num]:#$_completer}:}:" matcher-list _matchers ||
+  if zstyle -t "$ctxt" prefer-ignored && (( $compstate[alternate_nmatches] )); then
+    ret=0
+    break;
+  fi
+
+  zstyle -a "$ctxt" matcher-list _matchers ||
       _matchers=( '' )
 
   _matcher_num=1
@@ -93,9 +98,26 @@ for _completer; do
   (( _completer_num++ ))
 done
 
+if zstyle -s ":completion:${curcontext}:" single-ignored tmp &&
+   [[ $compstate[old_list] != shown &&
+      $compstate[alternate_nmatches] = 1 ]]; then
+  case "$tmp" in
+  show) compstate[insert]='' compstate[list]='list force' tmp='' ;;
+  menu)
+    local expl
+
+    compstate[insert]='menu'
+    _description original expl original    
+    compadd "$expl[@]" -a -S '' - "$PREFIX$SUFFIX"
+    ;;
+  *) tmp='' ;;
+  esac
+fi
+
 if [[ -n "$tmp" || $compstate[old_list] = keep ||
-      $compstate[nmatches] -gt 1 ]]; then
-  [[ _last_nmatches -ge 0 && _last_nmatches -ne $compstate[nmatches] ]] &&
+      $compstate[nmatches]+$compstate[alternate_nmatches] -gt 1 ]]; then
+  [[ _last_nmatches -ge 0 &&
+     _last_nmatches -ne $compstate[nmatches]+$compstate[alternate_nmatches] ]] &&
       _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" )
 
   if [[ "$compstate[insert]" = "$_saved_insert" ]]; then
@@ -148,7 +170,7 @@ if [[ -n "$tmp" || $compstate[old_list] = keep ||
       fi
     fi
   fi
-elif [[ $compstate[nmatches] -eq 0 &&
+elif [[ $compstate[nmatches]+$compstate[alternate_nmatches] -eq 0 &&
         $#_lastdescr -ne 0 && $compstate[old_list] != keep ]] &&
      zstyle -s ":completion:${curcontext}:warnings" format format; then
 
diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files
index 11445c204..d5feaa540 100644
--- a/Completion/Core/_path_files
+++ b/Completion/Core/_path_files
@@ -142,9 +142,8 @@ eorig="$orig"
 
 # If given no `-F' option, we may want to use $fignore, turned into patterns.
 
-[[ -z "$_comp_no_ignore" && $#ignore -eq 0 &&
-   ( -z $gopt || "$pats" = \ #\*\ # ) && -n $FIGNORE ]] && 
-    ignore=( "?*${^fignore[@]}" )
+[[ $#ignore -eq 0 && ( -z $gopt || "$pats" = \ #\*\ # ) && -n $FIGNORE ]] && 
+   ignore=( "?*${^fignore[@]}" )
 
 if (( $#ignore )); then
   _comp_ignore=( "$_comp_ignore[@]" "$ignore[@]" )
@@ -351,7 +350,7 @@ for prepath in "$prepaths[@]"; do
       continue 2
     fi
 
-    if [[ -z "$_comp_no_ignore" && "$tpre$tsuf" != */* && $#tmp1 -ne 0 ]] &&
+    if [[ "$tpre$tsuf" != */* && $#tmp1 -ne 0 ]] &&
        zstyle -s ":completion:${curcontext}:files" ignore-parents rem &&
        [[ ( "$rem" != *dir* || "$pats" = '*(-/)' ) &&
 	  ( "$rem" != *..* || "$tmp1" = *../* ) ]]; then
diff --git a/Completion/Core/_prefix b/Completion/Core/_prefix
index 32ffaea2f..ed95140bd 100644
--- a/Completion/Core/_prefix
+++ b/Completion/Core/_prefix
@@ -7,7 +7,7 @@
 local curcontext="${curcontext/:[^:]#:/:prefix-${(M)#_completers[1,_completer_num]:#_prefix}:}" comp i
 
 zstyle -a ":completion:${curcontext}:" completer comp ||
-  comp=( "${(@)_completers[1,_completer_num-1][(R)_prefix,-1]}" )
+  comp=( "${(@)_completers[1,_completer_num][(R)_prefix,-1]}" )
 
 if zstyle -t ":completion:${curcontext}:" add-space; then
   ISUFFIX=" $SUFFIX"
diff --git a/Completion/Core/_setup b/Completion/Core/_setup
index ed7307e69..0b9e5d0a9 100644
--- a/Completion/Core/_setup
+++ b/Completion/Core/_setup
@@ -54,7 +54,7 @@ fi
     _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" )
 
 if zstyle -a ":completion:${curcontext}:$1" menu val; then
-  _last_nmatches=$nm
+  _last_nmatches=$(( $nm + $compstate[alternate_nmatches] ))
   _last_menu_style=( "$val[@]" )
 else
   _last_nmatches=-1
diff --git a/Completion/Core/_tags b/Completion/Core/_tags
index a617776d4..2dfa56f9d 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 tmp tmp2 tmp3 als atag
+  local curcontext="$curcontext" order tag nodef
 
   if [[ "$1" = -C?* ]]; then
     curcontext="${curcontext%:*}:${1[3,-1]}"
@@ -51,13 +51,7 @@ if (( $# )); then
 
   if [[ -n "$_sort_tags" ]]; then
     "$_sort_tags" "$@"
-  else
-    zstyle -a ":completion:${curcontext}:" tag-order order ||
-      if [[ "$*" = *(arguments|values)* || "$*" = *options* ]] ;then
-        order=( 'arguments values' options )
-      else
-        order=()
-      fi
+  elif zstyle -a ":completion:${curcontext}:" tag-order order; then
 
     for tag in $order; do
       case $tag in
@@ -67,49 +61,33 @@ if (( $# )); then
                break
              fi
              ;;
-      \!*)   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[@]"
-	     ;;
+      \!*)   comptry "${(@)argv:#(${(j:|:)~${=tag[2,-1]}})}";;
+      ?*)    comptry ${${(ps: :)${tag//\\\\ /$'\0'}}//$'\0'/ };;
       esac
     done
 
     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
+          comptry "$tag"
         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[@]"
+        comptry "$@"
       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.