From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh workers <zsh-workers@zsh.org>
Subject: Re: autoload -X inside an anonymous function
Date: Thu, 20 Sep 2012 20:35:37 +0100 [thread overview]
Message-ID: <20120920203537.29bb1d18@pws-pc.ntlworld.com> (raw)
In-Reply-To: <120919075811.ZM24917@torch.brasslantern.com>
On Wed, 19 Sep 2012 07:58:11 -0700
Bart Schaefer <schaefer@brasslantern.com> 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 <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
next prev parent reply other threads:[~2012-09-20 19:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-18 2:12 Oliver Kiddle
2012-09-18 16:58 ` Bart Schaefer
2012-09-19 0:35 ` Bart Schaefer
2012-09-19 2:28 ` Oliver Kiddle
2012-09-19 14:58 ` Bart Schaefer
2012-09-20 19:35 ` Peter Stephenson [this message]
2012-09-24 18:50 ` Bart Schaefer
2012-10-05 21:32 ` Peter Stephenson
2012-10-05 21:54 ` Christian Neukirchen
2012-10-07 17:51 ` Peter Stephenson
2012-10-05 22:24 ` Peter Stephenson
2012-10-06 7:56 ` 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=20120920203537.29bb1d18@pws-pc.ntlworld.com \
--to=p.w.stephenson@ntlworld.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).