Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Getting original words after _arguments



On Sat, Apr 20, 2013 at 10:36 AM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> 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.

I know, I'm not going to usw zsh completion after that point.

> Is there some reason you can't just work on orig_words in the rest of
> your function?

It's not my code, it's git.git's bash completion, which uses 'word'.

> } Is there an easier way? Surely the contents of the command line must
> } be stored somewhere.
>
> If you literally want the contents of the command line, a completion
> widget is still a widget, so you can examine $BUFFER et al.  I'm not
> sure this is "easier" than copying the original state ...

Maybe not.

-- 
Felipe Contreras



Messages sorted by: Reverse Date, Date, Thread, Author