about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-02-23 10:25:01 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-02-23 10:25:01 +0000
commitaa660233d0382c6c5990e28fb87ef4a367157dc9 (patch)
tree3a4c5bc84ad2ff29fb9c152169117f1eb499c4f7 /Completion
parente0c99aa850ef8cee8451354e0314b9e4c5295f5d (diff)
downloadzsh-aa660233d0382c6c5990e28fb87ef4a367157dc9.tar.gz
zsh-aa660233d0382c6c5990e28fb87ef4a367157dc9.tar.xz
zsh-aa660233d0382c6c5990e28fb87ef4a367157dc9.zip
zsh-workers/9835
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Builtins/_zstyle6
-rw-r--r--Completion/Core/_main_complete32
2 files changed, 26 insertions, 12 deletions
diff --git a/Completion/Builtins/_zstyle b/Completion/Builtins/_zstyle
index 34b424114..10f624ed3 100644
--- a/Completion/Builtins/_zstyle
+++ b/Completion/Builtins/_zstyle
@@ -54,6 +54,7 @@ styles=(
   prefix-needed		 c:bool
   prompt		 c:
   remove-all-dups	 c:bool
+  single-ignored         c:single-ignored
   sort			 c:bool
   tag-order		 c:tag
   special-dirs		 c:sdirs
@@ -208,6 +209,11 @@ while [[ -n $state ]]; do
         compadd "$expl[@]" parent pwd .. directory
       ;;
 
+    single-ignored)
+      _wanted values expl 'how to handle single alternate match' &&
+          compadd "$expl[@]" - show menu
+      ;;
+
     _*)
       ${=ostate}
       ;;
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index fd8d9fcb2..6e472634c 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -97,7 +97,7 @@ if zstyle -s ":completion:${curcontext}:" single-ignored tmp &&
   esac
 fi
 
-if [[ -n "$tmp" || $compstate[nmatches] -gt 1 ]]; then
+if [[ -n "$tmp" || $compstate[nmatches]+$compstate[alternate_nmatches] -gt 1 ]]; then
   [[ _last_nmatches -ge 0 && _last_nmatches -ne compstate[nmatches] ]] &&
       _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" )
 
@@ -146,27 +146,35 @@ if [[ -n "$tmp" || $compstate[nmatches] -gt 1 ]]; then
 	  (( min )) || break
         done
 
+        zmodload -i zsh/complist
         SELECTMIN="$min"
       fi
     fi
   fi
-elif [[ $compstate[nmatches] -eq 0 && $#_lastdescr -ne 0 ]] &&
+elif [[ $compstate[nmatches]+$compstate[alternate_nmatches] -eq 0 &&
+        $#_lastdescr -ne 0 ]] &&
      zstyle -s ":completion:${curcontext}:warnings" format format; then
-  local str
-
-  _lastdescr=( "\`${(@)^_lastdescr:#}'" )
 
   compstate[list]='list force'
   compstate[insert]=''
 
-  case $#_lastdescr in
-  1) str="$_lastdescr[1]";;
-  2) str="$_lastdescr[1] or $_lastdescr[2]";;
-  *) str="${(j:, :)_lastdescr[1,-2]}, or $_lastdescr[-1]";;
-  esac
+  if [[ "$format" = *%d* ]]; then
+    local str mesg
+
+    _lastdescr=( "\`${(@)^_lastdescr:#}'" )
 
-  zformat -f format "$format" "d:$str"
-  compadd -UX "$format" -n ''
+    case $#_lastdescr in
+    1) str="$_lastdescr[1]";;
+    2) str="$_lastdescr[1] or $_lastdescr[2]";;
+    *) str="${(j:, :)_lastdescr[1,-2]}, or $_lastdescr[-1]";;
+    esac
+
+    zformat -f mesg "$format" "d:$str"
+    compadd -UX "$mesg" -n - ''
+  else
+    _setup warnings
+    compadd -UQX "$format" -V warnings - "${(@)_lastdescr:#}"
+  fi
 fi
 
 # Now call the post-functions.