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

Re: zle hook conventions (was Re: bracket-paste-magic ...)



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
>     }



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