Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to get syntax highlighting working??



While playing with this syntax highlighting code, I've come to the
conclusion that it would be much nicer to have a hook where the zle code
asks for a changed line to be highlighted.  This avoids having to create
functions for an ever-changing plethora of zle functions, and makes things
like push-line, yank, yank-pop, delete-char-or-list, and who-knows-what-else
Just Work (all of which have issues when using override widgets).

Here's a patch for zsh:

  http://opencoder.net/zle-set-highlight-hook.patch

Thoughts?  I really like this single hook point for highlighting.

With that change, the init code for the zsh-syntax-highlighting code becomes
this simple line:

  zle -N zle-set-highlight _zsh_highlight-zle-buffer

Then, just to make the shell code a little more optimal, I added the
following to the top of _zsh_highlight-zle-buffer function (to avoid
identical highlight processing):

  [[ ${ZSH_PRIOR_HIGHLIGHTED_BUFFER:-} == $BUFFER ]] && return
  ZSH_PRIOR_HIGHLIGHTED_BUFFER=$BUFFER

..wayne..


Messages sorted by: Reverse Date, Date, Thread, Author