Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug with emulation in completion?
- X-seq: zsh-workers 30819
- From: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Bug with emulation in completion?
- Date: Sat, 24 Nov 2012 14:47:40 +0100
- Cc: Felipe Contreras <felipecontreras@xxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=gmail.com; s=20120113;        h=mime-version:in-reply-to:references:date:message-id:subject:from:to         :cc:content-type;        bh=d0J1jZQKG7OJdFSwpQtA4DaddglARRiOEfFyaBpa+kk=;        b=CfqdT2OaW3dudfqebKTiBEUjKrau5ZzoIanX/I/cnpKBgOOk9LLeH5u94cRzQlAvYW         /A26rSWPmx6g2x3Ur4DfQK/utw9C99RiH8oyHjB9pH7fnUsmCqB6jFE5vIzz2MnvLPtD         WTyOs/pO0pjlO+2zjNY6Wl6EThtb9Eb10Ifv9RRIXaYy8B4VR5yUYMWLHMxVO8hE+GvR         C4KE9r4gGxt6hwiQ1NbzTEV44cM07StKgx84aPv5EyIn+yVK49OR+VQbmcDS0SPyU7QZ         esxhxKaqzoMEITc+fEXjGetqCTdMjRxlRUDcPSr0BaYGTEgn4scfMqE2F8PjWn0phAGU         7qQQ==
- In-reply-to: <CAMP44s0rnW6ebWHc85NR64FHUdXEF9_zE7SuG6Pnoh5JxpNMgw@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAMP44s0rnW6ebWHc85NR64FHUdXEF9_zE7SuG6Pnoh5JxpNMgw@mail.gmail.com>
> On Nov 22, 10:41am, Felipe Contreras wrote:
> }
> } _foo_1 () {
> }   emulate -L zsh
> }   _arguments '--one' '--two'
> } }
> }
> } compdef _foo_1 foo
>
> The completion system sets up a very specific setopt state that all the
> supplied completion functions such as _arguments expect to have in scope
> at the time they are run.
>
> There have recently been some changes that would allow that state to be
> made "sticky" for individual functions, so that it is automatically put
> in place when they are called, but that is only available in development
> builds of the shell at this point (and hasn't actually been applied to
> the completion functions even there AFAIK).
>
> The workaround is to introduce an additional function scope for the new
> emulation state that you need, call that, and then call _arguments after
> it returns (where the previous state will have been restored).  In recent
> zsh releases you can do that with an anonymous scope like so:
>
> _foo_1 () {
>   () {
>     emulate -L zsh
>     : do something you need to do
>   }
>   _arguments '--one' '--two'
> }
>
> In older zsh you'll have to explicitly declare a second function to be
> called from within _foo_1.
That's not what I need.
_foo_2 () {
  emulate -L zsh
 _arguments '--one' '--two'
}
_foo_3 () {
  : different stuff
}
_foo_1 () {
  emulate -L ksh
  : do something
  _foo_$1
}
So now instead of simply doing 'emulate -L zsh' on the few functions
that I'm interested in, I have to shuffle around to code so that ksh
and zsh code doesn't mix together =/
Cheers.
-- 
Felipe Contreras
Messages sorted by:
Reverse Date,
Date,
Thread,
Author