From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17967 invoked by alias); 5 Oct 2012 21:38:00 -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: 30716 Received: (qmail 19900 invoked from network); 5 Oct 2012 21:37:48 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 209.85.212.177 is neither permitted nor denied by SPF record at ntlworld.com) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-proxyuser-ip:date:from:to:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type :content-transfer-encoding:x-gm-message-state; bh=hgzgAsvRhldi714AJc/irEZSSU6DHwFZzs3IOlnDUHk=; b=WhVpi/oRZ9F+tj0sSpZPoKXqaPjqDeoWDqFsJPjoTlK+o8+NT0fKSnM5Uh0BRsyNgR zrhAiS1YrcVeI5HnpV1mo3vUY7c8x1YB4Y0nZRHlymEFSwWkI/nIefATwXWb/SuG7r/6 iCHYnrCLoFdGix3hK2U7YtjGeGGFNiunbgmvuElC0MD6o4tXe/YhEgtWdm7zpWM8IM9r ehNYLUz5UrM7zUIa1o1IMtmnrRIYULnVVnZiPc25Lhq4g/h1JgXtS1ni6OJpcf2QJWqk EPFUUuEKyTE4Jp7W/Xs65Af4zjU1bdV56UF4rfZDocXRNE7zIb+m+uRzmLTLqbeb28Dh Qgkg== X-ProxyUser-IP: 82.8.55.192 Date: Fri, 5 Oct 2012 22:32:28 +0100 From: Peter Stephenson To: Zsh workers Subject: Re: autoload -X inside an anonymous function Message-ID: <20121005223228.408a7b2f@pws-pc.ntlworld.com> In-Reply-To: <120924115023.ZM22732@torch.brasslantern.com> References: <13194.1347934322@thecus.kiddle.eu> <120918095827.ZM23535@torch.brasslantern.com> <1348021726.8764.YahooMailNeo@web29706.mail.ird.yahoo.com> <120919075811.ZM24917@torch.brasslantern.com> <20120920203537.29bb1d18@pws-pc.ntlworld.com> <120924115023.ZM22732@torch.brasslantern.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQl/pgMRUtvMM5dQaSMMlZOxBAB9Qp/3n0SDit1SE79AgaQ0D/qdgjWOkE+qBwx399a+nLuO On Mon, 24 Sep 2012 11:50:23 -0700 Bart Schaefer wrote: > On Sep 20, 8:35pm, Peter Stephenson wrote: > } > } I discovered while doing this that "autoload +X _path_files" didn't > } work, it doesn't like the absence of the semicolon in the braces. If > } anyone wants to work out why, be me guest. > > Works for me with 4.3.17-test-2 ... and also with 5.0.0-dev-0 just now > compiled from CVS (edited _path_files to remove your semicolon again). > > Did you try autoload -z +X ? I've tracked this mystery down... I had "ignoreclosebraces" set because I had been trying it out from when the option was added. This is correctly turned off by the completion code, but it caused loading of _path_files outside the completion code to fail. However, this opens a can of worms, or reveals an open can of worms, or at least perturbs the wave function of the universe sufficiently that measurement reveals the can of worms to be in the opened state. (I can, however, understand that Schroedinger's Cat is likely to remain more popular than Stephenson's Wormcan.) Sorry, it's Friday evening. Naively, you might have thought that simply making ignoreclosebraces an emulation setting (which might be the right thing to do anyway, as below) would fix this, but actually we seem to be missing a trick: the -z flag *doesn't* put the shell into zsh emulation during the load, although the manual does confusingly use the word "emulation" to describe its effect. Furthermore, emulate zsh -c 'autoload -z stuff' (where stuff is a function relying on being able to omit the semicolon before a closing brace) doesn't work, although emulate zsh -c 'autoload +X -z stuff' does work, because the function is loaded while the emulation is still in effect. More explicitly, the emulate in this case is only "sticky" for functions declared in it, not for functions marked for autoload in it. Maybe this needs to change? I explicitly did it this way: /* No sticky emulation for autoloaded functions */ shf->emulation = 0; and I wrote in the accompanying message (zsh-workers/26546): Note that sticky emulation is not propagated to autoloaded functions, neither when the autoload is set up nor when they are loaded, nor does autoloading a function provide the same sort of firewall as sticky emulation. Defining a function with the special "functions" parameter is treated the same as defining a function inline in the normal way. but I'm not sure I thought this through properly. If I got it wrong, the fix for the case here is trivial (and I've verified it works). The more I think about it, the less I can think of a good reason for having an autoload declared within a sticky emulation lose the stickiness. Beyond that, I'm not sure what the answer is; is making -z force zsh emulation reasonable? I don't necessarily think making -k force ksh emulation is reasonable, the function might be a zsh function that just happens to be written using the ksh format for autoloads. I may simply be expecting too much, though it would certainly be good to be able to ensure a function can be loaded irrespective of the options currently in effect. On the whole I'd be inclined to reverse my decision not to propagate stickiness to autoloads, and to document that -z only affects the autoload style and that emulate zsh -c 'autoload -Uz ...' is the way to ensure functions are loaded with appropriate options. This generalises in a natural way to other emulations in a way overloading the -z flag doesn't. Index: Src/options.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/options.c,v retrieving revision 1.62 diff -p -u -r1.62 options.c --- Src/options.c 21 Aug 2012 18:03:03 -0000 1.62 +++ Src/options.c 5 Oct 2012 21:02:18 -0000 @@ -160,7 +160,7 @@ static struct optname optns[] = { {{NULL, "histverify", 0}, HISTVERIFY}, {{NULL, "hup", OPT_EMULATE|OPT_ZSH}, HUP}, {{NULL, "ignorebraces", OPT_EMULATE|OPT_SH}, IGNOREBRACES}, -{{NULL, "ignoreclosebraces", 0}, IGNORECLOSEBRACES}, +{{NULL, "ignoreclosebraces", OPT_EMULATE}, IGNORECLOSEBRACES}, {{NULL, "ignoreeof", 0}, IGNOREEOF}, {{NULL, "incappendhistory", 0}, INCAPPENDHISTORY}, {{NULL, "interactive", OPT_SPECIAL}, INTERACTIVE}, -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/