Subject: Re: zle hook conventions (was Re: bracket-paste-magic ...)
From: Daniel Shahaf <[email-masked]>
To: Bart Schaefer <[email-masked]>
Cc: Zsh hackers list <[email-masked]>
Date: Fri, 10 Jun 2016 17:36:06 +0000
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Bart Schaefer wrote on Thu, Jun 02, 2016 at 00:06:00 -0700:
> Crudely sketched, I'm thinking of something like this:

Do you plan to take this further, i.e., to polish it and commit it?
It would be a useful interface to have...

Cheers,

Daniel

>     add-zle-hook-function() {
> 	local -aU extant_hooks
> 	local hook="$1"
> 	shift
> 	zstyle -g extant_hooks "$hook" functions
> 	extant_hooks+=("$@")
> 	zstyle -- "$hook" functions "${extant_hooks[@]}"
> 	if [[ -z "${widgets[$hook]}" ]]; then
> 	    zle -N $hook
> 	fi
>     }
> 
>     add-zle-hook-widget() {
> 	local -aU extant_hooks
> 	local hook="$1"
> 	shift
> 	zstyle -g extant_hooks "$hook" widgets
> 	extant_hooks+=("$@")
> 	zstyle -- "$hook" widgets "${extant_hooks[@]}"
> 	if [[ -z "${widgets[$hook]}" ]]; then
> 	    zle -N $hook
> 	fi
>     }