Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: (forw) --help able programs and completion

Matthias Kopfermann wrote:

> On Mon, Jun 26, 2000 at 11:20:20AM +0100, Peter Stephenson wrote:
> > Use compinstall.  I would like feedback, but the format is restricted by
> > the fact that it will be written in zsh, so there are menus but no dialogue
> > boxes.
> Which is really an approach in the right direction. Now my
> question is: Where do i find the `--help' completion here?

Nowhere. compinstall is about configuration with styles (mostly).

What you need is to tell the completion system to use a certain
function to complete after the commands in question. That's done with

 compdef <func-to-call> <commands...>

We have a function to complete the options described by the `--help'
output, it's called `_use_lo', so, once you have identified all the
commands for which completion should call the command with `--help'
and complete the options, you can do:

  compdef _use_lo cmd1 cmd2 cmd3 ...

In normal setup, _use_lo is only used for `gls' because we have to be
careful. Not every Unix supports `--help' for (almost) every command
and to complete the options, we have to call the command which may be
dangerous if it doesn't understand `--help', obviously.

To -workers (and to anyone who wants to use the above): it seems
_use_lo wasn't updated for quite some time, the  patch below should
make it more user-friendly.


Index: Completion/User/_use_lo
RCS file: /cvsroot/zsh/zsh/Completion/User/_use_lo,v
retrieving revision
diff -u -r1.1.1.6 _use_lo
--- Completion/User/_use_lo	2000/03/11 00:05:30
+++ Completion/User/_use_lo	2000/06/26 10:41:34
@@ -3,4 +3,4 @@
 # This is for GNU-like commands which understand the --help option,
 # but which do not otherwise require special completion handling.
-_arguments -- || _default
+_arguments '*:arg: _default' --

Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx

Messages sorted by: Reverse Date, Date, Thread, Author