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

Re: PATCH: custom zsh hooks (was Re: Extending zsh hooks)



On Wed, Nov 8, 2023 at 11:17 AM Gregory Seidman
<gsslist+zshdev@xxxxxxxxxxxxxxxxxx> wrote:
>
> My one-line-plus-documentation patch is below. The proposal is to
> have a way to add custom hook types to be managed with add-zsh-hook.

The doc paragraph preceding the one you edited says:
  Several functions ... are automatically called at specific points during
  shell execution.

This patch would introduce a new reserved parameter name; the arrays
thereby managed are obviously not related to any other
automatically-called function; and extending the list of hook names in
this way introduces the possibility of name conflicts with actual new
hook functions that might be added in the future.

I think we need some more justification for why this should be
enshrined in the official sources, and for why it should overload
add-zsh-hook rather than be its own new function.  The options-parsing
part of add-zsh-hook is already duplicated in add-zle-hook-widget, so
either there's no issue with duplicating it again, or it's a candidate
for being pulled out into its own function and then called from both
of those and a third new one (or just rewritten using zparseopts,
since getopts/OPTIND handling is a bit iffy [cf. README for changes
5.8.1 to 5.9]).

If a new function is introduced, I would suggest basing it on
add-zle-hook-widget rather than on add-zsh-hook, because
add-zle-hook-widget uses zstyle rather than array parameters and
thereby doesn't clutter the parameter namespace.  (That assumes you
want something mostly backward compatible, because going forward this
could all use namespaces.)




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