help-gnu-emacs
[Top][All Lists]
Advanced

[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: Thu, 18 Mar 2021 20:53:12 +0100
User-agent: mu4e 1.5.8; emacs 27.1.91

On Wed, Mar 17 2021, Harald Jörg wrote:
> My solution was to to combine a rule for [aBc] with a rule of type
> (MATCHER . ANCHORED-HIGHLIGHTER): The anchor is the opening "[" and the
> first "aBc", and the anchored matcher matches a semicolon and, as a
> group, another "aBc".

Ah, OK. I think I understand that. :-)

> I just saw that Stefan said this would work, so I'll give it a try:
> ```
> (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))
>         ("[[:alnum:]]*B[[:alnum:]]*"
>     (";[[:blank:]]*\\(?1:[[:alnum:]]*\\)\\(?2:B\\)\\(?3:[[:alnum:]]*\\)"
>      nil nil
>      (1 font-lock-warning-face)
>      (2 font-lock-keyword-face)
>      (3 font-lock-warning-face)))))
> ```

Thanks, that actually seems to work! I'll see if I can adapt it to my actual
use-case.

-- 
Joost Kremers
Life has its moments



reply via email to

[Prev in Thread] Current Thread [Next in Thread]