From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14180 invoked by alias); 20 Apr 2013 20:16:35 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 31299 Received: (qmail 9089 invoked from network); 20 Apr 2013 20:16:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 209.85.212.174 is neither permitted nor denied by SPF record at ntlworld.com) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-proxyuser-ip:date:from:to:subject:message-id :in-reply-to:references:x-mailer:mime-version:content-type :content-transfer-encoding:x-gm-message-state; bh=sAqbYU4Wkc0xAx4VTMTTdMfDn8Ss9V8hwUSkD2MN2OE=; b=ZgOAxhJOefjP8AqU6mdW44vUuCkmuNRtC1SMBH0+ROWxp46lRLSuMXIQXjHxpGAh7T pshh/Q+S/piYTVD9PwaG1kBHweTqo2piGWaB7j5pRWhiZqk/p1iFrXFrr0vbFQkPRv8i gI4gOwRPatpvPYitv8vJFETCR3/F9OoYdJdEI1QvJOCmiTBl5TMKxYrG5G+r9JSzhbHe UHITiI5NZvsjG5OUYznXkwx+EuaE7HySM0gqKS1HOR3w0DIrSNFwMzF9z4PiP5aYsCcO 7tYEj4CPqZM//KE/lmWnMSJ4AsCceO7j34sFdiFnDbdr6Np2gnhPON4VuzQ2d64ASV/V XLEQ== X-Received: by 10.194.8.99 with SMTP id q3mr36882436wja.34.1366488481421; Sat, 20 Apr 2013 13:08:01 -0700 (PDT) X-ProxyUser-IP: 86.6.30.159 Date: Sat, 20 Apr 2013 21:07:58 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Getting original words after _arguments Message-ID: <20130420210758.4b7d2427@pws-pc.ntlworld.com> In-Reply-To: <130420083634.ZM10866@torch.brasslantern.com> References: <130420083634.ZM10866@torch.brasslantern.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnP0QRDNCyPWeyDBSGNHwo/fq6etH5ns4TKwaWo4Tm9yp09dWH3GSs9eexiKFczhaGAS2OC On Sat, 20 Apr 2013 08:36:34 -0700 Bart Schaefer wrote: > On Apr 19, 3:21am, Felipe Contreras wrote: > } > } orig_words=( ${words[@]} ) > } _arguments -C '--stuff' && _ret=0 > } words=( ${orig_words[@]} ) > } > } I need to have access to the original array of words, before the > } _arguments stuff is run, and so far the only I can achieve that is by > } manually storing the old ones, and then restoring them. > > Hmm. The variable named "words" is special to the completion system, and > if _arguments modifies it that probably means that later stuff is going > to depend on the state in which $words was left. You may confuse things > by stuffing $orig_words back into words. This has just reminded me that one special aspect of "words" is that it gets restored after the current function exits. So if it's feasible to do the additional thing you want in a separate completion function --- I have a feeling even the caller would be good enough, so even a trivial function to nest the call to _arguments --- that's one way out. (_arguments changes the value of "compstate[restore]", which is why the altered value of "words" propagates back from it.) -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/