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:to:subject
         :mime-version:content-type;
        bh=u9758AXI+7dVPyAyPKgWT6x8MX1dQkUiqMSMnPBFAEc=;
        b=fwmO8D4G82ZFGotEmSpRspQBQAgR54SBdifmU1XJAVzov16kbJXXf0S6IX1ZPTniKN
         3i1NO+AzhToxsZsTGa2hmDdsFnovC2rSjMaTfZphVoMMx73DNmIDV+sHlN4ERHxyrkad
         kWbltP3UWdHMl9KV2U8znL76+ANcxxgeZ6i/Kvy1yF1P6ZaKjvVJ08uj1IrIG44tCFeW
         xE9rjmUKV8cv4meRxXf0YblMXAFD+5nLfH37G6KUdmngeWQywGw0sCg9hsVwz/8vMXcK
         k/NXhlm0nTmYUJv2gCz74/7f57YqMaIp3hDcj/tGdTVs/fNdjAryO6i4Tf2pxmjWxxDU
         g0qQ==
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:to:subject:mime-version:content-type;
        bh=u9758AXI+7dVPyAyPKgWT6x8MX1dQkUiqMSMnPBFAEc=;
        b=c69y6G3KvMdEK9Bz7FapCOhTHaxJZTnViiL1fRL0iabMfqUu3HbKvH5mwvbbbl/FNq
         m9stl6u0VkLbGWBtxsVZt437F7p9aG5uCYPMoIM0LY0hE1o7FR04HuSxl3cwDaf/OZ/h
         Ov/x0JFS/a9ph/eHhmqMk8ovECia9rAJu3FCddtp0PaS3YR+AOfmOT3eO8Bc8T7zYXZJ
         Cx9i/WLJFmCQxzHebtyqvykENcB/CFpq4Zhe4BqmDInQHlRz+cE51oJK0Tuu+ypoTUHX
         I7kRN7aVxPoTUUq/qIAOnxYdLXla2bw6Om7q+4vrIaHh+U2NIkgrDjBlRfss4DHBu6/X
         9Xuw==
X-Gm-Message-State: AG10YORIsHbHX7hNXtDRa9mN36vPpiR5ufAB2xvtSjfwYawIuyzKLycqDt+5PfNIKbqNkg==
X-Received: by 10.98.18.145 with SMTP id 17mr8837500pfs.103.1453512991710;
        Fri, 22 Jan 2016 17:36:31 -0800 (PST)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160122173705.ZM11491@torch.brasslantern.com>
Date: Fri, 22 Jan 2016 17:37:05 -0800
In-Reply-To: <CAKc7PVByfo51GcVkb_kYgO2D3cWYrcq-p4v8gmyfsaeWU=2new@mail.gmail.com>
Comments: In reply to Sebastian Gniazdowski <sgniazdowski@gmail.com>
        "Proof of concept mainstream plugin manager" (Jan 22,  8:44pm)
References: <CAKc7PVByfo51GcVkb_kYgO2D3cWYrcq-p4v8gmyfsaeWU=2new@mail.gmail.com>
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 37735

On Jan 22,  8:44pm, Sebastian Gniazdowski wrote:
}
} I imagine much more can be done if mainstream pairs of eyes will look
} at this. Any ideas of what can be done?
} 
} https://github.com/psprint/zsh-plugin-governor

Some thoughts ...

Consider declaring some or all ZGOV_* variables with "typeset -gH".

For shadowing commands like "autoload", you'd be better off using
function wrappers rather than aliases.  There are too many ways that
aliases can be turned off or bypassed, and none of the commands you
are replacing have keyword-like behavior.

I'm not sure how much value there is in capturing "setopt".  It's
really difficult to manage the side-effects of the "localoptions"
option within a wrapper function, and there are several other ways
to change options as well.  

You're failing to handle any of the flags of the "autoload" command
in zgov-shadow-autoload.  You can probably pass these through to the
"builtin autoload -X" inside the "eval".

You can of course eval a single double-quoted string with embedded
newlines instead of ending all those lines with backslash.

Various things in here are going to gripe if the warn_create_global
option is set.  Hard to decide what to do about that given that this
file is meant to be loaded with "source".  Perhaps wrap the entire
file in an anonymous function:

    () {
      emulate -LR zsh
      unsetopt warncreateglobal # not needed as of 5.3 with emulate

      # your entire current file contents go here
      # except you must use explicit "typeset -g"
    }

Every plugin that you "source" from inside zgov-load-plugin is going
to have a similar problem:  They're one level deeper in the function
stack than they would be if sourced directly from .zshrc and need to
be prepared for that.

For unloading, what you need is a diff of ${(k)functions} before and
after the plugin is loaded, assuming that the plugin really does
autoload or otherwise declare all its function names at load time.
Possibly a conventional unload function name, expected to be defined
by the plugin, could be called if it is in fact defined.  You may even
want the sort of setup/boot/cleanup/finish model used by zmodload
for binary object modules.

As a final thought, I'd just call this whole thing "zplugin", forget the
suffix "governor", name the variables ZPLUG_*, etc.

-- 
Barton E. Schaefer

