From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel Subject: Re: "Font-lock is limited to text matching" is a myth Date: Mon, 10 Aug 2009 20:04:56 +0200 Message-ID: References: <7b501d5c0908091634ndfba631vd9db6502db301097@mail.gmail.com> <200908101335.24002.danc@merrillprint.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1249927657 13861 80.91.229.12 (10 Aug 2009 18:07:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 10 Aug 2009 18:07:37 +0000 (UTC) Cc: Daniel Colascione , Deniz Dogan , Stefan Monnier , Steve Yegge , emacs-devel@gnu.org, Leo , Miles Bader To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 10 20:07:30 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MaZHK-0005fJ-GL for ged-emacs-devel@m.gmane.org; Mon, 10 Aug 2009 20:07:26 +0200 Original-Received: from localhost ([127.0.0.1]:60479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MaZHJ-0007cg-7Y for ged-emacs-devel@m.gmane.org; Mon, 10 Aug 2009 14:07:25 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MaZF1-0006Xa-Jw for emacs-devel@gnu.org; Mon, 10 Aug 2009 14:05:03 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MaZEy-0006UJ-46 for emacs-devel@gnu.org; Mon, 10 Aug 2009 14:05:03 -0400 Original-Received: from [199.232.76.173] (port=48554 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MaZEx-0006UA-Jo for emacs-devel@gnu.org; Mon, 10 Aug 2009 14:04:59 -0400 Original-Received: from mail-yw0-f186.google.com ([209.85.211.186]:34864) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MaZEu-0003KS-HS; Mon, 10 Aug 2009 14:04:56 -0400 Original-Received: by ywh16 with SMTP id 16so5111169ywh.24 for ; Mon, 10 Aug 2009 11:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=24UsfQpvDNyDT/IQqrl6I/z7tj7v8VpZl2vuL24PXLg=; b=VAp8mHWZj+3T89z8UHWIHCtkPRjPY8Wx1rkcz+yrZCmZYsfB0ZAsTYA7QBt6xUoSYQ AlGfqSvLmNZ408BShO2skPstxxTE+I6cALgzdNWtCp33LXEcFy4KWD5bUWl/djOFFeDX 4k7KIoe+rQ+fwxl+Exscv9p0cu8FNP+0/5sBc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=FRV1L7C6x+e2g28YTl93NhrIqF0nRr3gAhXwkK2+ZbiDI07eXzRDv6Sg0H3r5JRIi7 jFuw2zAwLGUCychfawl52NYUTz8xncGJVs4un9kd+ALWezOS91KOm3FVzEZTquwTLKFN 8qRN+opeLkKpL4ycxAjD5+AasN9sYMRaFk3wI= Original-Received: by 10.100.8.17 with SMTP id 17mr3995009anh.158.1249927496027; Mon, 10 Aug 2009 11:04:56 -0700 (PDT) In-Reply-To: <200908101335.24002.danc@merrillprint.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:113990 Archived-At: 2009/8/10 Daniel Colascione : > If that's not good enough, you can also have your font-lock "matcher" act= ually perform the fontification itself. cc-mode, espresso-mode, and nxml-mo= de use this technique. The basic idea is to find interesting patterns in th= e region of interest, then call font-lock-apply-highlight on them to perfor= m the actual fontification. Because the "matcher" function is still using t= he font-lock infrastructure, font-lock will respect the fontification and b= ehave 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, j= s2, >> 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 infrastr= ucture 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 quit= e 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).