From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9713 invoked by alias); 20 Sep 2012 19:35:53 -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: 30692 Received: (qmail 12794 invoked from network); 20 Sep 2012 19:35:50 -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: 74.125.83.43 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=1P1o0ho3vLEXrCXIUrAXh2vFc9/GGtdDecNh+DVJn00=; b=UQhwGSfuW/VyDvI8b2laj+V8mNnyl9rXKLFZZtyboE71aFFR8Cny4jPSRh8HITFOat 73gGxE222WcZohcgtmgRaTOi9bz/F2T0NQ8Kw+HuwLGFQXug214h4N/yXFOoDkpd3tqv c3qYnL/JMOpwm4Uew9xU+No2ZjN4rKeXpLuQGIdRB72/odqojq7qlTwQ54iWgvTEpGs0 wDBwj83FVgn4FavpHsmfxm80w6ayVJYcSkaGZrBD51APPOeKGVGz2Df+qhBY31lxihKq DvQLaFtEDJyKE8zS3p5ug897qIATi/22oK7AFwapQGZBZtEH7jT5JHulfVze6FfLI5jN cRYQ== X-ProxyUser-IP: 86.6.16.18 Date: Thu, 20 Sep 2012 20:35:37 +0100 From: Peter Stephenson To: Zsh workers Subject: Re: autoload -X inside an anonymous function Message-ID: <20120920203537.29bb1d18@pws-pc.ntlworld.com> In-Reply-To: <120919075811.ZM24917@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> 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: ALoCoQkrakfzcHEH5bYn8GsuooDHkkExSF6srFAuxA0CbYr1YN159xWQrZ18CWIVtHfWlFUxy4Oz On Wed, 19 Sep 2012 07:58:11 -0700 Bart Schaefer wrote: > } I can't see any reason why it wouldn't work if you simply > } added -m to the list of options accepted by autoload (or -X to > } functions). > > I misread the test at 2686 -- that one is using OPT_MINUS(), whereas > the one at 2876 is OPT_ISSET(). So this is there specifically *to* > implement "autoload -m +X", even though autoload doesn't currently > allow -m in its args list. Seems straightforward with an extra test. 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. Index: Completion/Unix/Type/_path_files =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v retrieving revision 1.58 diff -p -u -r1.58 _path_files --- Completion/Unix/Type/_path_files 5 Sep 2011 22:01:12 -0000 1.58 +++ Completion/Unix/Type/_path_files 20 Sep 2012 19:33:31 -0000 @@ -198,7 +198,7 @@ zstyle -T ":completion:${curcontext}:pat path_completion=1 if [[ -n "$compstate[pattern_match]" ]]; then - if { [[ -z "$SUFFIX" ]] && _have_glob_qual "$PREFIX" complete } || + if { [[ -z "$SUFFIX" ]] && _have_glob_qual "$PREFIX" complete; } || _have_glob_qual "$SUFFIX" complete; then # Copy all glob qualifiers from the line to # the patterns used when generating matches Index: Doc/Zsh/builtins.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v retrieving revision 1.142 diff -p -u -r1.142 builtins.yo --- Doc/Zsh/builtins.yo 21 Aug 2012 18:03:03 -0000 1.142 +++ Doc/Zsh/builtins.yo 20 Sep 2012 19:33:31 -0000 @@ -108,7 +108,7 @@ ifnzman(noderef(Aliasing)). findex(autoload) cindex(functions, autoloading) cindex(autoloading functions) -item(tt(autoload) [ {tt(PLUS())|tt(-)}tt(UXktz) ] [ tt(-w) ] [ var(name) ... ])( +item(tt(autoload) [ {tt(PLUS())|tt(-)}tt(UXkmtz) ] [ tt(-w) ] [ var(name) ... ])( Equivalent to tt(functions -u), with the exception of tt(-X)/tt(+X) and tt(-w). @@ -129,6 +129,9 @@ undefined and marked for autoloading. I enabled, the function created will contain the contents of the file plus a call to the function itself appended to it, thus giving normal ksh autoloading behaviour on the first call to the function. +If the tt(-m) flag is also given each var(name) is treated as a +pattern and all functions already marked for autoload that match the +pattern are loaded. With the tt(-w) flag, the var(name)s are taken as names of files compiled with the tt(zcompile) builtin, and all functions defined in them are Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.262 diff -p -u -r1.262 builtin.c --- Src/builtin.c 8 Sep 2012 19:19:07 -0000 1.262 +++ Src/builtin.c 20 Sep 2012 19:33:31 -0000 @@ -46,7 +46,7 @@ static struct builtin builtins[] = BUILTIN(".", BINF_PSPECIAL, bin_dot, 1, -1, 0, NULL, NULL), BUILTIN(":", BINF_PSPECIAL, bin_true, 0, -1, 0, NULL, NULL), BUILTIN("alias", BINF_MAGICEQUALS | BINF_PLUSOPTS, bin_alias, 0, -1, 0, "Lgmrs", NULL), - BUILTIN("autoload", BINF_PLUSOPTS, bin_functions, 0, -1, 0, "ktTUwXz", "u"), + BUILTIN("autoload", BINF_PLUSOPTS, bin_functions, 0, -1, 0, "mktTUwXz", "u"), BUILTIN("bg", 0, bin_fg, 0, -1, BIN_BG, NULL, NULL), BUILTIN("break", BINF_PSPECIAL, bin_break, 0, 1, BIN_BREAK, NULL, NULL), BUILTIN("bye", 0, bin_break, 0, 1, BIN_EXIT, NULL, NULL), @@ -2882,7 +2882,7 @@ bin_functions(char *name, char **argv, O if ((pprog = patcompile(*argv, PAT_STATIC, 0))) { /* with no options, just print all functions matching the glob pattern */ queue_signals(); - if (!(on|off)) { + if (!(on|off) && !OPT_ISSET(ops,'X')) { scanmatchtable(shfunctab, pprog, 1, 0, DISABLED, shfunctab->printnode, pflags); } else { -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/