Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Surprising effect of fun() { local FPATH=...; autoload -X }, and a bug
- X-seq: zsh-workers 39537
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Surprising effect of fun() { local FPATH=...; autoload -X }, and a bug
- Date: Fri, 30 Sep 2016 08:03:48 +0200
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ZY0G+EAZdGBZbRExjGiJydIoF7fLCvHS8rdg1/0maR0=; b=XvdlTG/1gsi7zfDqCkctKuQ8ZGhcR9S16T67fc6PJqtN/jezkcFkCHkm6+MTO7sGW2 ai3iFIoWi4ta6ng3X3IsQ+3cvGDHHqSFkvRrv75X+g0xAeVKtqCZTNv+z6vZ0lxcj1ko DQDifT0OytT7asQgI/+JosgB6MJthqbl2MoDX4lh47fjffFLmw8fyx6nU8D37xt7LcFX AvLeqZ+Xw/y7TRDQQPCMrUH+HDdKIv/G0U7Kcs4T0lTfuoR07dTuOl2hPlFnjIZS1icY B6xWz99gM4jqp+tW2rZDZNv5n4ctvoQSUjfykhzvNrsDbTYtfoyqtt/S1O6IcWJwlC0T iM/g==
- In-reply-to: <160929145022.ZM12459@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVCXq6jQe2gF-Hb4UFBx7UXxRE=3_8Z2Oyq-H6d0LoNLAA@mail.gmail.com> <160929001004.ZM27686@torch.brasslantern.com> <CAKc7PVCJ4RJjiV7u-9MYrZMKC-G4b5mhFM4o7rcQ7xmkEmRzvA@mail.gmail.com> <160929145022.ZM12459@torch.brasslantern.com>
On 29 September 2016 at 23:50, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Sep 29, 3:58pm, Sebastian Gniazdowski wrote:
> }
> } Turns out a normal fpath-extending loading support is needed for
> } Zplugin, unless a creative solution is found
>
> Your autoload wrapper that sets up the "local FPATH" needs to store
> the FPATH value for each module somewhere, e.g., in a has indexed
> on the module name, and then recall that every time another autoload
> occurs from inside a function that was loaded from that module.
This would lead to aliases? The autoloaded function would have to have
"autoload" calls translated into "zplg_autoload" calls. -U flag causes
problems here. Loading function with aliases disabled.. I could use
$dis_aliases to disable every alias except for "autoload", and this
way in general provide what -U should, however it looks like restoring
$dis_aliases will be difficult after autoload -X, because following
content of autoload stub will not be run
I could also make autoload wrapper continuously active in Zsh session
but that doesn't look nice to me. Having fpath-extending loading
support in place doesn't mean that clean-FPATH goal will not be
reached. Few plugins use autoload -> autoload, so user would have to
load via fpath say 2 times, and 10 times via fpath-clean way. Fair
enough. And even this might not happen, because author of plugin only
has to do all autoloads in plugin.zsh file, not in autoloaded file, to
solve the problem.
> Whether it's possible to find that the name of the module at the
> necessary time, is a harder question. In 5.3 "whence -v" will
> reliably give you the path from which the function was loaded, but
> it may not in earlier versions.
Supporting starting from 5.3 is fine to me in this case. Good to hear
about whence -v, this should open way to interesting tricks. Side, I
hope there is still some time till 5.3 because I want to make Zconvey
more robust, currently if I press Ctrl-R Ctrl-C continuously, rapidly
then often happens that every 2 seconds I get beep and new line –
zconvey's 2-second scheduled function is being apparently hit. Plan to
get on this with debugger today and to code as you had an idea of how
to make this less probable, will check that. Zconvey can be a cool
plugin, I currently e.g. switch all my sessions to current project
that I work on via "zcm -zz" (zcommodore -z -z, it uses zconvey). Plus
the take-session I mentioned and other possible ideas, I think having
sessions coupled together can get important say among users.
Idea "if you want functionality use latest" is fine to me if it's
about sophisticated functionality. So I exercised idea of extending
5.3 to make further-autoloading work. getfpfunc does:
pp = fpath;
for (; *pp; pp++) {
and it's about side-providing additional path to that loop. Had
multiple flawed ideas yesterday but now I'm rather blank. So maybe
actually no idea. Recalling something about if functions do have some
sort of meta-data. Then at some point additional fpath could be
extracted and provided to getfpfunc. Example problem: the state
save-restoration, one more data not serializable via declare -f. Other
flawed idea is autoload option to hold single path. It could store the
path somewhere so that getfpfunc could use it. But sorry I'm currently
not having any actual ideas.
Btw. I've stumbled upon following code in execcmd / exec.c:3054:
} else if (is_shfunc || type == WC_AUTOFN) {
Shfunc shf;
if (is_shfunc)
shf = (Shfunc)hn;
else {
shf = loadautofn(state->prog->shf, 1, 0);
Is this the place where autoload-marked functions are differentiated
from manual-autoload-stub functions?
Best regards,
Sebastian Gniazdowski
Messages sorted by:
Reverse Date,
Date,
Thread,
Author