X-Git-Url: https://git.madduck.net/etc/zsh.git/blobdiff_plain/e45b0db3d66ca9e041622db3d801d026fb4d3724..33230b65afa1076218abff057d0bbcc7486af0a8:/.zsh/zshrc/79-zle_widget_function_arrays diff --git a/.zsh/zshrc/79-zle_widget_function_arrays b/.zsh/zshrc/79-zle_widget_function_arrays new file mode 100644 index 0000000..0d3abe7 --- /dev/null +++ b/.zsh/zshrc/79-zle_widget_function_arrays @@ -0,0 +1,26 @@ +# +# Provide arrays for accept-line and magic-space handlers +# +# Copyright © 1994–2017 martin f. krafft +# Released under the terms of the Artistic Licence 2.0 +# +# Source repository: http://git.madduck.net/v/etc/zsh.git +# + +function _widget_functions_handler() { + emulate -L zsh + local fn + for fn in ${(P)${:-"${WIDGET//-/_}_functions"}}; do eval $fn \"\$@\"; done + [[ $WIDGET != zle-* ]] || return + zle .${WIDGET} "$@" +} + +# define arrays like $accept_line_functions so we can stack functions to be +# called for these widgets +typeset -l widget +for widget in accept_line magic_space zle_line_init; do + typeset -ga ${widget}_functions + zle -N ${widget//_/-} _widget_functions_handler +done + +# vim:ft=zsh