zsh-users
 help / color / mirror / code / Atom feed
* glob completion without menu style completion
@ 2000-09-15 17:30 E. Jay Berkenbilt
  2000-09-15 18:00 ` Andrej Borsenkow
  0 siblings, 1 reply; 6+ messages in thread
From: E. Jay Berkenbilt @ 2000-09-15 17:30 UTC (permalink / raw)
  To: zsh-users


(zsh-3.1.9-dev-6)

If I type 

rmdir TAB

I get a list of only directories.

If I setopt glob_complete and do 

rmdir *TAB

then each subsequent tab cycles through only directories.

If I don't have setopt glob_complete and I do

rmdir *TAB

the * gets replaced with all files in the directory that would be
matched by * if I were to just hit return at that moment.

Is there a way to get it so that when I type

rmdir *TAB

the * gets replaced with all the choices that the completion system
returns at that time (i.e., whatever glob pattern I've typed should be
applied to the completion choices rather than to files)?  I don't see
an option to do this.

This would be so great for commands like cvs add and cvs rm.......

--
E. Jay Berkenbilt (ejb@ql.org)  |  http://www.ql.org/q/


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

* RE: glob completion without menu style completion
  2000-09-15 17:30 glob completion without menu style completion E. Jay Berkenbilt
@ 2000-09-15 18:00 ` Andrej Borsenkow
  2000-09-15 18:55   ` Bart Schaefer
  2000-09-15 18:59   ` E. Jay Berkenbilt
  0 siblings, 2 replies; 6+ messages in thread
From: Andrej Borsenkow @ 2000-09-15 18:00 UTC (permalink / raw)
  To: E. Jay Berkenbilt, zsh-users

>
> (zsh-3.1.9-dev-6)
>
> If I type
>
> rmdir TAB
>
> I get a list of only directories.
>
> If I setopt glob_complete and do
>
> rmdir *TAB
>
> then each subsequent tab cycles through only directories.
>
> If I don't have setopt glob_complete and I do
>
> rmdir *TAB
>
> the * gets replaced with all files in the directory that would be
> matched by * if I were to just hit return at that moment.
>
> Is there a way to get it so that when I type
>
> rmdir *TAB
>
> the * gets replaced with all the choices that the completion system
> returns at that time (i.e., whatever glob pattern I've typed should be
> applied to the completion choices rather than to files)?  I don't see
> an option to do this.
>
> This would be so great for commands like cvs add and cvs rm.......
>

Yes, I can reproduce it. It happens, because by default TAB is bound to
expand-or-complete widget that tries expansion if it sees glob pattern
*before* it tries completion. So, it seems, that completion system sees input
line with already expanded '*' ... I personally consider it a bug, but Sven
should answer it when he is back.

You are better off if you redefine TAB to simple expand-word like

bindkey '^I' expand-word

(that is what I have in my .zshrc), and use _match or _expand completers. I
personally do not have much experience with _expand, I use _match. Use them as
secondary competer; I use

zstyle ':completion:*' completer _oldlist _complete _match

and I get exactly what you want. In general, _match will try to match possible
completions (in this case, directory names) against pattern on command line.
It will be used if _complete did not generate any completions, that is, no
directory that started with '*' existed :-)

In general, it is always good idea to use plain complete-word with new
completion system, because then you have much better control over possible
interpretation of patterns.

-andrej


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

* Re: glob completion without menu style completion
  2000-09-15 18:00 ` Andrej Borsenkow
@ 2000-09-15 18:55   ` Bart Schaefer
  2000-09-15 19:52     ` E. Jay Berkenbilt
  2000-09-18  7:05     ` Andrej Borsenkow
  2000-09-15 18:59   ` E. Jay Berkenbilt
  1 sibling, 2 replies; 6+ messages in thread
From: Bart Schaefer @ 2000-09-15 18:55 UTC (permalink / raw)
  To: zsh-users

On Sep 15, 10:00pm, Andrej Borsenkow wrote:
> Subject: RE: glob completion without menu style completion
> >
> > If I don't have setopt glob_complete and I do
> >
> > rmdir *TAB
> >
> > the * gets replaced with all files in the directory that would be
> > matched by * if I were to just hit return at that moment.
> >
> > Is there a way to get it so that when I type
> >
> > rmdir *TAB
> >
> > the * gets replaced with all the choices that the completion system
> > returns at that time
> 
> Yes, I can reproduce it. It happens, because by default TAB is bound to
> expand-or-complete widget that tries expansion if it sees glob pattern
> *before* it tries completion. So, it seems, that completion system sees
> input line with already expanded '*' ... I personally consider it a bug,
> but Sven should answer it when he is back.

It's not a bug, it's the defined behavior of expand-or-complete.

> You are better off if you redefine TAB to simple expand-word like
> 
> bindkey '^I' expand-word

You mean "complete-word", not "expand-word".  And if you run "compinit"
*after* setting your styles with zstyle, *and* you have used the _expand
completer, then compinit rebinds TAB to complete-word for you, for just
this reason.

> In general, it is always good idea to use plain complete-word with new
> completion system, because then you have much better control over possible
> interpretation of patterns.

Exactly.


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

* Re: glob completion without menu style completion
  2000-09-15 18:00 ` Andrej Borsenkow
  2000-09-15 18:55   ` Bart Schaefer
@ 2000-09-15 18:59   ` E. Jay Berkenbilt
  1 sibling, 0 replies; 6+ messages in thread
