From 261c180a36659fb01d68e2356a17837bd9ad4b3a Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 18 Mar 2016 14:41:18 +0000 Subject: [PATCH] widget binding: Unbreak the build. The last commit inadvertently broke interactive use, although the test suite passed. See issue #278. --- zsh-syntax-highlighting.zsh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 2fe3713..a30ab41 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -222,18 +222,21 @@ _zsh_highlight_bind_widgets() # Already rebound event: do nothing. user:_zsh_highlight_widget_*);; + # The "eval"'s are required to make $cur_widget a closure: the value of the parameter at function + # definition time is used. + # User defined widget: override and rebind old one with prefix "orig-". user:*) zle -N orig-$cur_widget ${widgets[$cur_widget]#*:} - _zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget orig-$cur_widget -- "$@" }; + eval "_zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget orig-$cur_widget -- \"\$@\" }"; zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; # Completion widget: override and rebind old one with prefix "orig-". completion:*) zle -C orig-$cur_widget ${${widgets[$cur_widget]#*:}/:/ }; \ - _zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget orig-$cur_widget -- "$@" }; \ + eval "_zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget orig-$cur_widget -- \"\$@\" }"; \ zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; # Builtin widget: override and make it call the builtin ".widget". - builtin) _zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget .$cur_widget -- "$@" }; \ + builtin) eval "_zsh_highlight_widget_$cur_widget() { _zsh_highlight_call_widget .$cur_widget -- \"\$@\" }"; zle -N $cur_widget _zsh_highlight_widget_$cur_widget;; # Default: unhandled case.