From f9c95b2ef34bddd5f7bf7ab487d0cc762f622f30 Mon Sep 17 00:00:00 2001 From: m0viefreak Date: Tue, 29 Mar 2016 21:50:46 +0200 Subject: [PATCH] 'driver': Widget binding: Support binding unbound zle hooks If a special zle-* hook is currently unbound, there is no entry in $widgets. Support that case by adding a new case branch. --- zsh-syntax-highlighting.zsh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index e49e5a8..2f6c842 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -235,8 +235,10 @@ _zsh_highlight_bind_widgets() } # Override ZLE widgets to make them invoke _zsh_highlight. + local -U widgets_to_bind + widgets_to_bind=(${${(k)widgets}:#(.*|orig-*|run-help|which-command|beep|set-local-history|yank)}) local cur_widget - for cur_widget in ${${(k)widgets}:#(.*|orig-*|run-help|which-command|beep|set-local-history|yank)}; do + for cur_widget in $widgets_to_bind; do case $widgets[$cur_widget] in # Already rebound event: do nothing. @@ -262,6 +264,10 @@ _zsh_highlight_bind_widgets() builtin) eval "_zsh_highlight_widget_${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }" zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; + # Special zle-* hook that is currently not bound at all: Bind to z-sy-h driectly. + '') eval "_zsh_highlight_widget_${(q)cur_widget}() { :; _zsh_highlight }" + zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; + # Default: unhandled case. *) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;; esac