zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: Re: pws-10 RE: zsh-3.1.5-pws-9: _path_files and symbolic links
@ 1999-03-01 15:46 Sven Wischnowsky
  0 siblings, 0 replies; 8+ messages in thread
From: Sven Wischnowsky @ 1999-03-01 15:46 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> (Phew, I hope I don't have to rewrite all my completions again...
> Just have to wait and see if Bart excoriates `compgen'.)

(So you have some as yet unrevealed completion functions?)

Phew, I hope I don't have to change all the completion functions again ;-)

> > Ah, tricky. The patch below makes path components be left unchanged
> > only if the rest of the string would produce a match below that
> > directory.
> 
> Was that all that needed doing?  I knew about this, but didn't complain
> about this because I thought it was a feature which would need a lot of
> work to alter.

My big patch also contained some other fixes in _path_files. Without
them it would indeed be more complicated.

Bye
 Sven

diff -u oc/Commands/_most_recent_file Completion/Commands/_most_recent_file
--- oc/Commands/_most_recent_file	Mon Mar  1 16:42:45 1999
+++ Completion/Commands/_most_recent_file	Mon Mar  1 16:44:50 1999
@@ -1,5 +1,5 @@
 #defkeycomp complete-word \C-xm
-local file tilde exptilde
+local file tilde etilde
 if [[ $PREFIX = \~*/ ]]; then
   tilde=${PREFIX%%/*}
   etilde=${~tilde}

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


^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: PATCH: Re: pws-10 RE: zsh-3.1.5-pws-9: _path_files  and symbolic links
@ 1999-03-01 14:45 Sven Wischnowsky
  0 siblings, 0 replies; 8+ messages in thread
From: Sven Wischnowsky @ 1999-03-01 14:45 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> > The question is what one can find under `/u/'. If there is anything
> > matching `l/l/T' the behavior might be correct (since it can't expand
> > `u' to `usr' then).
> 
> Nope. It is the problem of exact match. ``/u'' is matched _exactly_ and
> hence ``/usr'' is never even tried.

Ah, tricky. The patch below makes path components be left unchanged
only if the rest of the string would produce a match below that
directory.

Bye
 Sven

diff -u oc/Core/_path_files Completion/Core/_path_files
--- oc/Core/_path_files	Mon Mar  1 14:32:16 1999
+++ Completion/Core/_path_files	Mon Mar  1 15:45:51 1999
@@ -170,23 +170,26 @@
   fi
 fi
 
