[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: font-lock regexp for complementary keywords
From: |
Dieter Wilhelm |
Subject: |
Re: font-lock regexp for complementary keywords |
Date: |
Thu, 27 Jul 2006 10:21:56 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Thanks to Kevin and Johan
with your help I ended up having 3 working regexps to choose from ;-).
"fil\\(?:n\\(?:a\\(?:me?\\)?\\)?\\)?"
"/fil\\(n\\(a\\(me?\\)?\\)?\\)?"
"/fil\\(name\\|nam\\|na\\|a\\)"
I'll choose the first because it is supposed to be optimised (even
though it looks the most complicated).
bojohan+news@dd.chalmers.se (Johan Bockgård) writes:
> Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:
>>
>> /fil and
>> /filn and
>> /filna and
>> /filnam and
>> /filname and
>
> (regexp-opt
> '("fil"
> "filn"
> "filna"
> "filnam"
> "filname"))
>
> =>
>
> "fil\\(?:n\\(?:a\\(?:me?\\)?\\)?\\)?"
Emacs never ceases to astonish, I didn't know regexp-opt exists.
> Kevin Rogers wrote:
> > \\(/fil\\) 1 font-lock...
> > /fil\\(n\\) 1 fon...
> > /filn\\(a\\) 1 ...
> > /filna\\(m\\) 1 ...
> > /filnam\\(e\\) 1 ...
> Why are you grouping and highlighting either "/fil" or the last letter?
because a previous font-lock regexp fontifies already the letters in
between, somehow I thought this more efficient than overwriting the
previous fontifications.
> "/fil\\(n\\(a\\(me?\\)?\\)?\\)?\\>" 0 font-lock...
I see, 0 means then all levels of groupings, good to know, thanks.
> > Originally I thought that something like this
> >
> > /fil\\(n\\|na\\|nam\\|name\\)
interesting enough, just the order was wrong not the principle
/fil\\(name\\|nam\\|na\\|a\\)
does the trick and for my brain it looks the easiest.
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany