From c9bedcd98923cd9890bd5d92ec5b0ada57bccc31 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Thu, 20 Apr 2000 08:04:56 +0000 Subject: default values for styles in _expand_word, listing expansions with ^Xd, _expand uses add-space style (10854) --- Completion/Core/_expand | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'Completion/Core/_expand') diff --git a/Completion/Core/_expand b/Completion/Core/_expand index eff8d8601..2557af884 100644 --- a/Completion/Core/_expand +++ b/Completion/Core/_expand @@ -28,7 +28,8 @@ exp=("$word") # First try substitution. That weird thing spanning multiple lines # changes quoted spaces, tabs, and newlines into spaces. -zstyle -s ":completion:${curcontext}:" substitute expr && +{ zstyle -s ":completion:${curcontext}:" substitute expr || + [[ "$curcontext" = expand-word:* ]] && expr=1 } && [[ "${(e):-\$[$expr]}" -eq 1 ]] && exp=( "${(e)exp//\\[ ]/ }" ) @@ -41,7 +42,8 @@ subd=("$exp[@]") # Now try globbing. -zstyle -s ":completion:${curcontext}:" glob expr && +{ zstyle -s ":completion:${curcontext}:" glob expr || + [[ "$curcontext" = expand-word:* ]] && expr=1 } && [[ "${(e):-\$[$expr]}" -eq 1 ]] && exp=( ${~exp} ) @@ -65,28 +67,56 @@ zstyle -s ":completion:${curcontext}:" sort sort [[ "$sort" = (yes|true|1|on) ]] && exp=( "${(@o)exp}" ) # If there is only one expansion, add a suitable suffix -(($#exp == 1)) && suf='' && [[ -d $exp && "$exp[1]" != */ ]] && suf='/' + +if (( $#exp == 1 )); then + if [[ -d $exp && "$exp[1]" != */ ]]; then + suf=/ + elif zstyle -T ":completion:${curcontext}:" add-space; then + suf= + fi +fi if [[ -z "$compstate[insert]" ]] ;then - _description all-expansions expl 'all expansions' "o:$word" + if [[ "$sort" = menu ]]; then + _description expansions expl expansions "o:$word" + else + _description -V expansions expl expansions "o:$word" + fi - compadd "$expl[@]" -UQ -qS "$suf" - "$exp" + compadd "$expl[@]" -UQ -qS "$suf" - "$exp[@]" else _tags all-expansions expansions original - if _requested all-expansions; then _description all-expansions expl 'all expansions' compadd "$expl[@]" -UQ -qS "$suf" - "$exp" fi if [[ $#exp -gt 1 ]] && _requested expansions; then + local i normal dir + if [[ "$sort" = menu ]]; then _description expansions expl expansions "o:$word" else _description -V expansions expl expansions "o:$word" fi - compadd "$expl[@]" -UQ - "$exp[@]" + if zstyle -T ":completion:${curcontext}:" add-space; then + suf=' ' + else + suf= + fi + normal=() + dir=() + + for i in "$exp[@]"; do + if [[ -d "$i" && "$i" != */ ]]; then + dir=( "$dir[@]" "$i" ) + else + normal=( "$dir[@]" "$i" ) + fi + done + (( $#dir )) && compadd "$expl[@]" -UQ -qS/ - "$dir[@]" + (( $#normal )) && compadd "$expl[@]" -UQ -qS "$suf" - "$normal[@]" fi _requested original expl original && compadd "$expl[@]" -UQ - "$word" -- cgit 1.4.1