zsh-users
 help / color / mirror / code / Atom feed
* compctl -l
@ 2003-10-14 23:02 DervishD
  2003-10-15  5:13 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: DervishD @ 2003-10-14 23:02 UTC (permalink / raw)
  To: Zsh Users

    Hi all :)

    I'm trying to learn now the old completion code (compctl), but
I'm clueless with option '-l'. I mean, I don't understand the
documentation for the flag, and I've assumed only two uses: with an
empty string as CMD every completion is a command completion (every
argument is considered a command itself), and with a name, the
completion for that name is used to add matches. That's all.

    What is this option for? How it works with extended completion?

    I know: compctl is deprecated, but the fact is that 100% of my
completion needs are fulfilled with a couple of compctl commands (I
want 'cd' to just complete dirs, rmdir just the same, etc...), and it
works damn well ;)) I've googled for information and searched the
mailing list archive with no success...

    Thanks in advance.

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


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

* Re: compctl -l
  2003-10-14 23:02 compctl -l DervishD
@ 2003-10-15  5:13 ` Bart Schaefer
  2003-10-15  9:37   ` DervishD
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2003-10-15  5:13 UTC (permalink / raw)
  To: Zsh Users

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


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

* Re: compctl -l
  2003-10-15  5:13 ` Bart Schaefer
@ 2003-10-15  9:37   ` DervishD
  2003-10-15 15:06     ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: DervishD @ 2003-10-15  9:37 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

    Hi Bart :))

    Definitely, if you ever come to Spain, I owe you a good dinner ;))

 * Bart Schaefer <schaefer@brasslantern.com> dixit:
> }     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?

    Yes, I've read them, although I've not tried to understand all of
them, since I've not read all the -x completion 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.

    Yes, this one was the first I got, because the examples are more
or less clear and my own experiments led me to this conclussion.

> "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

    Yes, this is another clear use I understood. The '-' doesn't
confuse compctl?

> "compctl -x ... -l ..." is the real meat

    And the one I really didn't understand. I mean, the -x args
(specially p, P and r comes to mind) delimit a portion of the command
line that must be completed specially (well, more or less), and the
-l says if it must be completed as a command itself or as an
specified command. No problem with it. What confused me is the
documentation about -l:

    -l CMD
        This option restricts the range of command line words that
are considered to be arguments. [...] . Completion is then performed
as if these had been given as arguments to the CMD supplied with the
option.

    IMHO, this option doesn't really restricts what in the command
line is an argument :??? It is more like an alias. The only way of
really restricting ranges is using -x. And the second paragraph...
Well, I must admit that my completion knowledge is worse than my
english, but I don't get the meaning of that... The completion is
performed in two ways: command-like or using 'CMD' completion :??

> Note that order is important with "-x"

    Yes, I've read that in the manual.

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

    I've used it with -u, for example, for completing user names,
just like the example in the manual.

    Well, thanks a lot for your explanation. The fact is that I got
more or less well how -l works, but the documentation is bizarre...

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


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

