Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: 3.1.6-dev-18



Peter Stephenson wrote:

> > But maybe we should make _multi_parts use the `expand=suffix'
> > style/value to decide if the whole matches should be used at all. The
> > same way _path_files does that. I would prefer to make it use an empty 
> > tag then (because _multi_parts doesn't always complete paths and the
> > style is tested for the paths tag in _path_files). Because of that I
> > thought, I should ask first. Or maybe making it use the paths tag in
> > _path_files and no tag in _multi_parts is ok? (I find that a bit
> > confusing).
> 
> Empty tags are certainly easier than they were before, so I would be in
> favour of changing not to use tags unless they actually discriminate
> between different cases ---- depending really on logic, i.e. we have less
> need of inventing otherwise unused tags.

Yup. Here's the patch to make _multi_parts use the expand style, just
like _path_files.

This also make the ports, groups and users tags be not used anymore
when looking up the ports, groups and users styles.

Bye
 Sven

diff -ru ../z.old/Completion/Core/_multi_parts Completion/Core/_multi_parts
--- ../z.old/Completion/Core/_multi_parts	Thu Feb 17 12:58:16 2000
+++ Completion/Core/_multi_parts	Thu Feb 17 13:29:20 2000
@@ -109,7 +109,8 @@
 	PREFIX="${cpre}${pre}"
 	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[@]" \
                   -M "r:|${sep}=* r:|=* $match" - "$pref$matches[1]"
         else
@@ -142,7 +143,8 @@
 	SUFFIX="$suf"
       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
         # the prefix collected and a spearator for the matches that
@@ -164,22 +166,6 @@
                     -M "r:|${sep}=* r:|=* $match" - "$i"
           fi
         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
         # With normal completion we add all matches one-by-one with
 	# the unmatched part as a suffix. This will insert the longest
@@ -202,7 +188,8 @@
       # case we insert the expanded prefix we collected if it differs
       # 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}"
       SUFFIX="$suf"
diff -ru ../z.old/Completion/User/_groups Completion/User/_groups
--- ../z.old/Completion/User/_groups	Thu Feb 17 12:58:22 2000
+++ Completion/User/_groups	Thu Feb 17 13:08:05 2000
@@ -4,7 +4,7 @@
 
 _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 )) ||
       if (( ${+commands[ypcat]} )); then
         : ${(A)_cache_groups:=${${(s: :)$(ypcat group.byname)}%%:*}} # If you use YP
diff -ru ../z.old/Completion/User/_ports Completion/User/_ports
--- ../z.old/Completion/User/_ports	Thu Feb 17 12:58:24 2000
+++ Completion/User/_ports	Thu Feb 17 13:07:53 2000
@@ -2,7 +2,7 @@
 
 local expl ports
 
-if ! zstyle -a ":completion:${curcontext}:ports" ports ports; then
+if ! zstyle -a ":completion:${curcontext}:" ports ports; then
   (( $+_cache_ports )) ||
       : ${(A)_cache_ports:=${${(M)${${(f)"$(</etc/services)"}:#\#*}#*/tcp}%%[ 	]*}}
 
diff -ru ../z.old/Completion/User/_users Completion/User/_users
--- ../z.old/Completion/User/_users	Thu Feb 17 12:58:26 2000
+++ Completion/User/_users	Thu Feb 17 13:08:54 2000
@@ -1,13 +1,10 @@
 #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
 
 _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[@]" - "${(@k)userdirs}"
diff -ru ../z.old/Doc/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- ../z.old/Doc/Zsh/compsys.yo	Thu Feb 17 12:57:57 2000
+++ Doc/Zsh/compsys.yo	Thu Feb 17 13:16:24 2000
@@ -773,10 +773,11 @@
 tt(/etc/resolv.conf) will be used.
 )
 item(tt(expand))(
-Like tt(cursor), this style is used with the tt(paths) tag. If its
-value contains the string tt(prefix), the partially typed path from
-the line will be expanded as far as possible even if trailing pathname
-components can not be completed. If it contains the string tt(suffix)
+This style is used when completing strings consisting of multiple
+parts, such as path names. If its
+value contains the string tt(prefix), the partially typed word from
+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
 components after the first ambiguous one will be added, too. This
 means that the resulting string is the longest unambiguous string

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author