zsh-users
 help / color / mirror / code / Atom feed
* Q about new completion (how to create several match sets)
@ 2000-04-27 10:11 Andrej Borsenkow
  0 siblings, 0 replies; 4+ messages in thread
From: Andrej Borsenkow @ 2000-04-27 10:11 UTC (permalink / raw)
  To: ZSH users mailing list

This goes to zsh-users as it may be of common interest. Bear in mind,
this refers to the current 3.1.6 version from CVS.

In current form _configure completes both --with-option
and --without-option in one shot. It means, that I always get at least
two matches and (in my settings) cursor is placed after --with so I have
to use additional keystroke to jump to the end of line.

Is it possible to _externally_ (without changing _configure and/or
_arguments, but with styles) configure completion system so, that I get
two set of matches - first all --with-* and then all --without-* and can
select either of them? This includes of course different status lines
etc.

Is it possible to set different completers for one command only?

-andrej

Have a nice DOS!
B >>


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

* RE: Q about new completion (how to create several match sets)
@ 2000-04-27 14:03 Sven Wischnowsky
  0 siblings, 0 replies; 4+ messages in thread
From: Sven Wischnowsky @ 2000-04-27 14:03 UTC (permalink / raw)
  To: zsh-users


Andrej Borsenkow wrote:

> ...
> 
> No, that's weird. I was able to make it running exactly once - and I
> have a feeling, this was after cvs update/make/make install in one
> window, sourcing styles in another one and trying there (that is, with
> *old* zsh+functions). What I get currently, is
> 
> bor@itsrm2% cd samba-2.0.7/source
> bor@itsrm2% ./configure --wi-swTAB
> bor@itsrm2% cd samba-2.0.7/source
> bor@itsrm2% ./configure --with-<CURSOR HERE>swatdir
> Completing with options
> --with-swatdir
> Completing other options
> --with-swatdir      --without-swatdir
> 
> with styles
> 
> ...
>
> zstyle ':completion:*:options-other' ignored-patterns '^--with(|out)-*'
> 
> (I added ``^'' to the last pattern - assuming, it is beginning-of-word
> anchor)

Nah. The `^' is the special glob character to negate the pattern,
remove it again, then `other options' will contain only options not
beginning with `--with' or `--without'.

Sometimes I get it right the first time... ;-)

Bye
 Sven


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


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

* RE: Q about new completion (how to create several match sets)
  2000-04-27 11:05 Sven Wischnowsky
@ 2000-04-27 13:51 ` Andrej Borsenkow
  0 siblings, 0 replies; 4+ messages in thread
From: Andrej Borsenkow @ 2000-04-27 13:51 UTC (permalink / raw)
  To: zsh-users

>
> > In current form _configure completes both --with-option
> > and --without-option in one shot. It means, that I always
> get at least
> > two matches and (in my settings) cursor is placed after
> --with so I have
> > to use additional keystroke to jump to the end of line.
>
> Hm, this is ugly, but should it be enough to keep from
> supplying match
> specs?
>

No. In this case I obviously do want to use match specs )to be able to
complete --w-f-b-c).

>
> Sure:
>
>   zstyle ':completion:*:*:configure:*' tag-order \
>       'options:-with:with\ options options:-other:other\ options' \
>       'options:-without:without\ options'
>   zstyle ':completion:*:options-with' ignored-patterns '^--with-*'
>   zstyle ':completion:*:options-without' ignored-patterns
> '^--without-*'
>   zstyle ':completion:*:options-other' ignored-patterns
> '--with(|out)-*'
>
> (Hmmmmm, tag labels. ;-)
>
> This says to first complete options two times, once using the tag
> `options-with' and once using the tag `options-other'. The
> ignored-patterns for these tags then make sure that you don't get the
> `--without-*' options. The second value of the tag-order
> style says to
> complete options using the tag `options-without' and there the
> ignored-patterns says that only the `--without-*' options are to be
> completed.
>

No, that's weird. I was able to make it running exactly once - and I
have a feeling, this was after cvs update/make/make install in one
window, sourcing styles in another one and trying there (that is, with
*old* zsh+functions). What I get currently, is

bor@itsrm2% cd samba-2.0.7/source
bor@itsrm2% ./configure --wi-swTAB
bor@itsrm2% cd samba-2.0.7/source
bor@itsrm2% ./configure --with-<CURSOR HERE>swatdir
Completing with options
--with-swatdir
Completing other options
--with-swatdir      --without-swatdir

with styles

bor@itsrm2% zstyle -L
zstyle ':completion:*' completer _oldlist _complete _match
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' ignore-parents parent pwd
zstyle ':completion:*' insert-unambiguous true
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt 'Showing %l'
zstyle ':completion:*' match-original both
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'r:|[._-]=*
r:|=*' 'r:|[._-]=** r:|=**'
zstyle ':completion:*' menu 'select=0'
zstyle ':completion:*' original true
zstyle ':completion:*' verbose true
zstyle ':completion:*' old-list _match
zstyle ':completion:*:*:configure:*' tag-order 'options:-with:with\
options options:-other:other\ options' 'options:-without:without\
options'
zstyle ':completion:*:options-with' ignored-patterns '^--with-*'
zstyle ':completion:*:options-without' ignored-patterns '^--without-*'
zstyle ':completion:*:options-other' ignored-patterns '^--with(|out)-*'

(I added ``^'' to the last pattern - assuming, it is beginning-of-word
anchor)

+ setopt nolistambiguous in .zshrc

>
> I'm not completely sure that I know what you mean by `select
> either of
> them', but of course completing after `--without-' will take the
> matches from the second set because in the first one nothing matches,
> and then there is _next_tags, bound to ^Xn to go to the next set of
> tags in the tag-order style.
>

