zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Surprising effect of fun() { local FPATH=...; autoload -X }, and a bug
Date: Fri, 30 Sep 2016 08:03:48 +0200	[thread overview]
Message-ID: <CAKc7PVAVg9ZeGcCtPVKa69cAkqX11tZde+xyZhHNfTTng7aGqw@mail.gmail.com> (raw)
In-Reply-To: <160929145022.ZM12459@torch.brasslantern.com>

On 29 September 2016 at 23:50, Bart Schaefer <schaefer@brasslantern.com> 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


  reply	other threads:[~2016-10-02 15:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-26 22:07 Sebastian Gniazdowski
2016-09-27  7:05 ` Daniel Shahaf
2016-09-27  7:54   ` Sebastian Gniazdowski
2016-09-29  7:10 ` Bart Schaefer
2016-09-29  9:42   ` Sebastian Gniazdowski
2016-09-29 10:05     ` Sebastian Gniazdowski
2016-09-29 13:58   ` Sebastian Gniazdowski
2016-09-29 21:50     ` Bart Schaefer
2016-09-30  6:03       ` Sebastian Gniazdowski [this message]
2016-09-30 15:31         ` Bart Schaefer
2016-09-30 17:41           ` Sebastian Gniazdowski
2016-09-30 17:53             ` Sebastian Gniazdowski
2016-09-30 20:13             ` Bart Schaefer
2016-09-30  6:49       ` Daniel Shahaf
2016-09-30 18:16         ` 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=CAKc7PVAVg9ZeGcCtPVKa69cAkqX11tZde+xyZhHNfTTng7aGqw@mail.gmail.com \
    --to=sgniazdowski@gmail.com \
    --cc=schaefer@brasslantern.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).