1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-06 09:01:13 +02:00

zsh-workers/9773

This commit is contained in:
Tanaka Akira 2000-02-17 12:42:57 +00:00
parent 0e3f4cecde
commit 8ac5e93d9e
5 changed files with 14 additions and 29 deletions

View file

@ -109,7 +109,8 @@ while true; do
PREFIX="${cpre}${pre}" PREFIX="${cpre}${pre}"
SUFFIX="$suf" SUFFIX="$suf"
if [[ $#imm -ne 0 && $#matches -eq 1 ]]; then if [[ $#imm -ne 0 && $#matches -eq 1 ]] ||
zstyle -t ":completion:${curcontext}:" expand suffix; then
compadd "$group[@]" "$expl[@]" "$opts[@]" \ compadd "$group[@]" "$expl[@]" "$opts[@]" \
-M "r:|${sep}=* r:|=* $match" - "$pref$matches[1]" -M "r:|${sep}=* r:|=* $match" - "$pref$matches[1]"
else else
@ -142,7 +143,8 @@ while true; do
SUFFIX="$suf" SUFFIX="$suf"
fi fi
if [[ -n "$menu" || -z "$compstate[insert]" ]]; then if ! zstyle -t ":completion:${curcontext}:" expand suffix ||
[[ -n "$menu" || -z "$compstate[insert]" ]]; then
# With menucompletion we add only the ambiguous component with # With menucompletion we add only the ambiguous component with
# the prefix collected and a spearator for the matches that # the prefix collected and a spearator for the matches that
@ -164,22 +166,6 @@ while true; do
-M "r:|${sep}=* r:|=* $match" - "$i" -M "r:|${sep}=* r:|=* $match" - "$i"
fi fi
done done
# The old code and its comment:
# With menucompletion we just add matches for the matching
# components with the prefix we collected and the rest from the
# line as a suffix.
# tmp2="$pre$suf"
# if [[ "$tmp2" = *${sep}* ]]; then
# compadd "$group[@]" "$expl[@]" "$sopts[@]" \
# -p "$pref" -s "${sep}${tmp2#*${sep}}" \
# -M "r:|${sep}=* r:|=* $match" - "$tmp1[@]"
# else
# compadd "$group[@]" "$expl[@]" -p "$pref" "$sopts[@]" \
# -M "r:|${sep}=* r:|=* $match" - "$tmp1[@]"
# fi
else else
# With normal completion we add all matches one-by-one with # With normal completion we add all matches one-by-one with
# the unmatched part as a suffix. This will insert the longest # the unmatched part as a suffix. This will insert the longest
@ -202,7 +188,8 @@ while true; do
# case we insert the expanded prefix we collected if it differs # case we insert the expanded prefix we collected if it differs
# from the original string from the line. # from the original string from the line.
[[ "$orig" = "$pref$pre$suf" ]] && return 1 { ! zstyle -t ":completion:${curcontext}:" expand prefix ||
[[ "$orig" = "$pref$pre$suf" ]] } && return 1
PREFIX="${cpre}${pre}" PREFIX="${cpre}${pre}"
SUFFIX="$suf" SUFFIX="$suf"

View file

@ -4,7 +4,7 @@ local expl groups
_wanted groups expl group || return 1 _wanted groups expl group || return 1
if ! zstyle -a ":completion:${curcontext}:groups" groups groups; then if ! zstyle -a ":completion:${curcontext}:" groups groups; then
(( $+_cache_groups )) || (( $+_cache_groups )) ||
if (( ${+commands[ypcat]} )); then if (( ${+commands[ypcat]} )); then
: ${(A)_cache_groups:=${${(s: :)$(ypcat group.byname)}%%:*}} # If you use YP : ${(A)_cache_groups:=${${(s: :)$(ypcat group.byname)}%%:*}} # If you use YP

View file

@ -2,7 +2,7 @@
local expl ports local expl ports
if ! zstyle -a ":completion:${curcontext}:ports" ports ports; then if ! zstyle -a ":completion:${curcontext}:" ports ports; then
(( $+_cache_ports )) || (( $+_cache_ports )) ||
: ${(A)_cache_ports:=${${(M)${${(f)"$(</etc/services)"}:#\#*}#*/tcp}%%[ ]*}} : ${(A)_cache_ports:=${${(M)${${(f)"$(</etc/services)"}:#\#*}#*/tcp}%%[ ]*}}

View file

@ -1,13 +1,10 @@
#compdef last passwd groups #compdef last passwd groups
# If a parameter `users' exists and it is an array, we first try to
# complete only to its elements.
local expl users local expl users
_wanted users expl user || return 1 _wanted users expl user || return 1
zstyle -a ":completion:${curcontext}:users" users users && zstyle -a ":completion:${curcontext}:" users users &&
compadd "$expl[@]" "$@" - "$users[@]" && return 0 compadd "$expl[@]" "$@" - "$users[@]" && return 0
compadd "$@" "$expl[@]" - "${(@k)userdirs}" compadd "$@" "$expl[@]" - "${(@k)userdirs}"

View file

@ -773,10 +773,11 @@ completed. If this is not set by the user domain names mentioned in
tt(/etc/resolv.conf) will be used. tt(/etc/resolv.conf) will be used.
) )
item(tt(expand))( item(tt(expand))(
Like tt(cursor), this style is used with the tt(paths) tag. If its This style is used when completing strings consisting of multiple
value contains the string tt(prefix), the partially typed path from parts, such as path names. If its
the line will be expanded as far as possible even if trailing pathname value contains the string tt(prefix), the partially typed word from
components can not be completed. If it contains the string tt(suffix) the line will be expanded as far as possible even if trailing parts
can not be completed. If it contains the string tt(suffix)
and normal (non-menu-) completion is used, matching names for and normal (non-menu-) completion is used, matching names for
components after the first ambiguous one will be added, too. This components after the first ambiguous one will be added, too. This
means that the resulting string is the longest unambiguous string means that the resulting string is the longest unambiguous string