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

PATCH: Re: use of `expand suffix' style in _multi_parts



On 14 Feb, Peter wrote:
> Completing directories after
> 
>   tar xvzf file.tar.gz HERE/
> 
> with the `expand' style set to include `suffix' is inconvenient as it
> appends a space after the slash when completing the directory HERE.
> This is obviously wrong --- there is no reason to do anything other than
> normal file completion at this point, irrespective of styles.
> 
> I can fix this by setting `expand' specially for the tar command, of course.
> However, it needs fixing more generally.  Unfortunately I can't work out
> what's actually wrong.  The culprit is _multi_parts where the style is
> tested.  Is this wrong, is the compadd on the next line (which uses the
> options passed rather than the separator passed) warong, is _tar wrong,
> in any case what needs changing?

using:
  compdef '_multi_parts / "(HERE/ HERE/one HERE/two)"' foo
is enough to show the problem so it certainly isn't _tar.

If you rearrange the three matches, it is always the first one that is
completed.

This line in the trace output then looks suspicious:
+_multi_parts:94> compadd -O tmp1 -M 'r:|/=* r:|=* ' - HERE HERE HERE

It is followed by assertions being made based upon $#tmp1. So for the
part it is looking at there are three matches but they are all the
same.

This patch fixes the problem by adding all those matches.

Oliver

Index: Completion/Base/Utility/_multi_parts
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_multi_parts,v
retrieving revision 1.4
diff -u -r1.4 _multi_parts
--- Completion/Base/Utility/_multi_parts	31 May 2001 07:17:04 -0000	1.4
+++ Completion/Base/Utility/_multi_parts	19 Feb 2003 07:55:41 -0000
@@ -114,7 +114,7 @@
 	if [[ $#imm -ne 0 && $#matches -eq 1 ]] ||
            zstyle -t ":completion:${curcontext}:" expand suffix; then
 	  compadd "$group[@]" "$expl[@]" "$sopts[@]" \
-                  -M "r:|${sep}=* r:|=* $matcher" - "$pref$matches[1]"
+                  -M "r:|${sep}=* r:|=* $matcher" - $pref$matches
         else
 	  if (( $matches[(I)${tmp1[1]}${sep}*] )); then
 	    compadd "$group[@]" "$expl[@]" -p "$pref" -r "$sep" -S "$sep" "$opts[@]" \

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.



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