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

Re: Another keep-prefix problem



[ We only just found out that my machine still had the address of that
server that died yesterday in it's resolv.conf... that was the reason
why I didn't get my mails back -- they weren't sent.  Apologies to the
folks at sunsite.  Ahem. ]


Wayne Davison wrote:

> ...
> 
>   % ls -l /net/machine$path/foo<TAB>
> 
> This does not expand anything.  I think that it will cause less
> confusion if the new expander would work like the old one does in
> this regard.
> 
> However, I have the same complaint about keep-prefix when using
> wildcards:
> 
>   % ls -l /net/machine$path/foo*<TAB>
> 
> I'd like to see $path left unexpanded.  In other words, I want keep-
> prefix to preserve the prefix no matter where the $ expression is in
> the prefix.

Please try the patch below and tell me what you think (and everyone else
interested in this subject, too, please).  It gives me what you want for
both cases.

I won't commit this before I get positive replies and answers to the
question if we then should add another possible value for the
keep-prefix style for this new behaviour or if that's not needed (I
can't really think of a reason for keeping the old behaviour -- put some
people probably like it?).

Bye
  Sven

Index: Completion/Base/Completer/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_expand,v
retrieving revision 1.1
diff -u -r1.1 _expand
--- Completion/Base/Completer/_expand	2001/04/02 11:06:35	1.1
+++ Completion/Base/Completer/_expand	2001/04/25 13:20:37
@@ -89,10 +89,16 @@
   [[ "$subd" = "$exp"(|\(N\)) ]] &&  return 1
 
 zstyle -s ":completion:${curcontext}:" keep-prefix tmp || tmp=changed
-if [[ "$word" = [\~\$]*/* && "$tmp" = (yes|true|on|1|changed) ]]; then
-  eval 'epre=( ${(e)~${word%%/*}} )' 2>/dev/null
-  if [[ -n "$epre" && $#epre -eq 1 ]]; then
+
+if [[ "$word" = (\~*/*|*\$*/*) && "$tmp" = (yes|true|on|1|changed) ]]; then
+  if [[ "$word" = *\$* ]]; then
+    opre="${(M)word##*\$[^/]##/}"
+  else
     opre="${word%%/*}"
+  fi
+  eval 'epre=( ${(e)~opre} )' 2> /dev/null
+
+  if [[ -n "$epre" && $#epre -eq 1 ]]; then
     pre="${(q)epre[1]}"
     [[ "$tmp" != changed || $#exp -gt 1 ||
        "${opre}${exp[1]#${pre}}" != "$word" ]] && exp=( ${opre}${^exp#${pre}} )

-- 
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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