From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29000 invoked by alias); 22 Nov 2012 17:48:15 -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: 30816 Received: (qmail 25131 invoked from network); 22 Nov 2012 17:48:12 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <121122094747.ZM7951@torch.brasslantern.com> Date: Thu, 22 Nov 2012 09:47:47 -0800 In-reply-to: Comments: In reply to Felipe Contreras "Bug with emulation in completion?" (Nov 22, 10:41am) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Bug with emulation in completion? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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.