From 828dbe71c85bd64e179c63a04c71d0baa9ed714c Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Wed, 8 Dec 1999 14:11:04 +0000 Subject: manual/8944 --- Completion/Core/_main_complete | 66 +++++++++++++++++++++++++++++++++++++++--- Completion/Core/_setup | 12 +++++++- 2 files changed, 73 insertions(+), 5 deletions(-) (limited to 'Completion') 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 -- cgit 1.4.1