zsh-workers
 help / color / mirror / code / Atom feed
* Preserve initial // in path name completion
@ 2001-07-06  5:14 Andrej Borsenkow
  2001-07-06  9:24 ` Sven Wischnowsky
  0 siblings, 1 reply; 10+ messages in thread
From: Andrej Borsenkow @ 2001-07-06  5:14 UTC (permalink / raw)
  To: ZSH Workers Mailing List

Is it (easily) possible to preserve initial // irrespectively of
squeez-slashes? (Or depending on other style)? Looks like zsh is gaining
popularity on Cygwin and probably will be included in standard net release;
having the above allows you finally complete inside network shares
(fake-files //:'server1 server2' ...).

Sven?

-andrej


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Preserve initial // in path name completion
  2001-07-06  5:14 Preserve initial // in path name completion Andrej Borsenkow
@ 2001-07-06  9:24 ` Sven Wischnowsky
  2001-07-06 10:32   ` Andrej Borsenkow
  0 siblings, 1 reply; 10+ messages in thread
From: Sven Wischnowsky @ 2001-07-06  9:24 UTC (permalink / raw)
  To: zsh-workers

Andrej Borsenkow wrote:

> Is it (easily) possible to preserve initial // irrespectively of
> squeez-slashes? (Or depending on other style)? Looks like zsh is gaining
> popularity on Cygwin and probably will be included in standard net release;
> having the above allows you finally complete inside network shares
> (fake-files //:'server1 server2' ...).
> 
> Sven?

Currently not.  Seems like we never came aroud to implementing it, but
it can be made quite simply, see the patch below.  It adds a style
`preserve-prefix' which can be given a pattern and _path_files will then
blindly keep any prefix matched by that pattern unchanged.

