Hi Bram!
On Sa, 25 Okt 2014, Bram Moolenaar wrote:
>
> Christian wrote:
>
> > a popular questions at Stackoverflow covers the topic how to display
> > whitespace distinct so that it is easily visible where whitespace is.
> > Since starting with Vim 7.3 Concealing became available, my answer to
> > that problem was this:
> >
> > ,----
> > | syn match WhiteSpace / / containedin=ALL conceal cchar=·
> > | setl conceallevel=2 concealcursor=nv
> > `----
> >
> > That should theoretically match everywhere, but I noticed it doesn't. I
> > have digged into the syntax highlighting rules and apparently, this is
> > caused by the "skipwhite" argument in the syntax files. The help however
> > states this:
> >
> > ,----[ :h syn-skipwhite ]-
> > | When "skipwhite" is present, the white space is only skipped if there
> > | is no next group that matches the white space.
> > `----
> >
> > So I would argue, that a syntax rule, that has the containedin argument,
> > should also apply at that space. The patch seems relativly simple:
> >
> > diff --git a/src/syntax.c b/src/syntax.c
> > --- a/src/syntax.c
> > +++ b/src/syntax.c
> > @@ -2275,12 +2275,14 @@ syn_current_attr(syncing, displaying, ca
> > * If a nextgroup was not found, continue looking for one
> > if:
> > * - this is an empty line and the "skipempty" option was
> > given
> > * - we are on white space and the "skipwhite" option was
> > given
> > + * (but allow containedin groups to still match that)
> > */
> > if (!found_match)
> > {
> > line = syn_getcurline();
> > if (((current_next_flags & HL_SKIPWHITE)
> > - && vim_iswhite(line[current_col]))
> > + && vim_iswhite(line[current_col])
> > + && !syn_block->b_syn_containedin)
> > || ((current_next_flags & HL_SKIPEMPTY)
> > && *line == NUL))
> > break;
> >
> > Attached is also a screenshot, that shows the difference.
>
> Hmm, a nextgroup is something else than containedin.
It has nothing to do with a nextgroup. It depends on the skipwhite
keyword which prevents the containedin item to match at that particular
point.
> I suspect this might break some syntaxes in obscure ways. I think
> consistency is more important here, the syntax highlighting already is
> too complex.
I agree, syntax highlighting is already so complex, that I usually try
to avoid it as much as possible. Unfortunately there is no really a way
around that.
> Why not use a match to show whitespace?
Because a simple highlighting is too invasive (too much whitespace gets
suddenly highlighted). If I could use the match() familiy to conceal
items, that would actually a lot easily, but unfortunately you can only
use syntax highlighting if you want to actually conceal items. I even
made a patch¹ several years ago to allow hiding matches (though it
wasn't possible to set the cchar with that), but you didn't like it.
¹) https://groups.google.com/d/msg/vim_dev/8bKa98GhHdk/VOzIBhd1m8YJ
Best,
Christian
--
--
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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" 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.