zsh-workers
 help / color / mirror / code / Atom feed
* feature request: special completion of glob patterns
@ 2000-08-08 16:25 Adam Spiers
  2000-08-08 20:41 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Spiers @ 2000-08-08 16:25 UTC (permalink / raw)
  To: zsh workers mailing list

This one's a little bit tricky to explain, and I suspect way too
tricky to implement, but I'll mention it anyway.

Say I want to diff two files in mirrored directory hierarchies:

   foo1/bar/baz.txt
   foo2/bar/baz.txt

Ideally, I would like the following completion behaviour (assuming
baz.txt is the only file in foo1/bar):

  $ diff -u foo[12]/bar/b<TAB>
  $ diff -u foo[12]/bar/baz.txt

i.e. zsh would do normal expansion on `foo[12]/bar/b', attempt
completion on the first filename generated by the expansion, and then
perform the same change to `foo[12]/bar/b' as it did to `foo1/bar/b'
when it completed it to `foo1/bar/baz.txt', which in this case is
adding `az.txt' to the end.

Similar behaviour for

  $ diff -u foo_{one,two}/bar/b<TAB>

would be great too.

Now I realise that to do this in full generality with the myriad of
complex patterns zsh understands may well be impossible, but is it
feasible to deal with simple cases like these?


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

* Re: feature request: special completion of glob patterns
  2000-08-08 16:25 feature request: special completion of glob patterns Adam Spiers
@ 2000-08-08 20:41 ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2000-08-08 20:41 UTC (permalink / raw)
  To: zsh workers mailing list

On Aug 8,  5:25pm, Adam Spiers wrote:
> 
> Ideally, I would like the following completion behaviour (assuming
> baz.txt is the only file in foo1/bar):
> 
>   $ diff -u foo[12]/bar/b<TAB>
>   $ diff -u foo[12]/bar/baz.txt

This is very similar to the keep-prefix style, and I believe there was
some discussion in that thread of handling something like this.  You may
even be able to figure out a way to do it by looking for keep-prefix in
the _expand completer.

Trying out a couple of things has led me to find the following oddities:

zsh% x='foo[12]'
zsh% diff -u ${~x}/b<TAB>
zsh% diff -u ${~x}/foo/bar
                      ^
                      cursor here

It's behaving as if $~x expanded to ".".  This is with the _expand completer
and the keep-prefix style set to true.

The other is that the _expand completer seems to trigger menu-completion
even when I have explicitly turned it off.  I removed all references to
"menu" or "select" from my styles, I'm using the complete-word widget, and
I have automenu turned off, yet after `zsh/S*<TAB>' I still end up with a
menu completion cycling through zsh/Src, zsh/StartupFiles, and zsh/S*
(because I have the original style set).  I expected it just to list the
completions and feep.

I realize, looking back through the history of _expand, that it has always
been this way, and I simply never noticed because I usually have automenu
set.  Nevertheless it seems to me that there ought to be some way to turn
it off.


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

* Re: feature request: special completion of glob patterns
@ 2000-08-09  8:00 Sven Wischnowsky
  0 siblings, 0 replies; 3+ messages in thread
From: Sven Wischnowsky @ 2000-08-09  8:00 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Aug 8,  5:25pm, Adam Spiers wrote:
> > 
> > Ideally, I would like the following completion behaviour (assuming
> > baz.txt is the only file in foo1/bar):
> > 
> >   $ diff -u foo[12]/bar/b<TAB>
> >   $ diff -u foo[12]/bar/baz.txt
> 
> This is very similar to the keep-prefix style, and I believe there was
> some discussion in that thread of handling something like this.  You may
> even be able to figure out a way to do it by looking for keep-prefix in
> the _expand completer.

Adam may also have a look at the completion-after-braces thread. I
want to move enough of the basic completion code into shell code to be 
able to implement completion after `a{b,c}d' there. That would
probably also allow us to do that with globbing. I don't have any real 
ideas how to do that yet, though, and it will come after 4.0.

> Trying out a couple of things has led me to find the following oddities:
> 
> zsh% x='foo[12]'
> zsh% diff -u ${~x}/b<TAB>
> zsh% diff -u ${~x}/foo/bar
>                       ^
>                       cursor here
> 
> It's behaving as if $~x expanded to ".".  This is with the _expand completer
> and the keep-prefix style set to true.

I couldn't exactly reproduce this, but I see the problem (with files
foo{1,2}/bar):

  % x='foo[12]' y='${~x}/b'
  % echo ${(e)y}
  zsh: no matches found: foo[12]/b
  % echo ${~x}/b
  zsh: no matches found: foo[12]/b

These are the two types of parameter expansions used by _expand.

I've no idea how to fix that. Maybe add a `*' at the cursor position
or at the end or both end (as in _match/globcomplete). Or something.


> The other is that the _expand completer seems to trigger menu-completion
> even when I have explicitly turned it off.  I removed all references to
> "menu" or "select" from my styles, I'm using the complete-word widget, and
> I have automenu turned off, yet after `zsh/S*<TAB>' I still end up with a
> menu completion cycling through zsh/Src, zsh/StartupFiles, and zsh/S*
> (because I have the original style set).  I expected it just to list the
> completions and feep.
> 
> I realize, looking back through the history of _expand, that it has always
> been this way, and I simply never noticed because I usually have automenu
> set.  Nevertheless it seems to me that there ought to be some way to turn
> it off.

I didn't do that mainly because chances are even worse than for _match 
that the resulting words have a common prefix. However, we could use
the insert-unambiguous style there, too (and if it is true and
$compstate[unambiguous] is long enough, don't add the original and
maybe don't add the all-expansions string).


Bye
 Sven


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


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

end of thread, other threads:[~2000-08-09  8:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-08 16:25 feature request: special completion of glob patterns Adam Spiers
2000-08-08 20:41 ` Bart Schaefer
2000-08-09  8:00 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).