-# First we skip over all pathname components in `str' which really exist in
-# the file-system, so that `/usr/lib/l<TAB>' doesn't offer you `lib' and
-# `lib5'. Pathname components skipped this way are taken from `str' and added
-# to `donepath'.
-
-while [[ "$str" = */* ]] do
-  [[ -e "$realpath$donepath${str%%/*}" ]] || break
-  donepath="$donepath${str%%/*}/"
-  str="${str#*/}"
-done
-
+# Save the original string.
 orig="${str:s/*//}"
 
 # Now build the glob pattern by calling `_match_pattern'.
 patstr="$str"
 matchflags=""
 _match_pattern _path_files patstr matchflags
+
+# First we skip over all pathname components in `str' which really exist in
+# the file-system, so that `/usr/lib/l<TAB>' doesn't offer you `lib' and
+# `lib5'. Pathname components skipped this way are taken from `orig' and added
+# to `donepath'.
+
+while [[ "$orig" = */* ]] do
+  tmp1=($realpath$donepath${orig%%/*}/${~patstr#*/})
+  [[ $#tmp1 -gt 0 && -e "$realpath$donepath${orig%%/*}" ]] || break
+  donepath="$donepath${orig%%/*}/"
+  orig="${orig#*/}"
+  patstr="${patstr#*/}"
+done
 
 # We almost expect the pattern to have changed `..' into `*.*.', `/.' into
 # `/*.', and probably to contain two or more consecutive `*'s. Since these

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


^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: PATCH: Re: pws-10 RE: zsh-3.1.5-pws-9: _path_files  and symbolic links
@ 1999-03-01 13:45 Sven Wischnowsky
  1999-03-01 14:46 ` Peter Stephenson
  0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 1999-03-01 13:45 UTC (permalink / raw)
  To: zsh-workers


I'm a bit slow today...

I wrote:

>  the only other place where `-W' is currently used is `_mh'

This uses `compgen' (i.e. the former `complist'), not `_files'. Was
the reason for this that `_path_files' didn't handle ignored prefixes
correctly? My big patch made `_path_files' give `IPREFIX' to `compadd' 
so this should work now.

Bye
 Sven


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


^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: PATCH: Re: pws-10 RE: zsh-3.1.5-pws-9: _path_files  and symbolic links
@ 1999-03-01 13:39 Sven Wischnowsky
  0 siblings, 0 replies; 8+ messages in thread
From: Sven Wischnowsky @ 1999-03-01 13:39 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> Should it not be tested in _path_files? What if I want to use other array
> rather than cdpath in other function? It is really hard to always remember
> to test it before using.

I thought about it, too, but decided against it because:

- cdpath is special: if empty or unset, `.' is used
- in other cases you will have no tests, if the array containing the
  dirs is empty you probably won't want the files in `.'; I use `-W'
  only for `cd', so I'm not sure what people would like to have here
  (producing no matches due to an empty `-W'-array looked like a good
  hint that something went wrong); I could be convinced otherwise,
  though (the only other place where `-W' is currently used is `_mh'
  which I don't use (since I don't use `mh'), so I have to ask: would
  the automatic-use-current-dir behavior be correct there?)

> And, BTW, is it not a typo in _path_files:
> 
>   liniepath=''
> 
> I'd expect it to be linepath (not that it helps much).

Yes, thanks.

Bye
 Sven

diff -u oc/Core/_path_files Completion/Core/_path_files
--- oc/Core/_path_files	Mon Mar  1 13:13:16 1999
+++ Completion/Core/_path_files	Mon Mar  1 14:31:07 1999
@@ -150,7 +150,7 @@
   # If the string does not start with a `~' we don't remove a prefix from the
   # string.
 
-  liniepath=''
+  linepath=''
   realpath=''
 
   if [[ "$str[1]" = / ]]; then

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


^ permalink raw reply	[flat|nested] 8+ messages in thread
* PATCH: Re: pws-10 RE: zsh-3.1.5-pws-9: _path_files  and symbolic links
@ 1999-03-01 13:03 Sven Wischnowsky
  1999-03-01 13:24 ` Andrej Borsenkow
  1999-03-01 14:26 ` Andrej Borsenkow
  0 siblings, 2 replies; 8+ messages in thread
From: Sven Wischnowsky @ 1999-03-01 13:03 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> Just tried on vanilla pws-10. Copied Core, Base, Builtins, sourced compinit.
> The result is the same. What I have is:
> 
> itsrm1% ls -F /
> SAM/         config/      lib@         shlib@       tools@       var@
> X11/         dev/         lost+found/  stand/       u/
> bck/         dgn/         mnt/         svr4@        unix*
> bin@         etc/         opt@         tftpboot/    unix.old*
> boot/        export/      proc/        tmp@         usr@
> cdrom/       home@        sbin/        tmp_mnt/     utmp/
> 
> itsrm1% ls -l /usr
> lrwxrwxrwx   1 root     root           7 Feb 22 17:50 /usr -> SAM/usr
> 
> itsrm1% ls -ldF /usr/lib/locale/TZ
> drwxr-xr-x   9 bin      bin         2048 Feb 23 13:50 /usr/lib/locale/TZ/
> 
> itsrm1% cd /S/u/l/l/T =>  is correctly completed to
> itsrm1% cd /SAM/usr/lib/locale/T
> 
> but
> 
> itsrm1% cd /u/l/l/T
> results in beep.

The question is what one can find under `/u/'. If there is anything
matching `l/l/T' the behavior might be correct (since it can't expand
`u' to `usr' then).
I tried it with my `/var' which is a link to `/usr/val' and it works
nicely.

> Oh, just found:
> 
> drwxr-xr-x   9 bin      bin         2048 Feb 23 13:50 /usr/lib/locale/TZ/
> drwxr-xr-x   3 root     other       1024 Feb 22 18:19
> /usr/lib/locale/Transparent/

What's wrong with that? The string you showed above correctly stops
at the `T'.

>From 5569:

> And even more funny ...
> 
> itsrm1% cat ~/.zshrc
> #!/tools/bin/zsh
> fpath=("$fpath[@]" ~/.zsh.d/comp.d/*)
> [[ -f ~/.zsh.d/comp.d/Core/compinit ]] && source
> ~/.zsh.d/comp.d/Core/compinit
> 
> itsrm1% ls src
> bzip2-0.9.0c      make-3.77         zsh-3.1.5-pws-10
> gzip-1.2.4        sudo.v1.5.8       zsh-3.1.5-pws-9
> 
> itsrm1% cd s/z/C/C>TAB> => B-E-E-P
> itsrm1% cd ./s/z/C/C<TAB> =>
> itsrm1% cd ./src/zsh-3.1.5-pws-10/Completion/Co

That's the result of not testing ig `cdpath' is set.

Bye
 Sven

diff -u oc/Builtins/_cd Completion/Builtins/_cd
--- oc/Builtins/_cd	Mon Mar  1 13:12:40 1999
+++ Completion/Builtins/_cd	Mon Mar  1 13:54:51 1999
@@ -1,3 +1,7 @@
 #defcomp cd
 
-_files -W cdpath -g '*(-/)'
+if (( $#cdpath )); then
+  _files -W cdpath -/
+else
+  _files -/
+fi

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


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

end of thread, other threads:[~1999-03-01 15:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-01 15:46 PATCH: Re: pws-10 RE: zsh-3.1.5-pws-9: _path_files and symbolic links Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
1999-03-01 14:45 Sven Wischnowsky
1999-03-01 13:45 Sven Wischnowsky
1999-03-01 14:46 ` Peter Stephenson
1999-03-01 13:39 Sven Wischnowsky
1999-03-01 13:03 Sven Wischnowsky
1999-03-01 13:24 ` Andrej Borsenkow
1999-03-01 14:26 ` Andrej Borsenkow

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