[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Font lock question
From: |
Joost Kremers |
Subject: |
Re: Font lock question |
Date: |
Wed, 17 Mar 2021 14:46:06 +0100 |
User-agent: |
mu4e 1.5.8; emacs 27.1.91 |
On Wed, Mar 17 2021, Stefan Monnier wrote:
>> I have no trouble composing a regex that matches this entire thing. I'd add
>> a
>> shy group that includes an optional semicolon and that is repeated at least
>> once:
>>
>> \[\(?:\(?1:.*?\)B\(?2:.*?\);?\)+\]
>>
>> However, this does not work for font-lock, it seems.
>
> Can you clarify what you mean by "doe snot work"?
Of course. :-) What I mean is that in my test case, e.g., with the following
text in the buffer:
[aBc; aBc; aBc]
only the final `aBc` has the right font-lock faces applied to it. The first two
occurrences of `aBc` have no special face.
I'm testing with the following:
```
(font-lock-add-keywords nil
'(("\\[\\(?:\\(?1:[[:alnum:]]*?\\)\\(?2:B\\)\\(?3:[[:alnum:]]*?\\)[;[:blank:]]*?\\)+\\]"
(1 font-lock-warning-face)
(2 font-lock-keyword-face)
(3 font-lock-warning-face))))
```
This correctly fontifies [aBc] but not the sequence above, [aBc; aBc; aBc].
TIA
--
Joost Kremers
Life has its moments