On 6/29/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
[EMAIL PROTECTED] wrote:

> I'm looking for a way to define a few :syn-match'es before the definitions
> from cpp.vim, but after those of c.vim.

Well it seems it was not necessary in my precise case. I still have some
troubles with priorities.

Given my problem of enforcing good practices by highlighting c++ catches made by
value (instead of reference), I'm almost done. I'm able to highlight "catch(T)"
but neither "catch(...)" nor "catch(T&anything)". I'm even able to not
highlight text I'm typing ("catch(Typ<cursor>)"). So far so good.

However, "catch(T const E)" is correctly highlighted, but "catch(const T e)" is
never highlighted as it should.

Does anybody sees why in my :syn definitions ? I guess the definition of the
syn-Keyword for "const" is the root of my problem. But I don't see how to fix
it.

---------- >% -----------
if !exists("cpp_no_catch_by_reference")
  " In C++, we should always catch by reference (and throw by value)

  " The complex regex tells to match an expression without "&" except "...".
  syn match cppBadCatch
   \  /\(catch\s*(\s*\)\@<=\(\s*\.\.\.\s*\)[EMAIL PROTECTED]&)]*\()\)[EMAIL 
PROTECTED]/

  " Accept what is currently typed
  syn match cppEditedCatch
   \  /\(catch\s*(\s*\)\@<=[a-zA-Z:_]\+\%#\(\s*)\)[EMAIL PROTECTED]/
  syn match cppEditedCatch
   \  
/\(catch\s*(\s*\)\@<=\(\%[const]\|const\s*[a-zA-Z:_]\+\s*\)\%#\(\s*)\)[EMAIL 
PROTECTED]/
  syn match cppEditedCatch
   \  /\(catch\s*(\s*\)\@<=[a-zA-Z:_]\+\s*\%[const]\=\%#\(\s*)\)[EMAIL 
PROTECTED]/

  hi def link cppBadCatch    SpellBad
  " hi def link cppEditedCatch xxxx
endif
---------- >% -----------

I had similar problem, namely that syn-keyword
(like static etc) prevent syn-match from matching
the keywords. The detailed explanation and
hint at possible solition is at:

http://marc.theaimsgroup.com/?l=vim&m=114321198924381&w=2
http://marc.theaimsgroup.com/?l=vim&m=114322806510413&w=2
http://marc.theaimsgroup.com/?l=vim&m=114323035711653&w=2

I don't know how to make syn-match to match keywords.
I proposed once to add explicit 'priority=N' attribute to syntax
rules to make it possible.

Yakov

Reply via email to