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

Re: completion after //



Alexandre Duret-Lutz wrote:

> I will try later not to rewrite PREFIX and SUFFIX but only the copies
> of these used by _path_files.  Then,_path_files should complete
> as if there no sequence of slashes, but since the line won't be modified,
> I suppose the braces won't move.

May I suggest this simple solution?

`squeeze-slashes' may be a bit of a misnomer with it, though.

Bye
 Sven

diff -ru ../z.old/Completion/Core/_path_files Completion/Core/_path_files
--- ../z.old/Completion/Core/_path_files	Fri Jan 21 14:40:49 2000
+++ Completion/Core/_path_files	Fri Jan 21 14:50:20 2000
@@ -3,7 +3,7 @@
 # Utility function for in-path completion. This allows `/u/l/b<TAB>'
 # to complete to `/usr/local/bin'.
 
-local linepath realpath donepath prepath testpath exppath
+local linepath realpath donepath prepath testpath exppath skips
 local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre
 local pats haspats=no ignore group expl addpfx addsfx remsfx rem remt
 local nm=$compstate[nmatches] menu mspec matcher mopts atmp sort match
@@ -157,13 +157,9 @@
   fi
 fi
 
-# Squeeze sequences of slashes
-if zstyle -t ":completion${curcontext}:paths" squeeze-slashes
-then
-  PREFIX="${PREFIX//(\\/)#//}"
-  SUFFIX="${SUFFIX//(\\/)#//}"
-  [[ $PREFIX = */ ]] && SUFFIX=${SUFFIX#/}
-fi
+# Skip over sequences of slashes.
+
+zstyle -t ":completion${curcontext}:paths" squeeze-slashes && skips=yes
 
 # We get the prefix and the suffix from the line and save the whole
 # original string. Then we see if we will do menucompletion.
@@ -269,6 +265,14 @@
     if [[ "$tpre" = (.|..)/* ]]; then
       tmp1=( ${^tmp1}${tpre%%/*}/ )
       tpre="${tpre#*/}"
+      continue
+    fi
+
+    # Skip over multiple slashes?
+
+    if [[ -n "$skips" && "$tpre" = /* ]]; then
+      tmp1=( ${^tmp1}/ )
+      tpre="${tpre#/}"
       continue
     fi
 
diff -ru ../z.old/Doc/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- ../z.old/Doc/Zsh/compsys.yo	Fri Jan 21 14:40:25 2000
+++ Doc/Zsh/compsys.yo	Fri Jan 21 14:53:31 2000
@@ -1199,9 +1199,7 @@
 )
 item(tt(squeeze-slashes))(
 If set to `true', sequences of slashes (like in `tt(foo//bar)') will be
-rewritten with a single slash (`tt(foo/bar)') when completing directory
-names.  Using this style can confuse tt(zsh) if slashes get squeezed 
-before braces completion (e.g. when trying to complete `tt(//{etc)').
+treated as if they were only one slash when completing pathnames.
 )
 item(tt(stop))(
 If set to `true', the tt(_history_complete_word) bindable

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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