zsh-workers
 help / color / mirror / code / Atom feed
* _path_files prefix handling
@ 2003-02-12 12:29 Peter Stephenson
  2003-02-12 15:06 ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2003-02-12 12:29 UTC (permalink / raw)
  To: Zsh hackers list

There's a general problem with _path_files which we've encountered
before and fixed with specifics (e.g. the fake style), but actually
needs fixing generally.

If I want to complete /some/path/to/a/dir/<here>, then any failed
component in the directory path will stop me completing, even if
the full component /some/path/to/a/dir/ is found and has entirely
standard Unix behaviour.  We encountered this in Cygwin, but it occurs
in ClearCase too:

/view/pws/vob/bcsw_test/bc/dev/src/csr/lc/radiosched_data.c@@/main/

behaves like an ordinary directory, but there is no radiosched_data.c@@
in the directory list for lc --- even though
[[ -d <stuff>/radiosched_data.c@@ ]] returns true.

This is looking to me increasingly like an intrinsic limitation of the
completion system.  I can see two ways out.

1. At the least we could test [[ -d pathcomponent ]] at each stage and
trust the system to get this right, rather than rely on pathcomponent
appearing in the list of entries in the current directory.  This ought
to be relatively simple, and I think fixes all the problems I know about
--- this test works for all components of /cygdrive/c/Program\ Files
under Cygwin, for example, making half of `fake's properties redundant
(you still need it to be offered the choice, but don't need it for the
system to recognise that the choice is a valid path component).

2. Probably unnecessary now 1. has occurred to me, but a large fraction
of the time with a long path you simply want to complete the last
component.  This could presumably be optimised along the lines of

  if [[ -d ${PREFIX:h} ]] then
    ...

as a style, possibly set by default.  Presumably involves more invasive
surgery than the first option, but I'd very much like to see one of the
two implemented.

_path_files is fairly complicated, but I suspect 1. could be done
without more than a modicum of frustration.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

* Re: _path_files prefix handling
  2003-02-12 12:29 _path_files prefix handling Peter Stephenson
@ 2003-02-12 15:06 ` Peter Stephenson
  2003-02-12 17:16   ` Bart Schaefer
  2003-02-21 14:41   ` Peter Stephenson
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Stephenson @ 2003-02-12 15:06 UTC (permalink / raw)
  To: Zsh hackers list