Yes, that was it.

-andrej


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

* Re: Q about new completion (how to create several match sets)
@ 2000-04-27 11:05 Sven Wischnowsky
  2000-04-27 13:51 ` Andrej Borsenkow
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Wischnowsky @ 2000-04-27 11:05 UTC (permalink / raw)
  To: zsh-users


Andrej Borsenkow wrote:

> This goes to zsh-users as it may be of common interest. Bear in mind,
> this refers to the current 3.1.6 version from CVS.

3.1.7-pre-1, more precisely.

> In current form _configure completes both --with-option
> and --without-option in one shot. It means, that I always get at least
> two matches and (in my settings) cursor is placed after --with so I have
> to use additional keystroke to jump to the end of line.

Hm, this is ugly, but should it be enough to keep from supplying match 
specs?

> Is it possible to _externally_ (without changing _configure and/or
> _arguments, but with styles) configure completion system so, that I get
> two set of matches - first all --with-* and then all --without-* and can
> select either of them? This includes of course different status lines
> etc.

Sure:

  zstyle ':completion:*:*:configure:*' tag-order \
      'options:-with:with\ options options:-other:other\ options' \
      'options:-without:without\ options'
  zstyle ':completion:*:options-with' ignored-patterns '^--with-*'
  zstyle ':completion:*:options-without' ignored-patterns '^--without-*'
  zstyle ':completion:*:options-other' ignored-patterns '--with(|out)-*'

(Hmmmmm, tag labels. ;-)

This says to first complete options two times, once using the tag
`options-with' and once using the tag `options-other'. The
ignored-patterns for these tags then make sure that you don't get the
`--without-*' options. The second value of the tag-order style says to 
complete options using the tag `options-without' and there the
ignored-patterns says that only the `--without-*' options are to be
completed.

Actually, this is why we invented tag labels.

I'm not completely sure that I know what you mean by `select either of 
them', but of course completing after `--without-' will take the
matches from the second set because in the first one nothing matches,
and then there is _next_tags, bound to ^Xn to go to the next set of
tags in the tag-order style.

And for all of this and more and just to rub it in: have a look at
Peter's Guide, really good reading.

> Is it possible to set different completers for one command only?

No. I once asked if we should take the code that sets up the command
field of the context from _normal and put it into _main_complete. I
even once wrote that, there was a problem which I can't remember now,
but finally it worked, so I guess it would still be possible.

Bye
 Sven


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


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

end of thread, other threads:[~2000-04-27 14:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-27 10:11 Q about new completion (how to create several match sets) Andrej Borsenkow
2000-04-27 11:05 Sven Wischnowsky
2000-04-27 13:51 ` Andrej Borsenkow
2000-04-27 14:03 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).