zsh-users
 help / color / mirror / code / Atom feed
* completion with globbing, take 2
@ 2000-09-17 17:50 E. Jay Berkenbilt
  2000-09-17 18:43 ` Bart Schaefer
  0 siblings, 1 reply; 16+ messages in thread
From: E. Jay Berkenbilt @ 2000-09-17 17:50 UTC (permalink / raw)
  To: zsh-users


Several days ago, I wanted to know how I could get zsh to respond to 

something *TAB

by replacing the * with the list everything that the completion system
would return instead of everything * would match in the current
directory.  I was told to do this:

zstyle ':completion:*' completer _oldlist _complete _match
bindkey "^I" complete-word

I've spent a lot of time trying to figure this out, but this still
doesn't work and I don't know how to make it work.  This gives a
behavior like menu-complete.  I never want menu-complete-like
functionality.  I want behavior more like what expand-or-complete does
except that I want only what the completion system would return to be
substituted.

I will be very explicit to reduce the chance of my question being
misunderstood.

zsh -f

> zsh% autoload -U compinit
> zsh% compinit
> zsh% mkdir /tmp/z
> zsh% cd /tmp/z
> zsh% mkdir 1 2 3
> zsh% touch a b c

Type:

> zsh% rmdir TAB

You see:

> zsh% rmdir 
> 1/  2/  3/

Type:

> zsh% rmdir *TAB

You see:

> zsh% rmdir 1 2 3 a b c 

Now configure as above:

> zsh% zstyle ':completion:*' completer _oldlist _complete _match
> zsh% bindkey "^I" complete-word

Type:

> zsh% rmdir *TAB

You see:

> zsh% rmdir 1/
1/  2/  3/

Each subsequent TAB rotates between 1/, 2/, and 3/.

What I want:

> zsh% rmdir *TAB

should yield

> zsh% rmdir 1 2 3 

Is there a way to do this?

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


^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: completion with globbing, take 2
@ 2000-10-04 11:14 Sven Wischnowsky
  0 siblings, 0 replies; 16+ messages in thread
From: Sven Wischnowsky @ 2000-10-04 11:14 UTC (permalink / raw)
  To: zsh-users


E. Jay Berkenbilt wrote:

> ...
> 
> _main_complete is called.  It looks up my completers (_oldlist,
> _complete, _expand, and _match) and calls then in order.  _oldlist
> returns nothing, _complete returns nothing (since no files start with
> '*').  Now it starts getting interesting.  _expand is called.  Since I
> have set the completions style for expand to true, it sets
> compstate[insert]=all which gives me the behavior I'm looking for with
> respect to the replacement.  However, since the current context is not
> expand-word:*, it does not call _complete and thus just returns 1.
> Finally, _match is called.  I don't follow exactly what's going on at
> the top of _match, but it doesn't matter.  Since I don't have
> match-original set, _match sets compstate[pattern_match]='*' and calls
> _complete again.  This time, since compstate[pattern_match] is set,
> _complete actually does find matches.
> 
> So the right thing happens, but the path to the desired end seems
> quite convoluted and counterintuitive to me.  I would never have
> figured this out without the significant hints without having to spend
> a lot of time grokking this code.

The first thing is that _expand is intended to be in the completer
list *before* _complete. And it was documented that way.

The other thing is that this kind of use, as you all found out,
doesn't really have anything to do with expansion and hence doesn't
need a pattern on the line -- which lead to _expand being used in
combination with _match and all that.

Hm. Maybe we should make the completer-handling of _expand with the
completions style set more clever. Or something. Probably together
with Bart's changes to _expand_word. I'll have a look.


I'll avoid digging through all the other messages in this thread
again, only one more remark:

Of course, the (implementation of the) completions style is a bit
hackish. And, more importantly, it was never intended to be set
unconditionally. Not too long a go, it was one of the mathematically-
conditional styles (if you don't know what that was, don't mind). 
Nowadays it is intended to be used either with `zstyle -e' (where one
could, inter alia, have a look at the command line with $words,
$BUFFER or $PREFIX (to see if the word is a pattern or some such)) or
with, e.g., _generic, as in:

  zle -C complete-all complete-word _generic
  bindkey '^xa' complete-all
  zstyle ':completion:complete-all:*' completer _expand _complete
  zstyle ':completion:complete-all:*' completions yes



Bye
 Sven


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


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

end of thread, other threads:[~2001-02-20  9:46 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-17 17:50 completion with globbing, take 2 E. Jay Berkenbilt
2000-09-17 18:43 ` Bart Schaefer
2000-09-17 23:03   ` E. Jay Berkenbilt
2000-09-18  0:17     ` completion and globbing, part 2 E. Jay Berkenbilt
2000-09-18  6:53       ` Andrej Borsenkow
2000-09-18  9:59         ` insert-all-matches example " Andrej Borsenkow
2000-09-18 17:28           ` completion with globbing, take 2 Bart Schaefer
2000-09-18 18:08             ` Andrej Borsenkow
2000-09-19  2:02               ` Bart Schaefer
2000-09-20 15:06                 ` Andrej Borsenkow
2000-09-20 16:12                   ` Bart Schaefer
2000-09-18 22:07             ` E. Jay Berkenbilt
2000-09-19  2:14               ` Bart Schaefer
2001-02-20  9:55                 ` Job Table Nick Cross
2000-09-18  6:07   ` completion with globbing, take 2 Andrej Borsenkow
2000-10-04 11:14 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).