about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Completion/Core/_main_complete66
-rw-r--r--Completion/Core/_setup12
-rw-r--r--Doc/Zsh/compsys.yo26
-rw-r--r--Doc/Zsh/mod_complist.yo5
4 files changed, 103 insertions, 6 deletions
diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete
index f8ef78753..3542876f5 100644
--- a/Completion/Core/_main_complete
+++ b/Completion/Core/_main_complete
@@ -17,11 +17,14 @@
 # state than the global one for which you are completing.
 
 
-local comp post ret=1 _compskip _prio_num=1 _cur_context format
-local context state line opt_args val_args curcontext="$curcontext"
-local _saved_exact="$compstate[exact]" \
+local comp post ret=1 _compskip _prio_num=1 _cur_context format \
+      context state line opt_args val_args curcontext="$curcontext" \
+      _last_nmatches=-1 _last_menu_style _def_menu_style _menu_style sel \
+      _saved_exact="$compstate[exact]" \
       _saved_lastprompt="$compstate[last_prompt]" \
-      _saved_list="$compstate[list]"
+      _saved_list="$compstate[list]" \
+      _saved_insert="$compstate[insert]"
+
 typeset -U _offered_tags _tried_tags _failed_tags _used_tags _unused_tags
 
 _offered_tags=()
@@ -45,6 +48,8 @@ fi
 # Initial setup.
 
 _setup default
+_def_menu_style=( "$_last_menu_style[@]" )
+_last_menu_style=()
 
 # Get the names of the completers to use in the positional parameters.
 
@@ -78,6 +83,59 @@ comppostfuncs=()
 
 _lastdescr=( "\`${(@)^_lastdescr:#}'" )
 
+[[ _last_nmatches -ge 0 && _last_nmatches -ne compstate[nmatches] ]] &&
+    _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" )
+
+if [[ "$compstate[insert]" = "$_saved_insert" ]]; then
+  if [[ -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
+  fi
+fi
+
+_menu_style=( "$_menu_style[@]" "$_def_menu_style[@]" )
+
+if [[ "$compstate[insert]" = *menu ]]; then
+  if [[ -n "$_menu_style[(r)no-select*]" ]]; then
+    unset SELECTMIN
+  else
+    sel=( "${(@M)_menu_style:#select*}" )
+
+    if (( $# )); then
+      local min=9999999 i num
+
+      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
+
+      SELECTMIN="$min"
+    fi
+  fi
+fi
+
 _style -s warnings format format
 
 if [[ compstate[nmatches] -eq 0 &&
diff --git a/Completion/Core/_setup b/Completion/Core/_setup
index dfd1b4127..bdef1bf8e 100644
--- a/Completion/Core/_setup
+++ b/Completion/Core/_setup
@@ -1,6 +1,6 @@
 #autoload
 
-local val
+local val nm="$compstate[nmatches]"
 
 if _style -a "$1" list-colors val; then
   if [[ "$1" = default ]]; then
@@ -49,3 +49,13 @@ if _style -s "$1" accept-exact val; then
 else
   compstate[exact]="$_saved_exact"
 fi
+
+[[ _last_nmatches -ge 0 && _last_nmatches -ne nm ]] &&
+    _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" )
+
+if _style -a "$1" menu val; then
+  _last_nmatches="$nm"
+  _last_menu_style=( "$val[@]" )
+else
+  _last_nmatches=-1
+fi
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 30c80d8ef..7054f8a27 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -1075,7 +1075,31 @@ correcting completion with two errors will usually be performed, but if a
 numeric argument is given, correcting completion will not be performed.
 )
 item(tt(menu))(
-This is used by the tt(_oldlist) completer. It controls how menu
+This style is tested for the tt(default) tag and the tags used when
+adding matches. The value should be one of the `true' values (tt(yes), 
+tt(true), tt(1), or tt(on)) if menu completion should be started when
+matches for the given tag (or always in case of the tt(default) tag)
+are generated. If none of these values is defined for any of the tags
+used, but for at least one of these tags the value is the string
+tt(auto), this says that the same behavior as for the tt(AUTO_MENU)
+options should be used. Finally, if menu-completion is started by some 
+other means (e.g. by setting the tt(MENU_COMPLETE) option) and the
+value for one of the tags used is `false' (i.e. tt(no), tt(false),
+tt(0), or tt(off)), then menu-completion will em(not) be started for
+this completions. Note that the values defined for normal tags
+override the value set for the tt(default) tag.
+
+Either instead of or in addition to one of the values above, the value
+for this style may also contain the string tt(select), optionally
+followed by an equal sign and a number. In this case menu-selection
+(as defined by the tt(computil) module) will be started. Without the
+optional number, it will be started unconditionally and with a number
+it will be started only if at least that many matches are generated
+(if the values for more than one tag defines such a number, the
+smallest one is taken). Starting menu-selection can explicitly be
+turned off by defining a value containing the string tt(no-select).
+
+This is also used by the tt(_oldlist) completer. Here it controls how menu
 completion behaves when a completion has already been inserted and the
 user types a standard completion key type such as tt(TAB). The default
 behaviour of tt(_oldlist) is that menu completion always continues
diff --git a/Doc/Zsh/mod_complist.yo b/Doc/Zsh/mod_complist.yo
index 1ec77a33d..f04483268 100644
--- a/Doc/Zsh/mod_complist.yo
+++ b/Doc/Zsh/mod_complist.yo
@@ -145,6 +145,11 @@ to one of the options tt(MENU_COMPLETE) or tt(AUTO_MENU) being set.  If
 tt(SELECTMIN) is set, but is 0, 1 or empty, menu selection will always be
 started during an ambiguous menu completion.
 
+When using the shell function based completion system, the
+tt(SELECTMIN) parameter should not be used (like the tt(ZLS_COLORS)
+and tt(ZLS_COLOURS) parameters described above). Instead, the tt(menu) 
+style should be used.
+
 After menu-selection is started, the matches will be listed. The
 matches to insert into the command line can be selected from this
 list. In the list one match is highlighted using the value for tt(ma)