Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:in-reply-to
         :comments:to:subject:mime-version:content-type;
        bh=D1G4E22Ul+Nt1TMz3kfk3naoCTh1RN0qYXsvTVX+CUI=;
        b=Tuv/YC2cHsJCysa7xPFotaY5Vlk+5VlK1Hv5v7cWGXYmxulcpFs59uhv2CZ7VQAVC4
         tBkBE9EAqyDOlD8Y3EQtG4utBNQbGGEi8UN9iWI9FqBG/E0yTeU6VPHYGmfMfvCxosbd
         PA09V5cJXyXrvRPQpb1SuOPyTu0RtyviU0mPFP2cbKdcZHaG72MJ2OHhZ+238ZGFuA0L
         i9BXIgbZhg3/jbfry/lB2wZfoB8q3L8Sr5ZsKsc+IAe/xbZTHAgDbpbbZcoHixxYUMHq
         HtCfBAqzmDe+eFHd1KMm7aR6dYOvAQkOYl82C6qizx9cpcUSwtp/t07/anyKwyY7bG4a
         aN6g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:in-reply-to:comments:to:subject:mime-version
         :content-type;
        bh=D1G4E22Ul+Nt1TMz3kfk3naoCTh1RN0qYXsvTVX+CUI=;
        b=DLUR4D+713XymPcltY5p5N92IksEDgaCHTjrqp37ZVVQrbCbppS8GNjKVVbyVTXasn
         FcK4TstDlyX4Q0GIPaQQW9Wr23bcvJHjIfs2FNKFZS890L7dPZ3z+mwZuBdgDQkjmsYd
         rGCt0lfmZPS0dlhhs6jxbJNTZRBdMV8MOpfoudOclZNMoiQMGVxM+vEzkHwfUTLrQbOE
         NBp7/zBnsWPMYe1ou9FDXeWgIcOE1JcC3LznE+j2YKVvxRliUUAB6MRTVids3Cu9nMwW
         RyEXyjJ8AxQpRAdP1jxPGuNE/yJwCJ87H2EkGMjcHZHP9WmvyTPDkZTsqXlBgh9NFeI8
         RDEA==
X-Gm-Message-State: AG10YOSDBhc+p0P0n/h3OxhNpLUo4b+uGgj1OGn+3XRtXfy5VUFWGZWQhedsMnrLu0cYQw==
X-Received: by 10.66.159.38 with SMTP id wz6mr13508490pab.12.1453570526448;
        Sat, 23 Jan 2016 09:35:26 -0800 (PST)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160123093602.ZM14454@torch.brasslantern.com>
Date: Sat, 23 Jan 2016 09:36:02 -0800
In-Reply-To: <CAKc7PVCywh3fVsvFOUP3Bi27-8o1w30_E73rs8c+Zd4sOqtT8w@mail.gmail.com>
Comments: In reply to Sebastian Gniazdowski <sgniazdowski@gmail.com>
        "Re: Proof of concept mainstream plugin manager" (Jan 23, 10:03am)
References: <CAKc7PVByfo51GcVkb_kYgO2D3cWYrcq-p4v8gmyfsaeWU=2new@mail.gmail.com> 
	<160122173705.ZM11491@torch.brasslantern.com> 
	<CAKc7PVCywh3fVsvFOUP3Bi27-8o1w30_E73rs8c+Zd4sOqtT8w@mail.gmail.com> 
	<CAKc7PVChdTs4WzKf+amXJ9Y7zOpQVSEsVm6pmHK3FcCQy5k-Xw@mail.gmail.com> 
	<CAKc7PVD-AAQ2TDQ_V06Sh15xT9=n5u+cU1WXRAk4kGAi16DqPA@mail.gmail.com> 
	<CAKc7PVCXvW0PCV_pREMBqvWvVL02qFmnvc+PMcdDArrCuDMjpg@mail.gmail.com>
In-Reply-To: <CAKc7PVCXvW0PCV_pREMBqvWvVL02qFmnvc+PMcdDArrCuDMjpg@mail.gmail.com>
Comments: In reply to Sebastian Gniazdowski <sgniazdowski@gmail.com>
        "Re: Proof of concept mainstream plugin manager" (Jan 23,  5:09pm)
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Proof of concept mainstream plugin manager
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 37744

On Jan 23, 10:03am, Sebastian Gniazdowski wrote:
}
} I occur a problem with traps.

Hm.  The difference between a "real" autolaod and a function that calls
"autoload -X" is a couple levels of function stack depth -- in the "real"
case zsh knows it can optimize out the first call:

torch% functions showfunctrace
torch% autoload !$
autoload showfunctrace
torch% showfunctrace
Src/zsh:30
torch% unfunction showfunctrace
torch% showfunctrace() { autoload -X }
torch% showfunctrace
(eval):1
showfunctrace:0
Src/zsh:33
torch% 

This will affect traps created with the trap command because they
execute in the same scope as the function call that defined them,
rather than "inside" the call that defined them; so some convoluted
trap tricks that rely on the scope may not work.

} This is fixed in 5.1 (occurs in 5.0.8), wonder if
} I can somehow workaround this:

Probably not, it's almost certainly an internal signal handling thing.

There's another problem with the "local FPATH" trick that I thought
of just now:  It changes the load path for all other functions down
the call stack, which is likely to cause some other autoloads to fail.
A better approach is a temporary prepend.

    local FPATH="$ZPLUGIN_HOME/plugins/${ZPLUGIN_CURRENT_USER}--${ZPLUGIN_CURRENT_PLUGIN}:$FPATH"

A less pleasing approach to the whole thing is to use "autoload +X"
instead:

  preload-autoload() {
    FPATH="/tmp:$FPATH" autoload +X $1
  }

This causes the function to be loaded immediately but not run.  So it
"fixes" the trap problem but fills up memory with functions that may
never be used.

