zsh-users
 help / color / mirror / code / Atom feed
* how can one let completion work *inside* zsh scripts?
@ 2000-07-26 10:57 Matthias Kopfermann
  0 siblings, 0 replies; 6+ messages in thread
From: Matthias Kopfermann @ 2000-07-26 10:57 UTC (permalink / raw)
  To: zsh mailinglist

I don't know how to do completion _within_ scripts.
At the prompt it is not a big problem for me but within scripts I
have no clue. What messages of the archive should I read
regarding this question or can you show me how to do that?

Matthias


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

* Re: how can one let completion work *inside* zsh scripts?
       [not found] <no.id>
  2000-07-26 16:24 ` Matthias Kopfermann
  2000-07-27 12:42 ` Matthias Kopfermann
@ 2000-08-01 15:34 ` Matthias Kopfermann
  2 siblings, 0 replies; 6+ messages in thread
From: Matthias Kopfermann @ 2000-08-01 15:34 UTC (permalink / raw)
  To: Sven Wischnowsky; +Cc: zsh-users

On Thu, Jul 27, 2000 at 03:21:07PM +0200, Sven Wischnowsky wrote:
> 
> But that almost suggest (at least to me, striving for consistency) to
> put everything into a string of the form `<descr>:<action>', where
> <action> is as in _arguments, i.e.:
> 
>   {...}               = evaluate `...'
>   (1 2)               = complete `1' and `2'
>   (( 1\:foo 2\:bar )) = complete `1' and `2' and describe them as
>                         `foo' and `bar' in the list
> 
> Hm, is this going too far? Or should we use the array-based solution
> and allow to give the description with another parameter?
it could be me alone, but i guess that arrays for one and then
parameters with another description would be nice.
perhaps because it is easier for the eye. have problems to have a
series of ::: after each other. (my biggest problem with the new
completion system. thats like using FPATH instead of fpath, i
like the new way that ZSH solves the problem of pathes with an
array. it's not the same here but it still is full of words.)
> Or should we just support compcontext-as-array without (a)
> description(s) (and the `func()' form) and let user's use functions if 
> they need descriptions?
hmm, what do the others think?


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

* Re: how can one let completion work *inside* zsh scripts?
@ 2000-07-27 13:21 Sven Wischnowsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Wischnowsky @ 2000-07-27 13:21 UTC (permalink / raw)
  To: zsh-users


Matthias Kopfermann wrote:

> > To zsh-workers (and everyone else interested): hm, is this becoming
> > FAQish enough to make is simplify it? For example we could allow
> > compcontext to be set to `foo()' to make it just call function
> > `foo'. And we could allow it to be set to an array and then make
> > completion offer its elements as possible completions.
> I am for it ! The easier the better. At least normally I
> tend to think that way.

I'll add something like this (mostly because it doesn't cost us
anything if compcontext isn't set).

But first some questions: _arguments and friends allow `(( 1\:foo 2\:bar ))'
to generate the matches `1' and `2' and make them be shown with
descriptions `foo' and `bar', respectively. That might be nice to have 
here, too, think.

But stuffing them all in one string isn't needed here. Hm. Maybe if
all string contain an (non-backslash-quoted) colon, take everything
before them as the matches and the stuff after them as the
descriptions. People would then have to remember to quote colons when
setting compcontext from something automatically generated such as
filenames (using globbing).

And then we should allow the calling function to register a
description string for the whole set of matches (the things one gets
by setting the format style).

But that almost suggest (at least to me, striving for consistency) to
put everything into a string of the form `<descr>:<action>', where
<action> is as in _arguments, i.e.:

  {...}               = evaluate `...'
  (1 2)               = complete `1' and `2'
  (( 1\:foo 2\:bar )) = complete `1' and `2' and describe them as
                        `foo' and `bar' in the list

Hm, is this going too far? Or should we use the array-based solution
and allow to give the description with another parameter?

Or should we just support compcontext-as-array without (a)
description(s) (and the `func()' form) and let user's use functions if 
they need descriptions?


Bye
 Sven


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


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

* Re: how can one let completion work *inside* zsh scripts?
       [not found] <no.id>
  2000-07-26 16:24 ` Matthias Kopfermann
@ 2000-07-27 12:42 ` Matthias Kopfermann
  2000-08-01 15:34 ` Matthias Kopfermann
  2 siblings, 0 replies; 6+ messages in thread
From: Matthias Kopfermann @ 2000-07-27 12:42 UTC (permalink / raw)
  To: Sven Wischnowsky; +Cc: zsh-users

> To zsh-workers (and everyone else interested): hm, is this becoming
> FAQish enough to make is simplify it? For example we could allow
> compcontext to be set to `foo()' to make it just call function
> `foo'. And we could allow it to be set to an array and then make
> completion offer its elements as possible completions.
I am for it ! The easier the better. At least normally I
tend to think that way.

Matthias


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

* Re: how can one let completion work *inside* zsh scripts?
       [not found] <no.id>
@ 2000-07-26 16:24 ` Matthias Kopfermann
  2000-07-27 12:42 ` Matthias Kopfermann
  2000-08-01 15:34 ` Matthias Kopfermann
  2 siblings, 0 replies; 6+ messages in thread
From: Matthias Kopfermann @ 2000-07-26 16:24 UTC (permalink / raw)
  To: Sven Wischnowsky; +Cc: zsh-users

On Wed, Jul 26, 2000 at 02:00:11PM +0200, Sven Wischnowsky wrote:
> 
> Then... do you really need a *script*? Or would a function do?
no, as long as it is interactive i don't care. But i was not
thinking of filename completion, more of the ability to let users
easily choose options whatever. Another way is select of course
but i always wanted to know how to be able to do it with little
zsh scripts, too. 
>. If you need something else
> than filename completion, the `offical' way to do that is to (locally)
> define the parameter compcontex and set it to the name of the
> completion context that should be used for completion.
this was new to me. Thanx for explaining!

Matthias





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

* Re: how can one let completion work *inside* zsh scripts?
@ 2000-07-26 12:00 Sven Wischnowsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Wischnowsky @ 2000-07-26 12:00 UTC (permalink / raw)
  To: zsh-users


Matthias Kopfermann wrote:

> I don't know how to do completion _within_ scripts.
> At the prompt it is not a big problem for me but within scripts I
> have no clue. What messages of the archive should I read
> regarding this question or can you show me how to do that?

First, you use `vared', inside it you have completion.

Then... do you really need a *script*? Or would a function do?

With scripts it's probably better to use compctl so that you don't
have to call compinit, unless you don't care about that extra bit of
init time needed.

With compctl you just set up a `compctl -T' to complete what you want
(filename completion should be standard). If you want completion in
the first column (instead of a tab being inserted) you can use one of
a few tricks mentioned in the `Completion in the first character
position' thread posted on zsh-users in the last few days (including
today).

If you want to use the new completion system (probably preferrable if
the thing can be a function), look at Functions/Misc/nslookup (and
Completion/User/_nslookup) for an example. If you need something else
than filename completion, the `offical' way to do that is to (locally)
define the parameter compcontex and set it to the name of the
completion context that should be used for completion. I.e. to one of
the keys of the $_comps association, i.e. one of the things a `compdef
<func> <context>' has been done for. If there isn't one matching your
needs, add it.

To zsh-workers (and everyone else interested): hm, is this becoming
FAQish enough to make is simplify it? For example we could allow
compcontext to be set to `foo()' to make it just call function
`foo'. And we could allow it to be set to an array and then make
completion offer its elements as possible completions.

Bye
 Sven


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


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

end of thread, other threads:[~2000-08-02 19:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-26 10:57 how can one let completion work *inside* zsh scripts? Matthias Kopfermann
2000-07-26 12:00 Sven Wischnowsky
     [not found] <no.id>
2000-07-26 16:24 ` Matthias Kopfermann
2000-07-27 12:42 ` Matthias Kopfermann
2000-08-01 15:34 ` Matthias Kopfermann
2000-07-27 13:21 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).