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

Re: _files vs _path_files discussion (old thread)



[digging up a very old thread]

Sven Wischnowsky (wischnow@xxxxxxxxxxxxxxxxxxxxxxx) wrote:
> 
> Peter Stephenson wrote:
> 
> > Adam Spiers wrote:
> > > Now people may disagree with this, but I would have thought that in
> > > many completion scenarios, _path_files -/ -g <glob> is more
> > > appropriate than _files -g <glob>.  For example, when completing tar
> > > archives, if there are none in directory foo, and you type 
> > 
> > ...
> > 
> > A second issue is whether, if you find target files in the current
> > directory, you might still want to complete directories.  This is also hard
> > to generalise on, since if you are completing a common enough file type you
> > might very well want to be offered directories straight away, while if
> > there aren't many of that type they may just get in the way.  But probably
> > we need to be more consistent, rather than depending on who happened to
> > write the completion file.

Does the new zstyle stuff now provide some kind of configurability to
solve this issue?  Here's a practical example of the issue, just to
make sure it's clear what I'm talking about:

Suppose I have, in the cwd, a file `foo.tar.gz' and a directory `foo'.
I type:

  $ tar zxf foo<TAB>

Currently, this immediately completes to `foo.tar.gz'.  But what if I
actually wanted to extract a .tar.gz from somewhere within the
directory foo?  According to _complete_help, _tar calls _tar_archive,
which calls _files, which generates the tags `globbed-files',
`directories', and `all-files'.

Presumably because some globbed-files were found, directories were not
added to the list of completions.  Is it possible to set some style
appropriately so that directories are listed immediately along with
tarballs?  I'm interested in a general solution which would apply to
all invocations of `_files -g ...'.

Incidentally, the more I understand of the new completion system, the
more I like it.  Sure, it's very intricate and takes a lot of getting
used to, but it seems to me that the various concepts have been
abstracted out in just the right way so as to allow completion
function writers maximum flexibility and convenience.  It's also great
that the end-user can just press TAB and instantly enjoy all this
power without worrying about how it works, and that there is so much
configurability available from zstyle.  Congratulations to everyone
involved, especially (needless to say) Sven!

Adam



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