about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-06-27 15:05:33 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-06-27 15:05:33 +0000
commit9eca7fc7261494760c1709189e93a044c3658a84 (patch)
treea56e919b98c3c787d546edbb3ad788cb22299b5e /Completion
parentc8812bb0c830f595bad769f47f6d3cf07ee4ebf8 (diff)
downloadzsh-9eca7fc7261494760c1709189e93a044c3658a84.tar.gz
zsh-9eca7fc7261494760c1709189e93a044c3658a84.tar.xz
zsh-9eca7fc7261494760c1709189e93a044c3658a84.zip
menu style accepts yes=x to start menu completion if there are at least x matches (3219)
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Core/_main_complete50
1 files changed, 29 insertions, 21 deletions
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index f238c88ac..690192020 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -23,7 +23,7 @@ exec </dev/null	# ZLE closes stdin, which can cause errors
 # Failed returns from this code are not real errors
 setopt localtraps noerrexit ; trap - ZERR
 
-local func funcs ret=1 tmp _compskip format nm call match \
+local func funcs ret=1 tmp _compskip format nm call match min i num\
       _completers _completer _completer_num curtag _comp_force_list \
       _matchers _matcher _matcher_num _comp_tags _comp_mesg \
       context state line opt_args val_args curcontext="$curcontext" \
@@ -175,24 +175,33 @@ if [[ $compstate[old_list] = keep || nm -gt 1 ]]; then
   elif [[ "$compstate[insert]" = "$_saved_insert" ]]; then
     if [[ -n "$_menu_style[(r)select=long]" && tmp -gt LINES ]]; then
         compstate[insert]=menu
-    elif [[ -n "$_menu_style[(r)(yes|true|1|on)]" ||
-          ( -n "$_menu_style[(r)auto*]" &&
-            "$compstate[insert]" = automenu ) ]]; then
-      compstate[insert]=menu
-    elif [[ -n "$_menu_style[(r)auto*]" &&
-            "$compstate[insert]" != automenu ]]; then
-      compstate[insert]=automenu-unambiguous
-    elif [[ -n "$_menu_style[(r)(no|false|0|off)]" ]]; then
-      compstate[insert]=unambiguous
-    elif [[ -n "$_def_menu_style[(r)(yes|true|1|on)]" ||
-          ( -n "$_def_menu_style[(r)auto*]" &&
-            "$compstate[insert]" = automenu ) ]]; then
-      compstate[insert]=menu
-    elif [[ -n "$_def_menu_style[(r)auto*]" &&
-            "$compstate[insert]" != automenu ]]; then
-      compstate[insert]=automenu-unambiguous
-    elif [[ -n "$_def_menu_style[(r)(no|false|0|off)]" ]]; then
-      compstate[insert]=unambiguous
+    else
+      sel=( "${(@M)_menu_style:#(yes|true|1|on)*}" )
+
+      if (( $#sel )); then
+	min=9999999
+        for i in "$sel[@]"; do
+          if [[ "$i" = *\=* ]]; then
+  	    num="${i#*\=}"
+  	    [[ num -lt 0 ]] && num=0
+  	  else
+  	    num=0
+  	  fi
+  	  [[ num -lt min ]] && min="$num"
+  
+	  (( min )) || break
+        done
+      fi
+      if [[ ( -n "$min" && nm -ge min ) ||
+            ( -n "$_menu_style[(r)auto*]" &&
+              "$compstate[insert]" = automenu ) ]]; then
+        compstate[insert]=menu
+      elif [[ -n "$_menu_style[(r)auto*]" &&
+              "$compstate[insert]" != automenu ]]; then
+        compstate[insert]=automenu-unambiguous
+      elif [[ -n "$_menu_style[(r)(no|false|0|off)]" ]]; then
+        compstate[insert]=unambiguous
+      fi
     fi
   fi
 
@@ -209,8 +218,7 @@ if [[ $compstate[old_list] = keep || nm -gt 1 ]]; then
       sel=( "${(@M)_menu_style:#select*}" )
 
       if (( $#sel )); then
-        local min=9999999 i num
-
+	min=9999999
         for i in "$sel[@]"; do
           if [[ "$i" = *\=* ]]; then
   	    num="${i#*\=}"