From fc95f1a465638327704ba1bf28413b72c6a4226e Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Thu, 10 Feb 2000 14:52:33 +0000 Subject: zsh-workers/9657 --- Completion/Core/_approximate | 4 +++- Completion/Core/_description | 2 ++ Completion/Core/_main_complete | 2 +- Completion/Core/_matcher | 5 +++++ Completion/Core/_path_files | 29 +++++++++-------------------- Completion/Core/_prefix | 8 +++++++- 6 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 Completion/Core/_matcher (limited to 'Completion/Core') diff --git a/Completion/Core/_approximate b/Completion/Core/_approximate index 283f30e83..ef6e5b91d 100644 --- a/Completion/Core/_approximate +++ b/Completion/Core/_approximate @@ -6,7 +6,7 @@ # or get the corrected prefix. local _comp_correct _correct_expl comax cfgacc -local curcontext="${curcontext}" oldcontext +local curcontext="${curcontext}" oldcontext opm="$compstate[pattern_match]" # Only if all global matchers have been tried. @@ -100,6 +100,7 @@ while [[ _comp_correct -le comax ]]; do fi compstate[matcher]="$compstate[total_matchers]" unfunction compadd + compstate[pattern_match]="$opm" return 0 fi @@ -110,5 +111,6 @@ done compstate[matcher]="$compstate[total_matchers]" unfunction compadd +compstate[pattern_match]="$opm" return 1 diff --git a/Completion/Core/_description b/Completion/Core/_description index 06b54e807..970ee8f6a 100644 --- a/Completion/Core/_description +++ b/Completion/Core/_description @@ -27,6 +27,8 @@ zstyle -s ":completion:${curcontext}:$1" group-name gname && [[ -z "$gname" ]] && gname="$1" zstyle -s ":completion:${curcontext}:$1" matcher match && opts=($opts -M "${(q)match}") +[[ -n "$_comp_matcher" ]] && opts=($opts -M "${(q)_comp_matcher}") + if zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore; then opts=( $opts -F _comp_ignore) else diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete index a6714cea6..33a492bae 100644 --- a/Completion/Core/_main_complete +++ b/Completion/Core/_main_complete @@ -20,7 +20,7 @@ setopt localoptions nullglob rcexpandparam extendedglob unsetopt markdirs globsubst shwordsplit nounset ksharrays local comp post ret=1 _compskip _prio_num=1 format _comp_ignore \ - _completers _completers_left \ + _completers _completers_left _comp_matcher \ 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]}" \ diff --git a/Completion/Core/_matcher b/Completion/Core/_matcher new file mode 100644 index 000000000..6c0398e7b --- /dev/null +++ b/Completion/Core/_matcher @@ -0,0 +1,5 @@ +#autoload + +zstyle -s ":completion:${curcontext%%:*}:matcher-${(M)#${(@)_completers[1,-$#_completers_left]}:#_matcher}:${curcontext#[^:]#:[^:]#:}:" matcher _comp_matcher || _comp_matcher='' + +return 1 diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files index 0ec311c64..5ff8d7dd5 100644 --- a/Completion/Core/_path_files +++ b/Completion/Core/_path_files @@ -6,7 +6,7 @@ local linepath realpath donepath prepath testpath exppath skips skipped local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre local pats haspats=no ignore pfxsfx rem remt sopt gopt opt -local nm=$compstate[nmatches] menu mspec matcher mopts atmp sort match +local nm=$compstate[nmatches] menu matcher mopts atmp sort match typeset -U prepaths exppaths @@ -54,8 +54,6 @@ if (( $#ignore )); then fi fi -(( $#matcher )) && mspec="${matcher[2]}" - if [[ -z "$_file_pat_checked" ]] && zstyle -s ":completion:${curcontext}:files" file-patterns tmp1 && [[ -n "$tmp1" ]]; then @@ -92,7 +90,6 @@ if (( ! $mopts[(I)-[JVX]] )); then fi tmp1=$expl[(I)-M*] if (( tmp1 )); then - mspec="$mspec $expl[1+tmp1]" if (( $#matcher )); then matcher[2]="$matcher[2] $expl[1+tmp1]" else @@ -452,30 +449,26 @@ for prepath in "$prepaths[@]"; do if [[ "$tmp3" = */* ]]; then compadd -Qf "$mopts[@]" -p "$linepath$tmp2" -s "/${tmp3#*/}" \ -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" \ - -M "r:|/=* r:|=* $mspec" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" \ - "${(@)tmp1%%/*}" else compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \ -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" \ - -M "r:|/=* r:|=* $mspec" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" \ - "$tmp1[@]" fi else if [[ "$tmp3" = */* ]]; then atmp=( -Qf "$mopts[@]" -p "$linepath$tmp2" -W "$prepath$realpath$testpath" - "$pfxsfx[@]" \ - -M "r:|/=* r:|=* $mspec" ) + "$pfxsfx[@]" -M "r:|/=* r:|=*" ) for i in "$tmp1[@]"; do compadd "$atmp[@]" -s "/${i#*/}" - "${i%%/*}" done else compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \ - -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" \ - -M "r:|/=* r:|=* $mspec" \ + -W "$prepath$realpath$testpath" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" \ - "$tmp1[@]" fi fi @@ -522,11 +515,8 @@ for prepath in "$prepaths[@]"; do fi tmp4="$testpath" compquote tmp4 tmp1 - compadd -Qf "$mopts[@]" -p "$linepath$tmp4" \ - -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" \ - -M "r:|/=* r:|=* $mspec" \ - - "$tmp1[@]" + compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -W "$prepath$realpath$testpath" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" - "$tmp1[@]" fi done @@ -542,8 +532,7 @@ if zstyle -t ":completion:${curcontext}:paths" expand prefix && if (( $#exppaths )); then PREFIX="${opre}" SUFFIX="${osuf}" - compadd -Q "$mopts[@]" -S '' \ - -M "r:|/=* r:|=* $mspec" -p "$linepath" - "$exppaths[@]" + compadd -Q "$mopts[@]" -S '' -M "r:|/=* r:|=*" -p "$linepath" - "$exppaths[@]" fi fi diff --git a/Completion/Core/_prefix b/Completion/Core/_prefix index 6306b4aa0..34decf425 100644 --- a/Completion/Core/_prefix +++ b/Completion/Core/_prefix @@ -4,7 +4,7 @@ [[ -n "$SUFFIX" ]] || return 1 -local curcontext="${curcontext/:[^:]#:/:prefix:}" comp i +local curcontext="${curcontext/:[^:]#:/:prefix-${(M)#${(@)_completers[1,-$#_completers_left]}:#_prefix}:}" comp i zstyle -a ":completion:${curcontext}:" completer comp || comp=( "${(@)_completers[1,-${#_completers_left}-1][(R)_prefix,-1]}" ) @@ -16,8 +16,14 @@ else fi SUFFIX='' +local _completers _completer_left + +_completers=( "$comp[@]" ) +_completers_left=( "$comp[@]" ) + for i in "$comp[@]"; do [[ "$i" != _prefix ]] && "$i" && return 0 + shift 1 _completers_left done return 1 -- cgit 1.4.1