From 8c15ccd08c114ecde068794de0a176dca14716d6 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Mon, 28 Feb 2000 09:22:33 +0000 Subject: zsh-workers/9892 --- Completion/Core/_main_complete | 2 +- Completion/Core/_path_files | 14 ++++--- Completion/Core/compdump | 6 +-- Completion/Core/compinit | 84 ++++++++---------------------------------- 4 files changed, 27 insertions(+), 79 deletions(-) (limited to 'Completion/Core') diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete index a5acb36f7..d019351b9 100644 --- a/Completion/Core/_main_complete +++ b/Completion/Core/_main_complete @@ -106,7 +106,7 @@ fi if [[ -n "$tmp" || $compstate[old_list] = keep || $compstate[nmatches]+$compstate[alternate_nmatches] -gt 1 ]]; then [[ _last_nmatches -ge 0 && - _last_nmatches -ne $compstate[nmatches]+$compstate[alternate_nmatches ]] && + _last_nmatches -ne $compstate[nmatches]+$compstate[alternate_nmatches] ]] && _menu_style=( "$_last_menu_style[@]" "$_menu_style[@]" ) if [[ "$compstate[insert]" = "$_saved_insert" ]]; then diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files index 2452c3c34..bc3a52e5c 100644 --- a/Completion/Core/_path_files +++ b/Completion/Core/_path_files @@ -163,6 +163,8 @@ if (( $#ignore )); then (( $mopts[(I)-F] )) || mopts=( "$mopts[@]" -F _comp_ignore ) fi +(( $#matcher )) && mopts=( "$mopts[@]" "$matcher[@]" ) + # Now let's have a closer look at the string to complete. if [[ "$pre[1]" = \~ ]]; then @@ -458,26 +460,26 @@ for prepath in "$prepaths[@]"; do if [[ "$tmp3" = */* ]]; then compadd -Qf "$mopts[@]" -p "$linepath$tmp2" -s "/${tmp3#*/}" \ -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" \ - "${(@)tmp1%%/*}" else compadd -Qf "$mopts[@]" -p "$linepath$tmp2" \ -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" \ - "$tmp1[@]" fi else if [[ "$tmp3" = */* ]]; then atmp=( -Qf "$mopts[@]" -p "$linepath$tmp2" -W "$prepath$realpath$testpath" - "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" ) + "$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[@]" "$matcher[@]" "r:|/=* r:|=*" \ + "$pfxsfx[@]" -M "r:|/=* r:|=*" \ - "$tmp1[@]" fi fi @@ -525,7 +527,7 @@ for prepath in "$prepaths[@]"; do tmp4="$testpath" compquote tmp4 tmp1 compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -W "$prepath$realpath$testpath" \ - "$pfxsfx[@]" "$matcher[@]" "r:|/=* r:|=*" - "$tmp1[@]" + "$pfxsfx[@]" -M "r:|/=* r:|=*" - "$tmp1[@]" fi done @@ -541,7 +543,7 @@ if zstyle -t ":completion:${curcontext}:paths" expand prefix && if (( $#exppaths )); then PREFIX="${opre}" SUFFIX="${osuf}" - compadd -Q "$mopts[@]" -S '' "$matcher[@]" "r:|/=* r:|=*" -p "$linepath" - "$exppaths[@]" + compadd -Q "$mopts[@]" -S '' -M "r:|/=* r:|=*" -p "$linepath" - "$exppaths[@]" fi fi diff --git a/Completion/Core/compdump b/Completion/Core/compdump index 97a181084..c577747a1 100644 --- a/Completion/Core/compdump +++ b/Completion/Core/compdump @@ -29,19 +29,19 @@ print "#files: $#_d_files" > $_d_file print "_comps=(" >> $_d_file for _d_f in ${(ok)_comps}; do - print -r - "'${_d_f//\'/'\\''}'" "'${_comps[$_d_f]//\'/'\\''}'" + print -r - "${(q)_d_f}" "${(q)_comps[$_d_f]}" done >> $_d_file print ")" >> $_d_file print "\n_patcomps=(" >> $_d_file for _d_f in "${(ok@)_patcomps}"; do - print -r - "'${_d_f//\'/'\\''}'" "'${_patcomps[$_d_f]//\'/'\\''}'" + print -r - "${(q)_d_f}" "${(q)_patcomps[$_d_f]}" done >> $_d_file print ")" >> $_d_file print "\n_postpatcomps=(" >> $_d_file for _d_f in "${(ok@)_postpatcomps}"; do - print -r - "'${_d_f//\'/'\\''}'" "'${_postpatcomps[$_d_f]//\'/'\\''}'" + print -r - "${(q)_d_f}" "${(q)_postpatcomps[$_d_f]}" done >> $_d_file print ")" >> $_d_file diff --git a/Completion/Core/compinit b/Completion/Core/compinit index 1555a9b2f..5aaaea8fe 100644 --- a/Completion/Core/compinit +++ b/Completion/Core/compinit @@ -308,12 +308,16 @@ compconf() { Hello -\`compconf' will be removed in the near future. The \`styles' form of -your setup should be available in the file: +\`compconf' will be removed in the near future, we now use a more +general (and powerful) mechanism using the \`zstyle' builtin. An +approximation to your old setup using \`zstyle' should be available +in the file: \`${HOME}/.zsh-styles' -Note that the values for the style may not be fully correct. +Note that the values for the styles may be partly incorrect. Please +read the manual to find out how to configure the completion system +with styles. Have fun @@ -358,7 +362,7 @@ Have fun tmp="'*:options' prefix-needed yes" [[ "$val" = hide* ]] && tmp="$tmp -zstyle ':completion*:options' prefix-hidden yes" +zstyle ':completion:*:options' prefix-hidden yes" ;; group_matches) tmp="'*' group-name ''" @@ -373,28 +377,28 @@ zstyle ':completion*:options' prefix-hidden yes" tmp="'*:paths' cursor ${(qq)val}" ;; (approximate|incremental|predict|list|oldlist|match)_*) - tmp="':${name%%_*}' ${${name#*_}//_/-} ${(qq)val}" + tmp="'*${name%%_*}:*' ${${name#*_}//_/-} ${(qq)val}" ;; correct_*) cmt="# This one is a bit ugly. You may want to use only \`*:correct' # if you also have the \`correctword_*' or \`approximate_*' keys. " - tmp="':(correct(|-word)|approximate)' ${name#*_} ${(qq)val}" + tmp="'*(correct(|-word)|approximate):*' ${name#*_} ${(qq)val}" ;; correctword_*) - tmp="':correct-word' ${name#correctword_} ${(qq)val}" + tmp="'*:correct-word' ${name#correctword_} ${(qq)val}" ;; expand_*) cmt="# This one is a bit ugly. You may want to use only \`*:expand' # if you also have the \`expandword_*' keys. " - tmp="':expand(|expand-word)' ${name#*_} ${(qq)val}" + tmp="'*expand(|expand-word):*' ${name#*_} ${(qq)val}" ;; expandword_*) - tmp="':expand-word' ${name#expandword_} ${(qq)val}" + tmp="'expand-word:*' ${name#expandword_} ${(qq)val}" ;; history_*) - tmp="'*:history-words' ${name#history_} ${(qq)val}" + tmp="'history-words:*' ${name#history_} ${(qq)val}" ;; completer) tmp="'*' completer ${${(qqs.:.)val}}" @@ -403,7 +407,7 @@ zstyle ':completion*:options' prefix-hidden yes" tmp="'*' last-prompt 'yes'" ;; esac - [[ -n "$tmp" ]] && style="${style}${cmt}zstyle :completion${tmp} + [[ -n "$tmp" ]] && style="${style}${cmt}zstyle :completion:${tmp} " done @@ -412,64 +416,6 @@ zstyle ':completion*:options' prefix-hidden yes" print "$style" >>! ${HOME}/.zsh-styles } -# Very simple interface for setting styles: -# -# compstyle pattern style values... - -compstyle() { - local long - - if [[ "$1" = -L ]]; then - long=yes - shift - fi - - if (( ! $# )); then - local pats styles vals pat style pre eq - - zstyle -g pats - - for pat in "${(@M)pats:#:completion*}"; do - if [[ -n "$long" ]]; then - pre="compstyle ${(qq)pat#:completion} " - else - print "${pat#:completion}" - pre=' ' - eq=' =' - fi - zstyle -g styles "$pat" - for style in "$styles[@]"; do - zstyle -g vals "$pat" "$style" - print "${pre}${style}${eq}" "${(@qq)vals}" - done - done - - return 0 - fi - - if [[ "$1" = -d ]]; then - if [[ $# -gt 1 ]]; then - zstyle -d ":completion$2" "${(@)argv[3,-1]}" - else - local pats - - zstyle -g pats - - for pat in "${(@M)pats:#:completion}"; do - zstyle -d "$pat" - done - fi - - return 0 - fi - - [[ "$1" = -(|-) ]] && shift - - zstyle - ":completion$1" "${(@)argv[2,-1]}" - - return 0 -} - # Now we automatically make the definition files autoloaded. typeset -U _i_files -- cgit 1.4.1