From: Felipe Contreras <felipe.contreras@gmail.com>
To: zsh-workers@zsh.org
Cc: Felipe Contreras <felipecontreras@gmail.com>
Subject: Re: Bug with emulation in completion?
Date: Sat, 24 Nov 2012 14:47:40 +0100 [thread overview]
Message-ID: <CAMP44s2NOTgOj8yi=vv=B9h28pwoGmm7LMhNMG=d-3rZuXzMxQ@mail.gmail.com> (raw)
In-Reply-To: <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
next prev parent reply other threads:[~2012-11-24 14:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-22 9:41 Felipe Contreras
2012-11-22 17:47 ` Bart Schaefer
2012-11-24 20:33 ` Peter Stephenson
2012-11-25 6:23 ` Bart Schaefer
2012-11-24 13:47 ` Felipe Contreras [this message]
2012-11-24 17:39 ` Bart Schaefer
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='CAMP44s2NOTgOj8yi=vv=B9h28pwoGmm7LMhNMG=d-3rZuXzMxQ@mail.gmail.com' \
--to=felipe.contreras@gmail.com \
--cc=felipecontreras@gmail.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).