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

Re: PATCH: 3.1.5-pws-10: _tar



Peter Stephenson wrote:

> Sven Wischnowsky wrote:
> > The things below adds a helper function `_multi_parts' that gets two
> > arguments: a separator character and an array (name or `(...)'). It
> > will then complete the parts of the words that are separated by the
> > separator character.
> > 
> > It also changes the `_tar' function to use `_multi_parts', maybe Peter
> > would like to put the changed one into `_tar2' so that users can
> > decide which one they want.
> 
> This isn't working for directories for me.  After zsh-3.1.5-pws-10/ it will
> complete files, but not Src.  Typing Src/ makes it complete files but not
> directories down there, and so on.  Trying to do a lot in one go leaves a
> space where Src should have been, and makes no change after that.
> 
> In fact, now it's stopped working altogether: zsh-<TAB> does nothing in
> that position.  It's calling _multi_parts, and the list of files is right,
> but nothing's coming back.  When I type zsh-3.1.5-pws-10/, I can see it
> generate a list of completions with that removed, then I get this

It was too eager to replace `*s' with `[^/]#'s. The patch below does
the replacement only for the non-last components.

Bye
 Sven

diff -u oc/Core/_multi_parts Completion/Core/_multi_parts
--- oc/Core/_multi_parts	Thu Mar  4 16:53:13 1999
+++ Completion/Core/_multi_parts	Fri Mar  5 09:18:56 1999
@@ -67,7 +67,8 @@
   # `matches' that match the prefix we have and the exact substring in 
   # the array `tmp1'.
 
-  eval "pat=\"\${\${patstr#*\${sep}}:gs${gsep}*${gsep}[^${sep}]#${gsep}}\""
+  tmp1="${${patstr#*${sep}}%${sep}*}"
+  eval "pat=\"\${tmp1:gs${gsep}*${gsep}[^${sep}]#${gsep}}${patstr##*${sep}}\""
   tmp1=( "${(@M)matches:#${~matchflags}${orig%%${sep}*}${sep}${~pat}}" )
 
   # If there are no words matching the exact substring, stop.
@@ -86,7 +87,12 @@
 
 # Now we get all the words that still match in `tmp1'.
 
-eval "pat=\"\$patstr:gs${gsep}*${gsep}[^${sep}]#${gsep}\""
+if [[ "$patstr" = *${sep}* ]]; then
+  tmp1="${patstr%${sep}*}${sep}"
+  eval "pat=\"\$tmp1:gs${gsep}*${gsep}[^${sep}]#${gsep}${patstr##*${sep}}\""
+else
+  pat="$patstr"
+fi
 tmp1=( "${(@M)matches:#${~matchflags}${~pat}}" )
 
 if (( $#tmp1 )); then
@@ -123,7 +129,7 @@
     fi
   done
 
-elif [[ "$patstr" = */* ]]; then
+elif [[ "$patstr" = *${sep}* ]]; then
 
   # We had no words matching the string from the line. But we want to
   # be friendly and at least expand the prefix as far as we can. So we 

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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