zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Plugin conventions (was zsh-users Re: off topic)
Date: Sun, 11 Dec 2016 01:29:56 -0800	[thread overview]
Message-ID: <161211012956.ZM27197@torch.brasslantern.com> (raw)
In-Reply-To: <20161211043221.GA11489@fujitsu.shahaf.local2>

On Dec 11,  4:32am, Daniel Shahaf wrote:
} Subject: Re: off topic
}
} Oliver Kiddle wrote on Sat, Dec 10, 2016 at 03:50:26 +0100:
} > The omz convention seems to be a single file with the extension
} > .plugin.zsh which is sourced but there may be more to it than that.
} > We also need to think about the order in which commands are run.
} 
} Whatever convention we come up with, can we please arrange for the
} plugin's code to be parsed without user options and/or aliases in
} effect?

Sebastian's plugin manager goes to quite some lengths to handle this,
as I recall, including keeping deltas of the option changes so that
any option changes made by the plugin are preserved.

An outline of a simplistic approach to same (I like using zstyle to
avoid having to invent safe parameter names):

    {
      zstyle plugin-manager user-options "${(kv)options[@]}"
      zstyle plugin-manager user-aliases "${(kv)aliases[@]}"
      emulate -R zsh
      noglob unalias -m *
      if source some.plugin.zsh
      then
        zstyle plugin-manager some.plugin-options "${(kv)options[@]}"
        zstyle plugin-manager some.plugin-aliases "${(kv)aliases[@]}"
      fi
    } always {
      zstyle -a plugin-manager user-options options
      zstyle -a plugin-manager user-aliases aliases
      # ... and then merge in the deltas ...
    }

Another tricky bit is that the plugin might want to know what the
user's options were, so would have to be aware of how the plugin
manager has saved them.


       reply	other threads:[~2016-12-11  9:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20161209122958.GD19559@256bit.org>
     [not found] ` <57127.1481294647@hydra.kiddle.eu>
     [not found]   ` <584AC8AC.9050406@eastlink.ca>
     [not found]     ` <62522.1481300922@hydra.kiddle.eu>
     [not found]       ` <584AEDBF.2050402@eastlink.ca>
     [not found]         ` <161209165454.ZM9226@torch.brasslantern.com>
     [not found]           ` <95362.1481338226__15466.9970310808$1481338718$gmane$org@hydra.kiddle.eu>
     [not found]             ` <20161211043221.GA11489@fujitsu.shahaf.local2>
2016-12-11  9:29               ` Bart Schaefer [this message]
     [not found]           ` <95362.1481338226@hydra.kiddle.eu>
     [not found]             ` <161209191323.ZM9548@torch.brasslantern.com>
2016-12-14 12:40               ` plugin conventions (Re: " Oliver Kiddle
2016-12-14 23:51                 ` Bart Schaefer
     [not found]       ` <584AEDBF.2050402__19991.0537027337$1481307418$gmane$org@eastlink.ca>
     [not found]         ` <20161209192406.GA27532@fujitsu.shahaf.local2>
2016-12-11 18:06           ` off topic Peter Stephenson

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=161211012956.ZM27197@torch.brasslantern.com \
    --to=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).