2015-04-07 17:51 GMT+03:00 Alessandro Antonello <[email protected]>:
> Hi everyone.
>
> I think I'm a little bit rusty using regular expressions in syntax
> highlight.
> I was trying to add a custom highlight to a Doxygen comment body and, for
> some
> reason, it is leaking to outside the comment limits.
>
> In the file 'after/syntax/doxygen.vim' I did the following:
>
> syn match doxygenCustomUnderline contained /[^}]*/
>     \ containedin=doxygenUnderlineMatch
> syn region doxygenUnderlineMatch transparent contained
>     \ start=/\%(\%(\\\|@\)uf\){/ms=s+4 end=/}/ keepend
>     \ contains=doxygenCustomUnderline containedin=doxygenBody,doxygenBrief
>
> hi def link doxygenCustomUnderline Underlined

Your regex is rather strange:

1. You don’t need outer \%(\) at all.
2. You don’t need inner \%(\) as well because what you have there is
naturally expressed as the collection.

In any case, with

    hi def link doxygenCustomUnderline Underlined
    set ft=cpp.doxygen
    syn match doxygenCustomUnderline contained /[^}]*/
containedin=doxygenUnderlineMatch
    syn region doxygenUnderlineMatch transparent contained
start=/[@\\]uf{/ms=s+4 end=/}/ keepend
containedin=doxygenBody,doxygenBrief contains=doxygenCustomUnderline

I don’t have the behaviour you observe. Vim version is 7.4.683.

Specifically I have `\uf{underlined}` underlined where expected, but
not `@uf{underlined too}`. `(int argc… {<Space>` *are* underlined.

My special ShowSyntax command (shows synstack output at cursor
position) shows that if there is `containedin=doxygenUnderlineMatch`
there is no doxygenUnderlineMatch at that position, but there is
doxygenCustomUnderline.

Worse, it seems to depend on some state: I see this behaviour *only in
first attempt in the first unnamed buffer that is there when Vim
starts*.

If I do <C-w>v:enew<CR> (including without `<C-w>v`) and repeat those
commands `(int…` is not underlined.

If I do `set ft=cpp.doxygen` in the very same buffer `(int…` is no
longer highlighted.

Also note that `(int` is highlighted immediately I define `syn
match…`. It is also highlighted if I rename groups to `dcu` and `dum`.

Not sure what is this exactly, but this is definitely some strange bug.

>
> NOTE: In the original file there are no continuation lines. Each group is
> wrote in a single line. I use continuation line here to ease reading.
>
> The I made the test in a 'syntest.cpp' file:
>
> /**
>  * Brief description \uf{underlined}.
>  * With body @uf{underlined too}.
>  */
> int main(int argc, char** argv) { }
>         --------------------------
>
> Surprisingly the underlined text is marked with '--' in addition to both
> regions in the doxygen comment. What could cause this kind of leak? I can't
> understand since the group 'doxygenCustomUnderline' is specifically set as
> contained in the group 'doxygenUnderlineMatch'.
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to