Would that be enough?  (Please try it by hand, I won't commit it until I
get positive replies -- but then I probably will because if I remember
correctly there were even Unices which attach a special meaning to a
leading `//' which in turn makes me wonder why we didn't add it earlier,
but maybe I just haven't been asked often enough or was too fed up at
those times...).

Maybe we should then rename it to `keep-prefix', but maybe not, because
it has a slightly differnet meaning in _expand (and different values).


Bye
  Sven

Index: Completion/Unix/Type/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v
retrieving revision 1.6
diff -u -r1.6 _path_files
--- Completion/Unix/Type/_path_files	2001/06/18 09:53:17	1.6
+++ Completion/Unix/Type/_path_files	2001/07/06 09:21:25
@@ -264,7 +264,15 @@
   linepath=
   realpath=
 
-  if [[ "$pre[1]" = / ]]; then
+  if zstyle -s ":completion:${curcontext}:" preserve-prefix tmp1 &&
+     [[ -n "$tmp1" && "$pre" = (#b)(${~tmp1})* ]]; then
+
+    pre="$pre[${#match[1]}+1,-1]"
+    orig="$orig[${#match[1]}+1,-1]"
+    donepath="$match[1]"
+    prepaths=( '' )
+
+  elif [[ "$pre[1]" = / ]]; then
     # If it is a absolute path name, we remove the first slash and put it in
     # `donepath' meaning that we treat it as the path that was already handled.
     # Also, we don't use the paths from `-W'.

-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: Preserve initial // in path name completion
  2001-07-06  9:24 ` Sven Wischnowsky
@ 2001-07-06 10:32   ` Andrej Borsenkow
  2001-07-06 10:41     ` Sven Wischnowsky
  0 siblings, 1 reply; 10+ messages in thread
From: Andrej Borsenkow @ 2001-07-06 10:32 UTC (permalink / raw)
  To: zsh-workers


>
> Currently not.  Seems like we never came aroud to implementing it, but
> it can be made quite simply, see the patch below.  It adds a style
> `preserve-prefix' which can be given a pattern and _path_files will then
> blindly keep any prefix matched by that pattern unchanged.
>

To my immense surprise even with preserve-prefix unset (but with your patch
and suitably set fake-files) and squeeze-slashes it happily completed inside
UNC paths, even respecting all matchers. Looks, like fake-files win?

> Would that be enough?

I do not quite understand but may be it even is not needed? Anyway, the only
problem. I have \\itsrm2\root$. I defined

zstyle ':completion:*' fake-files //:itsrm2 //itsrm2:root\$
zstyle ':completion:*' squeeze-slashes true

Then

(tty1)% l //i/r/t/s/zTAB
(tty1)% l //itsrm2/root\$/tools/share/z
Completing files
share/  src/
(tty1)% l //itsrm2/root\$/tools/src/zTAB
No matches for: `files' or `file'

I *do* have /tools/src/zsh:

(tty1)% l //i/r/t/s/z/s/mTAB
(tty1)% l //itsrm2/root\$/tools/src/zsh/s/m
Completing files
zsh/        zsh-4.0.x/

This obviously happens only with root$; any other share I've tried works.

-andrej


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: RE: Preserve initial // in path name completion
  2001-07-06 10:32   ` Andrej Borsenkow
@ 2001-07-06 10:41     ` Sven Wischnowsky
  2001-07-06 11:03       ` Andrej Borsenkow
  0 siblings, 1 reply; 10+ messages in thread
From: Sven Wischnowsky @ 2001-07-06 10:41 UTC (permalink / raw)
  To: zsh-workers

Andrej Borsenkow wrote:

> ...
> 
> To my immense surprise even with preserve-prefix unset (but with your patch
> and suitably set fake-files) and squeeze-slashes it happily completed inside
> UNC paths, even respecting all matchers. Looks, like fake-files win?

Err... the patch shouldn't make a difference with the style set, does it
work without the patch, too? (And with the patch below.)

> ...
> 
> This obviously happens only with root$; any other share I've tried works.

This was a more general problem because the test for parameter
expansions in the string to complete didn't check if the `$' was
preceded by a backslash.  Fix below.  I'll commit it (to the stable
branch, too).


Bye
  Sven

Index: Completion/Unix/Type/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v
retrieving revision 1.6
diff -u -r1.6 _path_files
--- Completion/Unix/Type/_path_files	2001/06/18 09:53:17	1.6
+++ Completion/Unix/Type/_path_files	2001/07/06 10:40:04
@@ -190,7 +190,7 @@
 
 # Now let's have a closer look at the string to complete.
 
-if [[ "$pre" = [^][*?#^\|\<\>]#(\`[^\`]#\`|\$)*/* && "$compstate[quote]" != \' ]]; then
+if [[ "$pre" = [^][*?#^\|\<\>\\]#(\`[^\`]#\`|\$)*/* && "$compstate[quote]" != \' ]]; then
 
   # If there is a parameter expansion in the word from the line, we try
   # to complete the beast by expanding the prefix and completing anything

-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: RE: Preserve initial // in path name completion
  2001-07-06 10:41     ` Sven Wischnowsky
@ 2001-07-06 11:03       ` Andrej Borsenkow
  2001-07-06 11:16         ` Andrej Borsenkow
  2001-07-06 12:22         ` Sven Wischnowsky
  0 siblings, 2 replies; 10+ messages in thread
From: Andrej Borsenkow @ 2001-07-06 11:03 UTC (permalink / raw)
  To: zsh-workers

>
> > ...
> >
> > To my immense surprise even with preserve-prefix unset (but
> with your patch
> > and suitably set fake-files) and squeeze-slashes it happily
> completed inside
> > UNC paths, even respecting all matchers. Looks, like fake-files win?
>
> Err... the patch shouldn't make a difference with the style set, does it
> work without the patch, too? (And with the patch below.)
>

It happily works without the first patch. And the second does fix root$
problem. Wonder ... I guess I never tried it before but I presumed
squeeze-slashes should prevent it.

Can you explain why it works? (I mean, that we can be sure it continues to
work in the future).

-andrej


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: RE: Preserve initial // in path name completion
  2001-07-06 11:03       ` Andrej Borsenkow
@ 2001-07-06 11:16         ` Andrej Borsenkow
  2001-07-06 12:22         ` Sven Wischnowsky
  1 sibling, 0 replies; 10+ messages in thread
From: Andrej Borsenkow @ 2001-07-06 11:16 UTC (permalink / raw)
  To: zsh-workers


>
> Can you explain why it works? (I mean, that we can be sure it continues to
> work in the future).
>

zstyle ':completion:*' fake-files /:cygdrive '/cygdrive:c d e h' //:itsrm2
'//itsrm2:source sni Microsoft Linux root$'
zstyle ':completion:*' squeeze-slashes true

-andrej


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: RE: RE: Preserve initial // in path name completion
  2001-07-06 11:03       ` Andrej Borsenkow
  2001-07-06 11:16         ` Andrej Borsenkow
@ 2001-07-06 12:22         ` Sven Wischnowsky
  2001-07-06 12:34           ` Andrej Borsenkow
  2001-07-13 12:22           ` Andrej Borsenkow
  1 sibling, 2 replies; 10+ messages in thread
From: Sven Wischnowsky @ 2001-07-06 12:22 UTC (permalink / raw)
  To: zsh-workers

Andrej Borsenkow wrote:

> ...
> 
> It happily works without the first patch. And the second does fix root$
> problem. Wonder ... I guess I never tried it before but I presumed
> squeeze-slashes should prevent it.
> 
> Can you explain why it works? (I mean, that we can be sure it continues to
> work in the future).

The C-code in computil.c adds the fake stuff before building the
patterns.


In another message:

> zstyle ':completion:*' fake-files /:cygdrive '/cygdrive:c d e h' //:itsrm2
> '//itsrm2:source sni Microsoft Linux root$'
> zstyle ':completion:*' squeeze-slashes true

Err... yes?  What do you want to tell me with that? :-}


Bye
  Sven


-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: RE: RE: Preserve initial // in path name completion
  2001-07-06 12:22         ` Sven Wischnowsky
@ 2001-07-06 12:34           ` Andrej Borsenkow
  2001-07-13 12:22           ` Andrej Borsenkow
  1 sibling, 0 replies; 10+ messages in thread
From: Andrej Borsenkow @ 2001-07-06 12:34 UTC (permalink / raw)
  To: zsh-workers


> In another message:
>
> > zstyle ':completion:*' fake-files /:cygdrive '/cygdrive:c d e
> h' //:itsrm2
> > '//itsrm2:source sni Microsoft Linux root$'
> > zstyle ':completion:*' squeeze-slashes true
>
> Err... yes?  What do you want to tell me with that? :-}
>

I wanted to show the exact settimngs in use in case you needed it to answer
the question. That's all :-)

-andrej


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: RE: RE: Preserve initial // in path name completion
  2001-07-06 12:22         ` Sven Wischnowsky
  2001-07-06 12:34           ` Andrej Borsenkow
@ 2001-07-13 12:22           ` Andrej Borsenkow
  2001-07-17  9:02             ` PATCH: " Sven Wischnowsky
  1 sibling, 1 reply; 10+ messages in thread
From: Andrej Borsenkow @ 2001-07-13 12:22 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

> >
> > It happily works without the first patch.

I just realized and verified that the original patch (15278) allows to
complete after x:/, so I guess it should go in. Probably in both HEAD and
4.0

-andrej


^ permalink raw reply	[flat|nested] 10+ messages in thread

* PATCH: Re: Preserve initial // in path name completion
  2001-07-13 12:22           ` Andrej Borsenkow
@ 2001-07-17  9:02             ` Sven Wischnowsky
  0 siblings, 0 replies; 10+ messages in thread
From: Sven Wischnowsky @ 2001-07-17  9:02 UTC (permalink / raw)
  To: zsh-workers

Andrej Borsenkow wrote:

> I just realized and verified that the original patch (15278) allows to
> complete after x:/, so I guess it should go in. Probably in both HEAD and
> 4.0

Ok.  Andrej could you please check if what I wrote in the docs is
correct (the Cygwin example in particular).


Bye
  Sven

Index: Completion/Unix/Type/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v
retrieving revision 1.8
diff -u -r1.8 _path_files
--- Completion/Unix/Type/_path_files	2001/07/13 08:09:52	1.8
+++ Completion/Unix/Type/_path_files	2001/07/17 09:00:11
@@ -268,7 +268,15 @@
   linepath=
   realpath=
 
-  if [[ "$pre[1]" = / ]]; then
+  if zstyle -s ":completion:${curcontext}:" preserve-prefix tmp1 &&
+     [[ -n "$tmp1" && "$pre" = (#b)(${~tmp1})* ]]; then
+
+    pre="$pre[${#match[1]}+1,-1]"
+    orig="$orig[${#match[1]}+1,-1]"
+    donepath="$match[1]"
+    prepaths=( '' )
+
+  elif [[ "$pre[1]" = / ]]; then
     # If it is a absolute path name, we remove the first slash and put it in
     # `donepath' meaning that we treat it as the path that was already handled.
     # Also, we don't use the paths from `-W'.
Index: Completion/Zsh/Command/_zstyle
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_zstyle,v
retrieving revision 1.1
diff -u -r1.1 _zstyle
--- Completion/Zsh/Command/_zstyle	2001/04/02 11:34:11	1.1
+++ Completion/Zsh/Command/_zstyle	2001/07/17 09:00:11
@@ -75,6 +75,7 @@
   ports			 c:_ports
   prefix-hidden		 c:bool
   prefix-needed		 c:bool
+  preserve-prefix        c:preserve-prefix
   range                  c:
   regular                c:bool
   remote-access		 c:bool
@@ -302,6 +303,10 @@
 
     insunambig) 
       _wanted values expl 'insert unambiguous string' compadd true false pattern
+      ;;
+
+    preserve-prefix)
+      _message 'pattern matching prefix to keep'
       ;;
 
     urgh) 
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.128
diff -u -r1.128 compsys.yo
--- Doc/Zsh/compsys.yo	2001/06/06 09:50:39	1.128
+++ Doc/Zsh/compsys.yo	2001/07/17 09:00:14
@@ -1834,6 +1834,16 @@
 
 The default style for this style is `true'.
 )
+kindex(preserve-prefix, completion style)
+item(tt(preserve-prefix))(
+This style is used when completing path names.  Its value should be a
+pattern matching an initial prefix of the word to complete that should
+be left unchanged under all circumstances.  For example, on some Unices
+an initial `tt(//)' (double slash) has a special meaning and hence
+should be kept.  For that one could set this style to the string
+`tt(//)'.  As another example, setting this style to `tt(?:/)' under
+Cygwin would allow completion after `tt(a:/...)' and the like.
+)
 kindex(range, completion style)
 item(tt(range))(
 This is used by the tt(_history) completer and the

-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2001-07-17  9:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-06  5:14 Preserve initial // in path name completion Andrej Borsenkow
2001-07-06  9:24 ` Sven Wischnowsky
2001-07-06 10:32   ` Andrej Borsenkow
2001-07-06 10:41     ` Sven Wischnowsky
2001-07-06 11:03       ` Andrej Borsenkow
2001-07-06 11:16         ` Andrej Borsenkow
2001-07-06 12:22         ` Sven Wischnowsky
2001-07-06 12:34           ` Andrej Borsenkow
2001-07-13 12:22           ` Andrej Borsenkow
2001-07-17  9:02             ` PATCH: " Sven Wischnowsky

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).