Thursday, September 26, 2013

Re: Improve context syntax file


On Sep 26, 2013 2:12 PM, "Marco" <lists@homerow.info> wrote:
>
> On 2013–09–26 Paul Isambert wrote:
>
> > > But I can't add it permanently. The underscore is only part of a
> > > word in between the following blocks.
> > >
> > >   \unprotect    … \protect %% or
> > >   \starttexcode … \stoptexcode
> >
> > Since there is little chance that an underscore will immediately follow a
> > control sequence anyway, I don't think defining it for the entire syntax file
> > will cause any problem.
>
> I tried this. But iskeyword does not change the syntax highlighting.
> It only seems to have an effect on the "*" and similar commands. So
> changing iskeyword is probably not what I'm after.

It also affects \k atom. If changing &iskeyword does not affect syntax highlighting then it means this atom is not used.

> > However, you can do something along the following lines:
> >
> >   sy match ControlSequence '\\[a-zA-Z]\+'
> >   sy match SpecialControlSequence '\\[a-zA-Z_]\+' contained
> >   sy region SpecialCode matchgroup=ControlSequence start='\\unprotect' end='\\protect' contains=SpecialControlSequence
>
> I tried this, but it removes all syntax highlighting. Frankly, I
> have no idea of how the syntax highlighting works. I have to read up
> the basics to understand how this exactly works. The issue seems
> more complicated than anticipated. But thanks for the snippet, it's
> something to start with.

You also need to make all other syntax groups be containedin=SpecialCode. Or add contains=... to SpecialCode definition for all groups you need to be highlighted.

Note that there is no need in defining two separate syntax groups. You can make two rules for ControlSequence where one will be contained and other will not.

> Marco

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment