From bb93d135ba484cd423ae71b1686c63ac2c1c654f Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Mon, 6 Dec 1999 11:39:12 +0000 Subject: zsh-workers/8911 --- Completion/Commands/_complete_help | 3 +- Completion/Core/_approximate | 6 ++-- Completion/Core/_expand | 49 +++++++++++++++++++-------------- Completion/Core/_list | 3 +- Completion/Core/_main_complete | 8 +++--- Completion/Core/_message | 5 ++-- Completion/Core/_setup | 56 ++++++++++++++++++++++++++++++++------ Completion/Core/_style | 20 +++++++------- 8 files changed, 97 insertions(+), 53 deletions(-) (limited to 'Completion') diff --git a/Completion/Commands/_complete_help b/Completion/Commands/_complete_help index cfefdcf90..446fb2a90 100644 --- a/Completion/Commands/_complete_help +++ b/Completion/Commands/_complete_help @@ -18,8 +18,7 @@ _complete_help() { tags in context \`${i}': ${help_tags[$i]}" done - compstate[list]=list - compstate[force_list]=yes + compstate[list]='list force' compstate[insert]='' compadd -UX "$text[2,-1]" -n '' diff --git a/Completion/Core/_approximate b/Completion/Core/_approximate index f10d6588c..c0d409cb3 100644 --- a/Completion/Core/_approximate +++ b/Completion/Core/_approximate @@ -78,7 +78,7 @@ compstate[matcher]=-1 _correct_prompt="${cfgps//\\%e/1}" -_setup original corrections +_setup corrections [[ "$cfgorig" != *last* ]] && builtin compadd -V original builtin compadd -J corrections @@ -104,12 +104,14 @@ while [[ _comp_correct -le comax ]]; do else expl=(-n) fi + _setup original builtin compadd "$expl[@]" -U -V original -Q - "$PREFIX$SUFFIX" # If you always want to see the list of possible corrections, # set `compstate[list]=list' here. - compstate[force_list]=list + [[ "$compstate[list]" != list* ]] && + compstate[list]="$compstate[list] force" fi compstate[matcher]="$compstate[total_matchers]" unfunction compadd diff --git a/Completion/Core/_expand b/Completion/Core/_expand index 7598b6f88..471ad370e 100644 --- a/Completion/Core/_expand +++ b/Completion/Core/_expand @@ -84,8 +84,6 @@ fi exp=( "${(@)${(@)${(@q)exp}//\\\\=/=}/#=/\\=}" ) -_setup original expansions all-expansions - # We have expansions, should we menucomplete them? if [[ -z "$menu" ]]; then @@ -95,16 +93,20 @@ if [[ -z "$menu" ]]; then # probably also adding the original string. if [[ -z "$compstate[insert]" ]]; then + _setup all-expansions compadd -U -V all-expansions -Q - "$exp[@]" else - [[ -n "$orig" && "$orig" != *last* ]] && - compadd "$expl[@]" -UQ -V original - "$word" - - compadd -UQ -V _expand - "$exp" - - [[ -n "$orig" && "$orig" = *last* ]] && - compadd "$expl[@]" -UQ -V original - "$word" + if [[ -n "$orig" && "$orig" != *last* ]]; then + _setup original + compadd "$expl[@]" -UQ -V original - "$word" + fi + _setup expansions + compadd -UQ -V expansions - "$exp" + if [[ -n "$orig" && "$orig" = *last* ]]; then + _setup original + compadd "$expl[@]" -UQ -V original - "$word" + fi compstate[insert]=menu fi else @@ -115,24 +117,29 @@ else # Now add the expansion string, probably also adding the original # and/or the string containing all expanded string. - [[ -n "$orig" && "$orig" != *last* ]] && - compadd "$expl[@]" -UQ -V original - "$word" - - [[ $#exp -ne 1 && "$menu" = *last* && "$menu" != *only* ]] && - compadd "$expl2[@]" -UQ -V all-expansions - "$exp" - + if [[ -n "$orig" && "$orig" != *last* ]]; then + _setup original + compadd "$expl[@]" -UQ -V original - "$word" + fi + if [[ $#exp -ne 1 && "$menu" = *last* && "$menu" != *only* ]]; then + _setup all-expansions + compadd "$expl2[@]" -UQ -V all-expansions - "$exp" + fi + _setup expansions if [[ -z "$prompt" ]]; then compadd -UQ $group expansions - "$exp[@]" else compadd -UQ -X "${prompt//\\%o/$word}" \ $group expansions - "$exp[@]" fi - [[ $#exp -ne 1 && "$menu" != *last* && "$menu" != *only* ]] && - compadd "$expl2[@]" -UQ -V all-expansions - "$exp" - - [[ -n "$orig" && "$orig" = *last* ]] && - compadd "$expl[@]" -UQ -V original - "$word" - + if [[ $#exp -ne 1 && "$menu" != *last* && "$menu" != *only* ]]; then + _setup all-expansions + compadd "$expl2[@]" -UQ -V all-expansions - "$exp" + fi + if [[ -n "$orig" && "$orig" = *last* ]]; then + _setup original + compadd "$expl[@]" -UQ -V original - "$word" + fi compstate[insert]=menu fi diff --git a/Completion/Core/_list b/Completion/Core/_list index ea2ed36aa..6c72bc9e9 100644 --- a/Completion/Core/_list +++ b/Completion/Core/_list @@ -26,8 +26,7 @@ if [[ ( -z "$expr" || "${(e):-\$[$expr]}" -eq 1 ) && # to compare the next time. compstate[insert]='' - compstate[list]=list - compstate[force_list]=yes + compstate[list]='list force' _list_prefix="$pre" _list_suffix="$suf" fi diff --git a/Completion/Core/_main_complete b/Completion/Core/_main_complete index 4dd3bd218..f8ef78753 100644 --- a/Completion/Core/_main_complete +++ b/Completion/Core/_main_complete @@ -19,6 +19,9 @@ 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]" \ + _saved_lastprompt="$compstate[last_prompt]" \ + _saved_list="$compstate[list]" typeset -U _offered_tags _tried_tags _failed_tags _used_tags _unused_tags _offered_tags=() @@ -82,8 +85,7 @@ if [[ compstate[nmatches] -eq 0 && -n "$format" && $#_lastdescr -ne 0 ]]; then local str - compstate[list]=list - compstate[force_list]=yes + compstate[list]='list force' compstate[insert]='' case $#_lastdescr in @@ -95,8 +97,6 @@ if [[ compstate[nmatches] -eq 0 && compadd -UX "${format//\\%d/$str}" -n '' fi -_style '' last-prompt && compstate[last_prompt]=yes - _lastcomp=( "${(@kv)compstate}" ) _lastcomp[completer]="$comp" _lastcomp[prefix]="$PREFIX" diff --git a/Completion/Core/_message b/Completion/Core/_message index 5c5c42e06..b2730a331 100644 --- a/Completion/Core/_message +++ b/Completion/Core/_message @@ -8,11 +8,10 @@ _style -s messages format format || _style -s descriptions format format if [[ -n "$format" ]]; then if [[ $compstate[nmatches] -eq 0 ]]; then - compstate[list]=list - compstate[force_list]=yes + compstate[list]='list force' compstate[insert]='' compadd -UX "${format//\\%d/$1}" -n '' else - compadd -X "${format//\\%d/$1}" -n '' && compstate[force_list]=yes + compadd -X "${format//\\%d/$1}" -n '' && compstate[list]='list force' fi fi diff --git a/Completion/Core/_setup b/Completion/Core/_setup index f12c34b34..683757918 100644 --- a/Completion/Core/_setup +++ b/Completion/Core/_setup @@ -1,13 +1,51 @@ #autoload -local colors i +local val -for i; do - if _style -a "$i" list-colors colors; then - if [[ "$1" = default ]]; then - ZLS_COLORS="${(j.:.)${(@)colors:gs/:/\\\:}}" - else - eval "ZLS_COLORS=\"(${i})\${(j.:(${i}).)\${(@)colors:gs/:/\\\:}}:\${ZLS_COLORS}\"" - fi +if _style -a "$1" list-colors val; then + if [[ "$1" = default ]]; then + ZLS_COLORS="${(j.:.)${(@)val:gs/:/\\\:}}" + else + eval "ZLS_COLORS=\"(${i})\${(j.:(${i}).)\${(@)val:gs/:/\\\:}}:\${ZLS_COLORS}\"" fi -done +fi + +if _style -s "$1" list-packed val; then + if [[ "$val" = (yes|true|1|on) ]]; then + compstate[list]="${compstate[list]} packed" + else + compstate[list]="${compstate[list]:gs/packed//}" + fi +else + compstate[list]="$_saved_list" +fi + +if _style -s "$1" list-rows-first val; then + if [[ "$val" = (yes|true|1|on) ]]; then + compstate[list]="${compstate[list]} rows" + else + compstate[list]="${compstate[list]:gs/rows//}" + fi +else + compstate[list]="$_saved_list" +fi + +if _style -s "$1" last-prompt val; then + if [[ "$val" = (yes|true|1|on) ]]; then + compstate[last_prompt]=yes + else + compstate[last_prompt]='' + fi +else + compstate[last_prompt]="$_saved_lastprompt" +fi + +if _style -s "$1" accept-exact val; then + if [[ "$val" = (yes|true|1|on) ]]; then + compstate[exact]=accept + else + compstate[exact]='' + fi +else + compstate[exact]="$_saved_exact" +fi diff --git a/Completion/Core/_style b/Completion/Core/_style index 6e2de23df..d666a9fd8 100644 --- a/Completion/Core/_style +++ b/Completion/Core/_style @@ -1,21 +1,21 @@ #autoload -local val ret +local _val _ret # Should we return the value? case "$1" in -b) - compstyles -S "$context" "$2" val - ret="$?" + compstyles -S "${curcontext}${2:+:${2}}" "$3" _val + _ret="$?" - if [[ "$val" = (#I)(yes|true|1|on) ]]; then - eval "${3}=yes" + if [[ "$_val" = (yes|true|1|on) ]]; then + eval "${4}=yes" else - eval "${3}=no" + eval "${4}=no" fi - return ret; + return _ret ;; -s) compstyles -S "${curcontext}${2:+:${2}}" "$3" "$4" @@ -33,11 +33,11 @@ esac [[ "$1" = -(|-) ]] && shift -if compstyles -S "${curcontext}${1:+:${1}}" "$2" val; then +if compstyles -S "${curcontext}${1:+:${1}}" "$2" _val; then if [[ $# -eq 3 ]]; then - [[ "$val" = ${~3} ]] + [[ "$_val" = ${~3} ]] else - [[ "$val" = (#I)(yes|true|1|on) ]] + [[ "$_val" = (yes|true|1|on) ]] fi else return 1 -- cgit 1.4.1