zsh-users
 help / color / mirror / code / Atom feed
* Menu-completion for particular commands
@ 2000-05-28 22:47 David Bustos
  2000-05-29  0:12 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: David Bustos @ 2000-05-28 22:47 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 141 bytes --]

How do I get zsh to menu-complete arguments to vim and gvim, while leaving
normal completion for other commands alone?

Thanks,
David Bustos

[-- Attachment #2: Type: application/pgp-signature, Size: 203 bytes --]

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

* Re: Menu-completion for particular commands
  2000-05-28 22:47 Menu-completion for particular commands David Bustos
@ 2000-05-29  0:12 ` Bart Schaefer
  2000-05-29  1:48   ` David Bustos
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2000-05-29  0:12 UTC (permalink / raw)
  To: David Bustos, zsh-users

On May 28,  3:47pm, David Bustos wrote:
} Subject: Menu-completion for particular commands
}
} How do I get zsh to menu-complete arguments to vim and gvim, while leaving
} normal completion for other commands alone?

In 3.0.x, you can't, really; the closest you could come would be to use
`setopt auto_menu' so that one tab does normal completion and two tabs
starts menu completion.  That affects all commands, though.

In 3.1.6+, you can do it with the new completion system.  (You're probably
best off with at least 3.1.7-pre-4, or wait a few days for the real 3.1.7
release.)

If you haven't already set up the completion system, do this:

zsh% autoload -U compinstall
zsh% compinstall

This will lead you through a bunch of menus to configure the completion
system.  (If the above doesn't work, you've probably overwritten zsh's
default value of $fpath; fix that in your ~/.zshrc or wherever and start
again.)  Once you have that ready, you can do this:

zsh% vim <C-x h>
tags in context :completion::complete:vim::
    all-files  (_files _default)

That is, you type v i m space control-X h and the next two lines are what
zsh prints back at you.  These show you the name of the completion context
for that position on that command line, and the set of tags that zsh uses
to look up completion styles in that context.

Next you look through the "Completion System Configuration" section of the
doc to find something about menu completion.  Lo and behold:

menu
     If this is set to true in a given context, using any of the tags
     defined for a given completion, menu completion will be used. The
     tag `default' can be used to match any tag, but a specific tag
     will take precedence.  [... a lot of other stuff ...]

With these two pieces of information, you're ready to write a "zstyle"
command:

zsh% zstyle :completion::complete:vim::default menu true

Presto, menu completion for vim.  You could do a second similar command
for gvim, but instead notice that it's possible to use glob patterns in
any of the places between the colons in a context.  So:

zsh% zstyle ':completion::complete:(g|)vim::default' menu true

The `(g|)' means to match a `g' or nothing.  So there's your style to
menu-complete the arguments of vim and gvim, leaving everything else
alone.  Put it in your .zshrc with all the other styles that compinstall
added for you, and happy tabbing.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: Menu-completion for particular commands
  2000-05-29  0:12 ` Bart Schaefer
@ 2000-05-29  1:48   ` David Bustos
  2000-05-29  2:42     ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: David Bustos @ 2000-05-29  1:48 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 893 bytes --]

On Mon, May 29, 2000 at 12:12:58AM +0000, Bart Schaefer wrote:
> On May 28,  3:47pm, David Bustos wrote:
> } Subject: Menu-completion for particular commands
> }
> } How do I get zsh to menu-complete arguments to vim and gvim, while leaving
> } normal completion for other commands alone?
> 
[completion installation, context determination, and the menu style]

> With these two pieces of information, you're ready to write a "zstyle"
> command:
> 
[snip]
> 
> zsh% zstyle ':completion::complete:(g|)vim::default' menu true
This didn't work immediately.  ':completion:*:(g|)vim:*' did, though.

[snip]
> 
> -- 
> Bart Schaefer                                 Brass Lantern Enterprises
> http://www.well.com/user/barts              http://www.brasslantern.com
> 
> Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

Thanks alot,
David Bustos

[-- Attachment #2: Type: application/pgp-signature, Size: 203 bytes --]

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

* Re: Menu-completion for particular commands
  2000-05-29  1:48   ` David Bustos
@ 2000-05-29  2:42     ` Bart Schaefer
  0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2000-05-29  2:42 UTC (permalink / raw)
  To: zsh-users

On May 28,  6:48pm, David Bustos wrote:
} Subject: Re: Menu-completion for particular commands
}
} On Mon, May 29, 2000 at 12:12:58AM +0000, Bart Schaefer wrote:
} > 
} > zsh% zstyle ':completion::complete:(g|)vim::default' menu true
} This didn't work immediately.  ':completion:*:(g|)vim:*' did, though.

Hmm, the documentation appears to be fibbing about the `default' tag.
You only need one of those `*', though:

    zstyle ':completion::complete:(g|)vim::*' menu true

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: Menu-completion for particular commands
  2000-05-29  8:35 Sven Wischnowsky
@ 2000-05-29 10:04 ` Bart Schaefer
  0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2000-05-29 10:04 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-users

On May 29, 10:35am, Sven Wischnowsky wrote:
} Subject: Re: Menu-completion for particular commands
}
} > > zsh% zstyle ':completion::complete:(g|)vim::default' menu true
} > This didn't work immediately.  ':completion:*:(g|)vim:*' did, though.
} 
} Yep. The default tag is tested at the very beginning, when almost
} nothing of the context is set up.

In that case the discussion of `default' under doc for the `menu' style
is, at least, misleading.  Shouldn't it be removed from that paragraph
and discussed more genearally somewhere earlier?  (Perhaps lengthen the
explanation under "Standard Tags" a bit?)

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: Menu-completion for particular commands
@ 2000-05-29  8:35 Sven Wischnowsky
  2000-05-29 10:04 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Sven Wischnowsky @ 2000-05-29  8:35 UTC (permalink / raw)
  To: zsh-users


David Bustos wrote:

> On Mon, May 29, 2000 at 12:12:58AM +0000, Bart Schaefer wrote:
>
> ...
>
> > zsh% zstyle ':completion::complete:(g|)vim::default' menu true
> This didn't work immediately.  ':completion:*:(g|)vim:*' did, though.

Yep. The default tag is tested at the very beginning, when almost
nothing of the context is set up.

Bye
 Sven


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


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

end of thread, other threads:[~2000-05-29 10:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-28 22:47 Menu-completion for particular commands David Bustos
2000-05-29  0:12 ` Bart Schaefer
2000-05-29  1:48   ` David Bustos
2000-05-29  2:42     ` Bart Schaefer
2000-05-29  8:35 Sven Wischnowsky
2000-05-29 10:04 ` Bart Schaefer

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