Fix #46: Conflict with url-quote-magic

This commit is contained in:
Julien Nicoulaud 2011-07-26 22:50:53 +02:00
parent 3b27ad778d
commit 776453cb5b
1 changed files with 24 additions and 23 deletions

View File

@ -136,30 +136,31 @@ highlighters_dir="${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:-${0:h}/highlighters}"
} }
# Override ZLE widgets to make them invoke _zsh_highlight. # Override ZLE widgets to make them invoke _zsh_highlight.
for event in ${${(f)"$(zle -la)"}:#(_*|orig-*|.run-help|.which-command|.beep)}; do for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|orig-*|run-help|which-command|beep)}; do
if [[ "$widgets[$event]" == completion:* ]]; then case $widgets[$cur_widget] in
eval "zle -C orig-$event ${${${widgets[$event]}#*:}/:/ } ; $event() { builtin zle orig-$event && _zsh_highlight } ; zle -N $event"
else # Already rebound event: do nothing.
case $event in user:$cur_widget);;
accept-and-menu-complete)
eval "$event() { builtin zle .$event && _zsh_highlight } ; zle -N $event" # User defined widget: override and rebind old one with prefix "orig-".
;; user:*) eval "zle -N orig-$cur_widget ${widgets[$cur_widget]#*:}; \
.*) $cur_widget() { builtin zle orig-$cur_widget && _zsh_highlight }; \
clean_event=${event#\.} zle -N $cur_widget";;
case ${widgets[$clean_event]-} in
(completion|user):*) # Completion widget: override and rebind old one with prefix "orig-".
;; completion:*) eval "zle -C orig-$cur_widget ${${widgets[$cur_widget]#*:}/:/ }; \
*) $cur_widget() { builtin zle orig-$cur_widget && _zsh_highlight }; \
eval "$clean_event() { builtin zle $event && _zsh_highlight } ; zle -N $clean_event" zle -N $cur_widget";;
;;
# Builtin widget: override and make it call the builtin ".widget".
builtin) eval "$cur_widget() { builtin zle .$cur_widget && _zsh_highlight }; \
zle -N $cur_widget";;
# Default: unhandled case.
*) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;;
esac esac
;;
*)
;;
esac
fi
done done
unset event clean_event unset cur_widget
# Start highlighting immediately after the creation of a new command line. # Start highlighting immediately after the creation of a new command line.
autoload add-zsh-hook && add-zsh-hook precmd _zsh_highlight autoload add-zsh-hook && add-zsh-hook precmd _zsh_highlight