* El 12/04/06 a las  8:53, Charles E Campbell Jr chamullaba:

> Luis A. Florit wrote:
>
> > >> I've always had some special highlighting for TeX
> > >>files. For example, I have the following syn for "$$":
> > >>
> > >>hi dollars cterm=bold ctermfg=7 ctermbg=4 guifg=white guibg=blue
> > >>syn match dollars /\(\$\$\|\\\[\|\\\]\)/
> > >>
> > >>
> > ...
> > But your (and Benji's) solution gives rise to another problem:
> > If I add containedin=ALL, or containedin=texDocZone, the "$$"
> > are properly highlighted, but then 80% of the "}" in the
> > manuscript are highlighted like errors, white over red (??!!).
> >
> > Another problem that I have (but this one I always had) is that
> > the highlighting of the "$$" destroys the normal highlighting
> > of the math zone, and errors appear inside the $$ ... $$.
> > But I assume it has to do with the contained-contains stuff.
> >
> > I tried, then:
> >
> > hi dolares cterm=bold ctermfg=7 ctermbg=4 guifg=white guibg=blue
> > syn match dolares contained /\(\$\$\|\\\[\|\\\]\)/ containedin=ALL
> >
> > but, still, the two problems persist: 80% of the "}" are marked
> > as errors, and the syntax inside the $$ ... $$ is destroyed.
> >
> > Do you have a suggestion? I really don't get how this works.
> >
> >
>
> Look into syntax/tex.vim. The $$ ... $$ is recognized as
> a texMathZoneY (normally). Now, your syntax item (dolares) occurs
> later, so it has priority; hence, the texMathZoneY is bypassed by
> your extra syntax.

Got it!

> What you've wanted is to change the highlighting of $$. Currently,
> the texMathZoneY uses Delimiter for the highlighting of the $$s.
> Now, I haven't tested this, but one way to do this is to overwrite
> the texMathZoneY:
>
>  syn clear texMathZoneY
> syn region texMathZoneY matchgroup=Delimiter start="\$\$"
> matchgroup=Delimiter end="\$\$" end="%stopzone\>" keepend
> [EMAIL PROTECTED]
>
> This clears the texMathZoneY and then re-installs it. It does have
> a high priority (because its being done most recently) but I don't
> think that should be a problem. Now, change the "Delimiter" to
> "dolares". Include your dolares highlighting specification. Finally,
> put it into after/syntax/tex.vim (so that it gets loaded after usual
> syntax/tex.vim highlighting for ft=tex files). I think that'll do it!

Indeed!
Now $$ is highlighted as I wanted, and the syntax preserved inside.
No "containedin=..." needed.

However (why there is always a however?), the other problem persists.
I want to highlight, say, the beginning and end of proofs, and my old 
highlighting does nothing:

  hi proof cterm=bold ctermfg=black ctermbg=cyan guifg=black guibg=cyan
  syn match proof /\(\\\(begin{\|end{\)\?proof[}]\?\)\|\(\\qed\)/

Adding "containedin=<WHATEVER>" highlights the patterns, BUT then that
also highlights most "}" as errors (this sounds like a bug in the
highlighting syntax to me...)

If the file after/syntax/tex.vim only contains this two lines

  hi proof cterm=bold ctermfg=black ctermbg=cyan guifg=black guibg=cyan
  syn match proof /\\qed/ containedin=ALL

then most "}" are highlighted as errors. I can grab the screen and 
post it on my webpage if needed. The "containedin=ALL" seems to
have some problem.

    Thanks a lot!!

            L.

Reply via email to