From 3076ed44d33ac699b306824214951c436c4a7a4e Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Fri, 11 Feb 2000 11:14:51 +0000 Subject: zsh-workers/9677 --- Completion/Core/_approximate | 15 ----------- Completion/Core/_expand | 4 --- Completion/Core/_main_complete | 57 +++++++++++++++++++----------------------- Completion/Core/_match | 10 ++------ 4 files changed, 28 insertions(+), 58 deletions(-) (limited to 'Completion/Core') diff --git a/Completion/Core/_approximate b/Completion/Core/_approximate index ef6e5b91d..989eeba11 100644 --- a/Completion/Core/_approximate +++ b/Completion/Core/_approximate @@ -8,10 +8,6 @@ local _comp_correct _correct_expl comax cfgacc local curcontext="${curcontext}" oldcontext opm="$compstate[pattern_match]" -# Only if all global matchers have been tried. - -[[ compstate[matcher] -ne compstate[total_matchers] ]] && return 1 - # We don't try correction if the string is too short. [[ "${#:-$PREFIX$SUFFIX}" -le 1 ]] && return 1 @@ -60,16 +56,7 @@ compadd() { builtin compadd "$_correct_expl[@]" "$@" } -# Now initialise our counter. We also set `compstate[matcher]' -# to `-1'. This allows completion functions to use the simple -# `[[ compstate[matcher] -gt 1 ]] && return' to avoid being -# called for multiple global match specs and still be called -# again when correction is done. Also, this makes it easy to -# test if correction is attempted since `compstate[matcher]' -# will never be set to a negative value by the completion code. - _comp_correct=1 -compstate[matcher]=-1 [[ -z "$compstate[pattern_match]" ]] && compstate[pattern_match]='*' @@ -98,7 +85,6 @@ while [[ _comp_correct -le comax ]]; do [[ "$compstate[list]" != list* ]] && compstate[list]="$compstate[list] force" fi - compstate[matcher]="$compstate[total_matchers]" unfunction compadd compstate[pattern_match]="$opm" @@ -109,7 +95,6 @@ while [[ _comp_correct -le comax ]]; do (( _comp_correct++ )) done -compstate[matcher]="$compstate[total_matchers]" unfunction compadd compstate[pattern_match]="$opm" diff --git a/Completion/Core/_expand b/Completion/Core/_expand index b1609ad40..e92c7966b 100644 --- a/Completion/Core/_expand +++ b/Completion/Core/_expand @@ -18,10 +18,6 @@ if zstyle -s ":completion:${curcontext}:" completions expr && return 1 fi -# Do this only for the first global matcher. - -[[ "$compstate[matcher]" -le 1 ]] || return 1 - # In exp we will collect the expansion. exp=("$word") diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete index 33a492bae..2381ae76d 100644 --- a/Completion/Core/_main_complete +++ b/Completion/Core/_main_complete @@ -128,8 +128,7 @@ if (( $compstate[nmatches] )); then fi fi fi -elif [[ compstate[matcher] -eq compstate[total_matchers] && - $#_lastdescr -ne 0 ]] && +elif [[ $#_lastdescr -ne 0 ]] && zstyle -s ":completion:${curcontext}:warnings" format format; then local str @@ -148,34 +147,30 @@ elif [[ compstate[matcher] -eq compstate[total_matchers] && compadd -UX "$format" -n '' fi -if [[ compstate[matcher] -eq compstate[total_matchers] || - compstate[nmatches] -ne 0 ]]; then - - # See which tags were or were not used. - - _used_tags=( "${(@)_tried_tags:#${(j:|:)~${(@)_failed_tags//\[/\\[}//\]/\\]}}" ) - _unused_tags=( "${(@)_offered_tags:#${(j:|:)~${(@)_used_tags//\[/\\[}//\]/\\]}}" ) - - # Now call the post-functions. - - for post in "$comppostfuncs[@]"; do - "$post" - done - comppostfuncs=() - - _lastcomp=( "${(@kv)compstate}" ) - _lastcomp[completer]="$comp" - _lastcomp[prefix]="$PREFIX" - _lastcomp[suffix]="$SUFFIX" - _lastcomp[iprefix]="$IPREFIX" - _lastcomp[isuffix]="$ISUFFIX" - _lastcomp[qiprefix]="$QIPREFIX" - _lastcomp[qisuffix]="$QISUFFIX" - _lastcomp[offered_tags]="${(j.:.)_offered_tags}" - _lastcomp[tried_tags]="${(j.:.)_tried_tags}" - _lastcomp[failed_tags]="${(j.:.)_failed_tags}" - _lastcomp[unused_tags]="${(j.:.)_unused_tags}" - _lastcomp[used_tags]="${(j.:.)_used_tags}" -fi +# See which tags were or were not used. + +_used_tags=( "${(@)_tried_tags:#${(j:|:)~${(@)_failed_tags//\[/\\[}//\]/\\]}}" ) +_unused_tags=( "${(@)_offered_tags:#${(j:|:)~${(@)_used_tags//\[/\\[}//\]/\\]}}" ) + +# Now call the post-functions. + +for post in "$comppostfuncs[@]"; do + "$post" +done +comppostfuncs=() + +_lastcomp=( "${(@kv)compstate}" ) +_lastcomp[completer]="$comp" +_lastcomp[prefix]="$PREFIX" +_lastcomp[suffix]="$SUFFIX" +_lastcomp[iprefix]="$IPREFIX" +_lastcomp[isuffix]="$ISUFFIX" +_lastcomp[qiprefix]="$QIPREFIX" +_lastcomp[qisuffix]="$QISUFFIX" +_lastcomp[offered_tags]="${(j.:.)_offered_tags}" +_lastcomp[tried_tags]="${(j.:.)_tried_tags}" +_lastcomp[failed_tags]="${(j.:.)_failed_tags}" +_lastcomp[unused_tags]="${(j.:.)_unused_tags}" +_lastcomp[used_tags]="${(j.:.)_used_tags}" return ret diff --git a/Completion/Core/_match b/Completion/Core/_match index 42416242d..ad481f23b 100644 --- a/Completion/Core/_match +++ b/Completion/Core/_match @@ -12,12 +12,10 @@ local tmp opm="$compstate[pattern_match]" ret=0 orig ins local curcontext="${curcontext/:[^:]#:/:match:}" -# Do nothing if we don't have a pattern or there are still global -# match specifications to try. +# Do nothing if we don't have a pattern. tmp="${${:-$PREFIX$SUFFIX}#[~=]}" -[[ "$tmp:q" = "$tmp" || - compstate[matcher] -ne compstate[total_matchers] ]] && return 1 +[[ "$tmp:q" = "$tmp" ]] && return 1 zstyle -s ":completion:${curcontext}:" original orig zstyle -b ":completion:${curcontext}:" insert-unambiguous ins @@ -25,11 +23,9 @@ zstyle -b ":completion:${curcontext}:" insert-unambiguous ins # Try completion without inserting a `*'? if [[ -n "$orig" ]]; then - compstate[matcher]=-1 compstate[pattern_match]='-' _complete && ret=1 compstate[pattern_match]="$opm" - compstate[matcher]="$compstate[total_matchers]" if (( ret )); then [[ "$ins" = yes && @@ -43,11 +39,9 @@ fi [[ "$orig" = only ]] && return 1 -compstate[matcher]=-1 compstate[pattern_match]='*' _complete && ret=1 compstate[pattern_match]="$opm" -compstate[matcher]="$compstate[total_matchers]" [[ ret -eq 1 && "$ins" = yes && $#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] && -- cgit 1.4.1