[patch] match does not Conceal items

115 views
Skip to first unread message

Christian Brabandt

unread,
Apr 9, 2011, 8:13:34 AM4/9/11
to vim...@googlegroups.com
Hi Bram,
problem is, you can't conceal items using :match or matchadd().

Attached patch fixes it:

regards,
Christian

match_conceal.diff

Christian Brabandt

unread,
Apr 10, 2011, 8:06:22 AM4/10/11
to vim...@googlegroups.com
Hi vim_dev!

On Sa, 09 Apr 2011, Christian Brabandt wrote:

> problem is, you can't conceal items using :match or matchadd().
>
> Attached patch fixes it:

... and this time, it even compiles with tiny features...

regards,
Christian

match_conceal

Bram Moolenaar

unread,
Apr 10, 2011, 8:07:40 AM4/10/11
to Christian Brabandt, vim...@googlegroups.com

Christian Brabandt wrote:

> Hi Bram,
> problem is, you can't conceal items using :match or matchadd().
>
> Attached patch fixes it:

Can you explain what the effect is? Perhaps we also need an update to
the documentation. And an example to show the effect.

Please use tabs where possible.

+ match_conc=FALSE;

Put spaces around the "=".


--
For society, it's probably a good thing that engineers value function over
appearance. For example, you wouldn't want engineers to build nuclear power
plants that only _look_ like they would keep all the radiation inside.
(Scott Adams - The Dilbert principle)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christian Brabandt

unread,
Apr 10, 2011, 8:27:00 AM4/10/11
to vim...@googlegroups.com
Hi Bram!

On So, 10 Apr 2011, Bram Moolenaar wrote:

> Can you explain what the effect is?

Basically, I wanted to create a plugin that uses concealing for
something like vertical folding. I tried to dynamically conceal columns
using :call matchadd(), but this only highlights the region, it does not
conceal it, no matter what 'cole' is set to. So instead, I started using
:syn match commands. Problem here is, you can't really remove matches
and it is not that easy to use.

There is still a problem, that cursor movement won't skip over concealed
text. I am currently thinking about creating a patch for that as well,
e.g. when cole is set to 4 (it currently allows only 3). But I don't
know how easy that is to implement, it would have to be done on a lot of
places.

> Perhaps we also need an update to
> the documentation. And an example to show the effect.

I Don't think so. I expect, that when cole is set to 3, that a :call
matchadd('Conceal', 'foobar') conceals the foobar part
and not to have it highlighted. I would even consider this a bug.

> Please use tabs where possible.
>
> + match_conc=FALSE;
>
> Put spaces around the "=".

Sorry. The updated patch, I sent earlier should have covered that.

regards,
Christian

Bram Moolenaar

unread,
Apr 10, 2011, 3:45:55 PM4/10/11
to Christian Brabandt, vim...@googlegroups.com

Christian Brabandt wrote:

> On So, 10 Apr 2011, Bram Moolenaar wrote:
>
> > Can you explain what the effect is?
>
> Basically, I wanted to create a plugin that uses concealing for
> something like vertical folding. I tried to dynamically conceal columns
> using :call matchadd(), but this only highlights the region, it does not
> conceal it, no matter what 'cole' is set to. So instead, I started using
> :syn match commands. Problem here is, you can't really remove matches
> and it is not that easy to use.
>
> There is still a problem, that cursor movement won't skip over concealed
> text. I am currently thinking about creating a patch for that as well,
> e.g. when cole is set to 4 (it currently allows only 3). But I don't
> know how easy that is to implement, it would have to be done on a lot of
> places.
>
> > Perhaps we also need an update to
> > the documentation. And an example to show the effect.
>
> I Don't think so. I expect, that when cole is set to 3, that a :call
> matchadd('Conceal', 'foobar') conceals the foobar part
> and not to have it highlighted. I would even consider this a bug.

No, using the "Conceal" group only means it's highlighted like
characters replaced by the conceal feature, not that they are not
displayed.

You will have to do more than setting the highlighting group, something
similar to the cchar and conceal arguments to :syn.

You will also have to fix the cursor movement and any other related
problems before I would include this. Experience with the conceal
feature has learned us that it can easily trigger more problems, thus we
also need tests.

--
Bad fashion can discourage normal people from interacting with the engineer
and talking about the cute things their children do.

Charles E Campbell Jr

unread,
Apr 10, 2011, 8:34:36 PM4/10/11
to vim...@googlegroups.com
Christian Brabandt wrote:
> Hi Bram!
>
> On So, 10 Apr 2011, Bram Moolenaar wrote:
>
>
>> Can you explain what the effect is?
>>
> Basically, I wanted to create a plugin that uses concealing for
> something like vertical folding.
>

Perhaps you could look into foldcol.vim and see if that does what you
want: http://mysite.verizon.net/astronaut/vim/index.html#FOLDCOL. It
uses syntax rather than match, with the limitations thereof.

Regards,
Chip Campbell

Christian Brabandt

unread,
Apr 11, 2011, 5:24:40 AM4/11/11
to vim...@googlegroups.com
On Sun, April 10, 2011 9:45 pm, Bram Moolenaar wrote:
> Christian Brabandt wrote:
>> On So, 10 Apr 2011, Bram Moolenaar wrote:
>> > Can you explain what the effect is?
>> Basically, I wanted to create a plugin that uses concealing for
>> something like vertical folding. I tried to dynamically conceal columns
>> using :call matchadd(), but this only highlights the region, it does not
>> conceal it, no matter what 'cole' is set to. So instead, I started using
>> :syn match commands. Problem here is, you can't really remove matches
>> and it is not that easy to use.
>>
>> There is still a problem, that cursor movement won't skip over concealed
>> text. I am currently thinking about creating a patch for that as well,
>> e.g. when cole is set to 4 (it currently allows only 3). But I don't
>> know how easy that is to implement, it would have to be done on a lot of
>> places.
>>
>> > Perhaps we also need an update to
>> > the documentation. And an example to show the effect.
>>
>> I Don't think so. I expect, that when cole is set to 3, that a :call
>> matchadd('Conceal', 'foobar') conceals the foobar part
>> and not to have it highlighted. I would even consider this a bug.
>
> No, using the "Conceal" group only means it's highlighted like
> characters replaced by the conceal feature, not that they are not
> displayed.

Too bad. I find it really useful to be able to hide certain parts
of a buffer, when it is not needed (think of hiding time stamps in
log files or columns in large csv-files) I know I can use syn match,
but that has problems to selectively remove those hidden parts or when
other syntax highlighting take precedence.

> You will have to do more than setting the highlighting group, something
> similar to the cchar and conceal arguments to :syn.

Actually, I like the way the patch worked. When cole was zero, nothing
would have changed to how it worked before, when set to 1 or 2, it would
use the 'listchars' setting and with 3, the text would be completely
hidden. I don't have an idea how to set the cchar via the matchadd()
function.

The patch itsself was small and didn't change concealing at all,
just the way when concealing happened.

> You will also have to fix the cursor movement and any other related
> problems before I would include this. Experience with the conceal
> feature has learned us that it can easily trigger more problems, thus we
> also need tests.

Yes probably, that's why I haven't done it yet. You don't sound like
this would be worth the trouble, so I probably won't try to implement it
myself.

regards,
Christian

Reply all
Reply to author
Forward
0 new messages