* Re: compctl -l
  2003-10-15  9:37   ` DervishD
@ 2003-10-15 15:06     ` Bart Schaefer
  2003-10-15 17:52       ` DervishD
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2003-10-15 15:06 UTC (permalink / raw)
  To: Zsh Users

On Oct 15, 11:37am, DervishD wrote:
}
}     Definitely, if you ever come to Spain, I owe you a good dinner ;))

I'll keep that in mind.

} >     compctl -l '' nohup noglob exec nice eval - time rusage
} 
}     Yes, this is another clear use I understood. The '-' doesn't
} confuse compctl?

It might confuse it if it were written in this order:

    compctl -l '' - nohup noglob exec nice eval time rusage

Once compctl begins parsing the list of command names, though, it won't
change back to parsing options, so "-" is just another command name in
the previous excerpt.

} > "compctl -x ... -l ..." is the real meat
} 
} What confused me is the documentation about -l:

That documentation was written by another non-native English speaker,
so perhaps a bit is lost in the double translation.

}     -l CMD
}         This option restricts the range of command line words that
} are considered to be arguments. [...] . Completion is then performed
} as if these had been given as arguments to the CMD supplied with the
} option.
} 
}     IMHO, this option doesn't really restricts what in the command
} line is an argument :???

When CMD is the empty string, it does.  In that case, the arguments are
restricted to words 2 through the end (with the original command name
as word zero), and word 1, which would normally be an argument, is a
command name.

However, you're right that this is badly worded in the case where CMD
is not empty.  It restricts the words considered to be arguments to
exactly the same set as before they were restricted, but changes the
interpretation of the word in command position.

I may be misremembering, but I think originally -l didn't have any
argument and always worked like the usage with an empty argument.  The
doc thus was written for that case and then mutated to cover the other.

} Well, I must admit that my completion knowledge is worse than my
} english, but I don't get the meaning of that... The completion is
} performed in two ways: command-like or using 'CMD' completion :??

It's trying to get across the notion that one word is completed as a
command name (using "compctl -C") and then the rest of the words are
completed as arguments of whatever command the first word names.  It's
describing what happens with different cursor placements at the time
completion is invoked.

-- 
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] 5+ messages in thread

* Re: compctl -l
  2003-10-15 15:06     ` Bart Schaefer
@ 2003-10-15 17:52       ` DervishD
  0 siblings, 0 replies; 5+ messages in thread
From: DervishD @ 2003-10-15 17:52 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

    Hi Bart :))

 * Bart Schaefer <schaefer@brasslantern.com> dixit:
> }     Definitely, if you ever come to Spain, I owe you a good dinner ;))
> I'll keep that in mind.

    I'm a very good cooker, and my wife too ;)) At least, I'm better
at cooking than at zsh completion XDD

> } >     compctl -l '' nohup noglob exec nice eval - time rusage
> }     Yes, this is another clear use I understood. The '-' doesn't
> } confuse compctl?
> Once compctl begins parsing the list of command names, though, it won't
> change back to parsing options, so "-" is just another command name in
> the previous excerpt.

    Nice :) I took note for writing my compctl recipes ;)
> }     -l CMD
> }         This option restricts the range of command line words that
> } are considered to be arguments. [...] . Completion is then performed
> } as if these had been given as arguments to the CMD supplied with the
> } option.
> }     IMHO, this option doesn't really restricts what in the command
> } line is an argument :???
> When CMD is the empty string, it does.

    Of course, because then any argument is completed as a command,
but that's a very fixed restriction. From the docs I assume that with
-l I can specify which words are commands and which are not. But
really -x is needed for that...

> The doc thus was written for that case and then mutated to cover
> the other.

    Since compctl is currently deprecated, would do any harm if I
rewrite this bit of documentation (not in Yodl, please, although I
can try...)? Please take into account that I'm not english-speaking
and the resulting test may be even worse than the current... But
anyway if the patch may be accepted I can do.
 
> } Well, I must admit that my completion knowledge is worse than my
> } english, but I don't get the meaning of that... The completion is
> } performed in two ways: command-like or using 'CMD' completion :??
> It's trying to get across the notion that one word is completed as a
> command name (using "compctl -C") and then the rest of the words are
> completed as arguments of whatever command the first word names.  It's
> describing what happens with different cursor placements at the time
> completion is invoked.

    Excuse me for insisting, but really that cannot be done without
-x. I mean, without -x you can only handle special cursor placements
using '-l' with the empty string. That way, word 2 is considered a
command and completed as such. But if you specify a command in the -l
option, then the completion is just an alias (well, more or less),
but doesn't treat specially word 2,3,etc... Please excuse if I sound
clueless: I'm really clueless O:))

    Thanks as always for your invaluable help. I really owe you a
dinner. Or two... No joking ;)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


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

end of thread, other threads:[~2003-10-15 17:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-14 23:02 compctl -l DervishD
2003-10-15  5:13 ` Bart Schaefer
2003-10-15  9:37   ` DervishD
2003-10-15 15:06     ` Bart Schaefer
2003-10-15 17:52       ` DervishD

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