From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19747 invoked from network); 26 Jul 2000 12:01:53 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 26 Jul 2000 12:01:53 -0000 Received: (qmail 8803 invoked by alias); 26 Jul 2000 12:00:22 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3339 Received: (qmail 8793 invoked from network); 26 Jul 2000 12:00:17 -0000 Date: Wed, 26 Jul 2000 14:00:11 +0200 (MET DST) Message-Id: <200007261200.OAA13613@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-users@sunsite.auc.dk In-reply-to: Matthias Kopfermann's message of Wed, 26 Jul 2000 12:57:58 +0200 Subject: Re: how can one let completion work *inside* zsh scripts? 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 ' 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