all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dieter Wilhelm <dieter@duenenhof-wilhelm.de>
Cc: ihs_4664@yahoo.com
Subject: Re: font-lock regexp for complementary keywords
Date: Thu, 27 Jul 2006 10:21:56 +0200	[thread overview]
Message-ID: <87mzavo3tn.fsf@hans.local.net> (raw)
In-Reply-To: <yoijirllj1ji.fsf@iota250.dd.chalmers.se> (Johan Bockgård's message of "Tue, 25 Jul 2006 14:45:37 +0200")


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

  reply	other threads:[~2006-07-27  8:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.4440.1153819115.9609.help-gnu-emacs@gnu.org>
2006-07-25 12:45 ` font-lock regexp for complementary keywords Johan Bockgård
2006-07-27  8:21   ` Dieter Wilhelm [this message]
2006-07-24 16:53 Dieter Wilhelm
2006-07-25 16:15 ` Kevin Rodgers
     [not found] ` <mailman.4451.1153844221.9609.help-gnu-emacs@gnu.org>
2006-08-13 18:37   ` David Combs
2006-08-16 12:18     ` Miles Bader

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mzavo3tn.fsf@hans.local.net \
    --to=dieter@duenenhof-wilhelm.de \
    --cc=ihs_4664@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.