Peter Stephenson wrote:
> 1. At the least we could test [[ -d pathcomponent ]] at each stage and
> trust the system to get this right, rather than rely on pathcomponent
> appearing in the list of entries in the current directory.  This ought
> to be relatively simple, and I think fixes all the problems I know about
> --- this test works for all components of /cygdrive/c/Program\ Files
> under Cygwin, for example, making half of `fake's properties redundant
> (you still need it to be offered the choice, but don't need it for the
> system to recognise that the choice is a valid path component).

Here's an attempt which seems to do more or less the right thing with
Cygwin and ClearCase without fake-files.  I'm not claiming this is The
Right Way To Do It.  I have tried it with a filename with a space in,
however.

Index: Completion/Unix/Type/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v
retrieving revision 1.20
diff -u -r1.20 _path_files
--- Completion/Unix/Type/_path_files	6 Nov 2002 08:03:44 -0000	1.20
+++ Completion/Unix/Type/_path_files	12 Feb 2003 15:05:06 -0000
@@ -343,6 +343,22 @@
     if [[ -n "$PREFIX$SUFFIX" ]]; then
       # See which of them match what's on the line.
 
+      # pws non-canonical hack which seems to work so far...
+      # if we didn't match by globbing, check that there is
+      # something to match by explicit name.  This is for
+      # `clever' filing systems where names pop into existence
+      # when referenced.
+      if (( ! $#tmp1 )); then
+	  for tmp3 in "$tmp2[@]"; do
+	      if [[ -n $tmp3 && $tmp3 != */ ]]; then
+		  tmp3+=/
+	      fi
+	      if [[ -e "$tmp3${(Q)PREFIX}${(Q)SUFFIX}" ]] then
+		  tmp1+=("$tmp3${(Q)PREFIX}${(Q)SUFFIX}")
+	      fi
+	  done
+      fi
+
       if (( ! $#tmp1 )); then
         tmp2=( ${^tmp2}/$PREFIX$SUFFIX )
       elif [[ "$tmp1[1]" = */* ]]; then


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

* Re: _path_files prefix handling
  2003-02-12 15:06 ` Peter Stephenson
@ 2003-02-12 17:16   ` Bart Schaefer
  2003-02-12 17:26     ` Peter Stephenson
  2003-02-21 14:41   ` Peter Stephenson
  1 sibling, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2003-02-12 17:16 UTC (permalink / raw)
  To: Zsh hackers list

On Feb 12,  3:06pm, Peter Stephenson wrote:
}
} +      # if we didn't match by globbing, check that there is
} +      # something to match by explicit name.  This is for
} +      # `clever' filing systems where names pop into existence
} +      # when referenced.

Could this replace the hack that was put in for forcing NFS filesystems
to automount?  I suppose not entirely ...


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

* Re: _path_files prefix handling
  2003-02-12 17:16   ` Bart Schaefer
@ 2003-02-12 17:26     ` Peter Stephenson
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2003-02-12 17:26 UTC (permalink / raw)
  To: Zsh hackers list

"Bart Schaefer" wrote:
> On Feb 12,  3:06pm, Peter Stephenson wrote:
> }
> } +      # if we didn't match by globbing, check that there is
> } +      # something to match by explicit name.  This is for
> } +      # `clever' filing systems where names pop into existence
> } +      # when referenced.
> 
> Could this replace the hack that was put in for forcing NFS filesystems
> to automount?  I suppose not entirely ...

Well, it seemed to do the trick when I commented out the line you're
referring to.  But I'm not that confident about all the things
_path_files is doing.  compfiles is undocumented.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

* Re: _path_files prefix handling
  2003-02-12 15:06 ` Peter Stephenson
  2003-02-12 17:16   ` Bart Schaefer
@ 2003-02-21 14:41   ` Peter Stephenson
  2003-02-24 11:34     ` Peter Stephenson
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2003-02-21 14:41 UTC (permalink / raw)
  To: Zsh hackers list

Peter Stephenson wrote:
> Peter Stephenson wrote:
> > 1. At the least we could test [[ -d pathcomponent ]] at each stage and
> > trust the system to get this right, rather than rely on pathcomponent
> > appearing in the list of entries in the current directory.
> 
> Here's an attempt which seems to do more or less the right thing with
> Cygwin and ClearCase without fake-files.  I'm not claiming this is The
> Right Way To Do It.  I have tried it with a filename with a space in,
> however.
> 
> Index: Completion/Unix/Type/_path_files

Has anyone tried this and seen a problem?  I may commit it.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

* Re: _path_files prefix handling
  2003-02-21 14:41   ` Peter Stephenson
@ 2003-02-24 11:34     ` Peter Stephenson
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2003-02-24 11:34 UTC (permalink / raw)
  To: Zsh hackers list

Peter Stephenson wrote:
> Peter Stephenson wrote:
> > Index: Completion/Unix/Type/_path_files
> 
> Has anyone tried this and seen a problem?  I may commit it.

I have now committed this.  I've also commented out the other hack to
get automounting to work a few lines earlier --- if the new hack turns
out not to do this consistently enough, we can uncomment that again.

So please complain if completion can't see your automounted directories
any more.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

end of thread, other threads:[~2003-02-24 11:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-12 12:29 _path_files prefix handling Peter Stephenson
2003-02-12 15:06 ` Peter Stephenson
2003-02-12 17:16   ` Bart Schaefer
2003-02-12 17:26     ` Peter Stephenson
2003-02-21 14:41   ` Peter Stephenson
2003-02-24 11:34     ` Peter Stephenson

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).