Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Extending zed



śOn Tue, 5 Jun 2018 at 16:40, Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
>
> On 4 June 2018 at 18:08, Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:
> > -i vi-cmd-mode). I followed the naming of the __zed_pg_up widgets in
> > naming this __zed_init but I'm not especially fond of this – it looks
> > like a completion function.
>
> It hurts me a little too. For my plugin functions, I use "-", i.e.
> "-zed_pg_up", but didn't propose this as it is somewhat controversial
> – requires to use "--" when handling the function, e.g. when passing
> to `autoload -- -zed_pg_up`.

A proposal for a function naming scheme. The prefix and then its description:

- . (dot) - for normal yet private functions, i.e. functions that
shouldn't interfere with command-line completion, i.e. shouldn't be
completed when user enters e.g. "$ z<TAB>",

- + - for IO functions, e.g.: +myprj_print_msg or +myprj-print-msg

- @ - for API-like functions, i.e. functions that are used across
projects, that are exposed for use by some code with another ogigin,
.e.g @myprj-register-hook

- / - for debug-like functions, e.g. /myprj-dbg-print. The slash makes
the function impossible to be autoloaded, but the assumption is that
the debug functions shouldn't need this, at least not that it cannot
be resigned from,

- : - for a handler- or callback-, etc like functions; so e.g.
add-zsh-hook precmd :my-precmd-handler

So an example condensed code would look like this:

.prjid_register_hooks() {
    integer ret
    add-zsh-hook precmd :prjid-precmd-handler; ret+=$?
    /prjid-dmsg "Installed precmd hook with result: $ret"
    @otherprj-notice-hook precmd-hook :prjid-precmd-handler; ret+=$?
    +prjid-print "Initialization complete (errors: $ret)"
}

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org



Messages sorted by: Reverse Date, Date, Thread, Author