emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "Font-lock is limited to text matching" is a myth


From: Lennart Borgman
Subject: Re: "Font-lock is limited to text matching" is a myth
Date: Mon, 10 Aug 2009 20:04:56 +0200

2009/8/10 Daniel Colascione <address@hidden>:

> If that's not good enough, you can also have your font-lock "matcher" 
> actually perform the fontification itself. cc-mode, espresso-mode, and 
> nxml-mode use this technique. The basic idea is to find interesting patterns 
> in the region of interest, then call font-lock-apply-highlight on them to 
> perform the actual fontification. Because the "matcher" function is still 
> using the font-lock infrastructure, font-lock will respect the fontification 
> and behave correctly in other respects.


mumamo uses this font-lock for dividing the buffer into chunks with
different major modes. It ties into the font-lock framework using
font-lock-fontify-region-function which I think is an entry point
parsers could and should use. (But that is more beliefe ..., someone
who knows better please tell me.)

You said that js2 could not use font-lock or did I misunderstand you?
I do not understand why it can't use that entry point. (Cc:ing Steve.)

If it can't then maybe there is something that could be added to font-lock?


>> it'd be nice if emacs provides syntax parsing infrastructure.... nmxl, js2,
>> cedet, can be leads in this direction and see how things work out.
>
> It already does. It's called font-lock. If you want some kind of 
> infrastructure that uses a grammar to perform fontification, I believe CEDET, 
> which will be included in Emacs, can be wired up that way [I think? I'm not 
> quite sure whether Semantic's tags are generic enough for fontification].


I think Xah meant the grammars. Maybe CEDET is not yet using
font-lock, I do not know how old JIT-lock, which is an essential part
for this, is.

Thanks for a good overview, Daniel. Perhaps you want to explain once
again the difficulties that espresso-mode have with this? What is
missing? I have had a lot of trouble in mumamo, but I thought it was
because I am making things not really expected by the frame work (and
some things are missing in Emacs to really make the corner cases
possible AFAICS).




reply via email to

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