From: E. Jay Berkenbilt @ 2000-09-15 18:59 UTC (permalink / raw)
  To: Andrej.Borsenkow; +Cc: zsh-users


>   > Is there a way to get it so that when I type
>   >
>   > rmdir *TAB
>   >
>   > the * gets replaced with all the choices that the completion system
>   > returns at that time (i.e., whatever glob pattern I've typed should be
>   > applied to the completion choices rather than to files)?  I don't see
>   > an option to do this.
>   >
>   > This would be so great for commands like cvs add and cvs rm.......
>   >
>
>   . . .
>
>   You are better off if you redefine TAB to simple expand-word like
>
>   bindkey '^I' expand-word
>
>   (that is what I have in my .zshrc), and use _match or _expand completers. I
>   personally do not have much experience with _expand, I use _match. Use them as
>   secondary competer; I use
>
>   zstyle ':completion:*' completer _oldlist _complete _match
>
>   and I get exactly what you want. In general, _match will try to match possible
>   completions (in this case, directory names) against pattern on command line.
>   It will be used if _complete did not generate any completions, that is, no
>   directory that started with '*' existed :-)

Thanks.  I'll study this so I understand exactly what it means and
give it a try.

>   In general, it is always good idea to use plain complete-word with new
>   completion system, because then you have much better control over possible
>   interpretation of patterns.

Do you mean to say that it's better to use expand-word, or are you
indicating here that there is some loss of control over interpretation
of patters by switching to expand-word?  If the latter, is it fully
mitigated by giving the zstyle command you mentioned?  I will need to
look into this in more depth so I can understand the full implications
of switching from complete-word to expand-word...

                                Jay


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

* Re: glob completion without menu style completion
  2000-09-15 18:55   ` Bart Schaefer
@ 2000-09-15 19:52     ` E. Jay Berkenbilt
  2000-09-18  7:05     ` Andrej Borsenkow
  1 sibling, 0 replies; 6+ messages in thread
From: E. Jay Berkenbilt @ 2000-09-15 19:52 UTC (permalink / raw)
  To: schaefer; +Cc: zsh-users


>   > You are better off if you redefine TAB to simple expand-word like
>   > 
>   > bindkey '^I' expand-word
>
>   You mean "complete-word", not "expand-word".  And if you run "compinit"
>   *after* setting your styles with zstyle, *and* you have used the _expand
>   completer, then compinit rebinds TAB to complete-word for you, for just
>   this reason.

Ah.  This all makes sense now.  My previous reply can be disregarded.
Now I just have to decide whether to use _match as a secondary
completer and whether to use _expand is a primary completer.

                                Jay


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

* RE: glob completion without menu style completion
  2000-09-15 18:55   ` Bart Schaefer
  2000-09-15 19:52     ` E. Jay Berkenbilt
@ 2000-09-18  7:05     ` Andrej Borsenkow
  1 sibling, 0 replies; 6+ messages in thread
From: Andrej Borsenkow @ 2000-09-18  7:05 UTC (permalink / raw)
  To: Bart Schaefer, zsh-users

> >
> > Yes, I can reproduce it. It happens, because by default TAB is bound to
> > expand-or-complete widget that tries expansion if it sees glob pattern
> > *before* it tries completion. So, it seems, that completion system sees
> > input line with already expanded '*' ... I personally consider it a bug,
> > but Sven should answer it when he is back.
>
> It's not a bug, it's the defined behavior of expand-or-complete.
>


You are right of course. I have not used expand-or-complete for several years
already :-)

-andrej


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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-15 17:30 glob completion without menu style completion E. Jay Berkenbilt
2000-09-15 18:00 ` Andrej Borsenkow
2000-09-15 18:55   ` Bart Schaefer
2000-09-15 19:52     ` E. Jay Berkenbilt
2000-09-18  7:05     ` Andrej Borsenkow
2000-09-15 18:59   ` E. Jay Berkenbilt

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