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

Re: compctl -l



(If anyone else would like to jump in, here ... I miss Sven. :-)

On Oct 15,  1:02am, DervishD wrote:
}
}     I'm trying to learn now the old completion code (compctl), but
} I'm clueless with option '-l'.

Have you looked at Misc/compctl-examples yet?

"compctl -l foo bar" means that, if there exists a compctl for "foo",
then use that when completing arguments of "bar".  It's like aliasing.
If there is not a compctl for "foo", it's useless.

"compctl -l '' bar" means that "bar" should be ignored for purposes of
completion; that is, the first word after "bar" completes as a command,
and the second and further words complete as arguments of the command
named by the first word.  The classic example is
    compctl -l '' nohup noglob exec nice eval - time rusage

"compctl -x ... -l ..." is the real meat; the arguments to -x tell how
to delimit a portion of the command line, and then -l says that when
the cursor is within those limits, completion should behave as in one
of the two cases above.

Note that order is important with "-x": if the "-l" comes *before* the
"-x" as in
    compctl -l '' -x 'p[1]' -f -- . source
then that means to ignore "source" or "." only when the -x arguments
are false -- in this example, 'p[1]' means "the cursor is in the first
word after the command name"; when 'p[1]' is true, files ("-f") are
completed, otherwise "-l ''" is used, so the file name is treated as a
command name and the compctl for that (if any) is used to complete the
other arguments.

Of course this stuff about -x generalizes to other options besides -l,
but -l is what you were asking about ...



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