zsh-users
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-users@sunsite.auc.dk
Subject: Re: how can one let completion work *inside* zsh scripts?
Date: Wed, 26 Jul 2000 14:00:11 +0200 (MET DST)	[thread overview]
Message-ID: <200007261200.OAA13613@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Matthias Kopfermann's message of Wed, 26 Jul 2000 12:57:58 +0200


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


             reply	other threads:[~2000-07-26 12:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-26 12:00 Sven Wischnowsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-07-27 13:21 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-26 10:57 Matthias Kopfermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200007261200.OAA13613@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-users@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).