From 07588d2165e6fb334e190a4c54628c3983e0b3f8 Mon Sep 17 00:00:00 2001 From: Takeshi Banse Date: Sun, 16 Jan 2011 13:58:31 +0900 Subject: [PATCH] Make core syntax highlighting a function. Make `_zsh_highlight-zle-buffer` just a hands-off. Now, `_zsh_highlight-zle-buffer` calls each ZSH_HIGHLIGHT_FUNCTIONS in turn. The former `_zsh_highlight-zle-buffer` is renamed to `_zsh_main-highlight.` Signed-off-by: Takeshi Banse --- zsh-syntax-highlighting.zsh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 4f8d144..1ebaf13 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -106,8 +106,22 @@ _zsh_highlight-string() { done } +# Functions to be called in _zsh_highlight-zle-buffer. +ZSH_HIGHLIGHT_FUNCTIONS=( + _zsh_main-highlight +) + # Recolorize the current ZLE buffer. _zsh_highlight-zle-buffer() { + local ret=$? + { + for func in ${ZSH_HIGHLIGHT_FUNCTIONS}; do "$func"; done + } always { + return $ret + } +} + +_zsh_main-highlight() { # Avoid doing the same work over and over [[ ${ZSH_PRIOR_HIGHLIGHTED_BUFFER:-} == $BUFFER ]] && [[ ${#region_highlight} -gt 0 ]] && (( ZSH_PRIOR_CURSOR == CURSOR )) && return ZSH_PRIOR_HIGHLIGHTED_BUFFER=$BUFFER