67416Re: [patch] Add a 'modifier' keyword to the :syntax commands, allowing syntax matches to stack.
- Dec 4, 2012On Sunday, December 2, 2012 9:30:55 PM UTC-6, So8res wrote:
> Motivation:I'm not clear on how synIDattr() will work with combined syntax items, or synIDtrans() for that matter.
> syntax region Italic start='_' end='_' modifier contains=Bold
> syntax region Bold start='\*' end='\*' modifier contains=Italic
> highlight Italic cterm=italic
> highlight Bold cterm=bold
> _this is both italic *and bold*_
> The code is surprisingly simple, as vim already has a stack of syntax matches which it walks up to determine the attributes. It's trivial to add a flag which merges attributes instead of clobbering them.
> I'm not sure how to add tests that test text color and format.
In the example you give, synIDtrans() needs to somehow return an ID for both Bold AND Italic.
Do we need to add a new function or modify synIDattr to get whether a syntax ID stands on its own or needs to be combined with the previous item on the syntax stack? Then scripts can call synstack() and check the combine attribute of each item in the stack.
Or maybe modify synIDtrans() to return a List of items if a combined item is used. Then scripts can just check each item actually used to highlight the text.
I think I like the idea of synIDtrans() returning a list in this case a little better.
I'm bringing this up because I maintain TOhtml, which needs to build CSS information for each highlight attribute. It is easy enough to combine CSS classes to obtain a combined syntax highlight, but the information to know which classes to combine needs to be available.
I do think this sounds like a useful feature.
You received this message from the "vim_dev" 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
- << Previous post in topic Next post in topic >>