zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: Getting original words after _arguments
Date: Sat, 20 Apr 2013 21:07:58 +0100	[thread overview]
Message-ID: <20130420210758.4b7d2427@pws-pc.ntlworld.com> (raw)
In-Reply-To: <130420083634.ZM10866@torch.brasslantern.com>

On Sat, 20 Apr 2013 08:36:34 -0700
Bart Schaefer <schaefer@brasslantern.com> 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 <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  reply	other threads:[~2013-04-20 20:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-19  8:21 Felipe Contreras
2013-04-20 15:36 ` Bart Schaefer
2013-04-20 20:07   ` Peter Stephenson [this message]
2013-04-20 22:03   ` Felipe Contreras
2013-04-21 18:55     ` Bart Schaefer
2013-04-21 20:42       ` Felipe Contreras

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=20130420210758.4b7d2427@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /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).