Keywords syntax highlighting

Help
2005-01-09
2013-05-02
  • Hi there. I am a freelance writer, using JOE to hack in my articles. I'd like to create a new syntax file that suits my needs, but I am at a loss as to how it is done. Let's say I'd like to have my text in blue, except certain keywords that are supposed to show up in red and except words that end in -ly (red also). How would I do that? Any help appreciated. In case this has been asked before and I have not seen it or there is a site explaining it, don't hesitate to put me on track. Thanks. :-)

     
    • Joe Allen
      Joe Allen
      2005-01-19

      Included is a highlighter for keywords (see c.jsf for the little documentation that exists).  Unfortunately there is no easy way to color words which end in "ly".  The problem is that there is no way to supply the buffered word length to the "recolor" option.  Which leads to the hard way: make a set of states for every word length (up to some maximum).  This way when -ly is recognized, you know the word length for "recolor=".  It's a big mess though.

      I'll add a way of marking areas to the highlighter in a future version.  This should bring JOE's highlighter up to the power of VIM's.

      # Just highlight keywords

      # Name the colors

      =Idle
      =Type1  blue
      =Type2  red

      # First state

      :idle Idle
              *               idle
              "a-zA-Z"        word buffer     # Start of a word

      :word Idle
              *               idle noeat strings
      # Put your list of keywords here...
              "foo"           type1
              "bar"           type1
              "blech"         type2
      done
              "a-zA-Z"        word            # Collect additional letters of a word

      # These states don't eat characters, but give the type name

      :type1 Type1
              *               idle noeat

      :type2 Type2
              *               idle noeat