Skip to content

Commit

Permalink
add helper function to (re-)bind special zle-* widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
m0vie committed Apr 29, 2016
1 parent 341a3ae commit 1d855a3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions zsh-syntax-highlighting.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,21 @@ _zsh_highlight_bind_widgets()
done
}

# Wrap special zle-* hooks if already bound, or set them otherwise.
#
# Takes a single argument.
_zsh_highlight_set_or_wrap_special_zle_widget() {
local hook="$1"
local currentbinding="$widgets[$hook]"
if [[ -z "$currentbinding" ]]; then
eval "_zsh_highlight_widget_${(q)hook}() { :; _zsh_highlight }"
zle -N $hook _zsh_highlight_widget_$hook
elif [[ $currentbinding == user:* && $currentbinding != user:_zsh_highlight_widget_* ]]; then
eval "_zsh_highlight_widget_${(q)hook}() { ${(q)currentbinding#*:}; _zsh_highlight }"
zle -N $hook _zsh_highlight_widget_$hook
fi
}

# Load highlighters from directory.
#
# Arguments:
Expand Down

0 comments on commit 1d855a3

Please sign in to comment.