|
From: | Lennart Borgman (gmail) |
Subject: | Re: [emacs-nxml-mode] [patch] use font-lock |
Date: | Fri, 23 May 2008 23:52:49 +0200 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666 |
Daniel Colascione wrote:
I've converted nxml to font-lock. I used the existing fontification machineryand put it inside a cc-mode-style matcher. Efficiency and output are the same, but: 1) hi-lock-mode works now2) all conventional font-locking functions work as expected. For example, youcan turn fontification on and off with M-x font-lock-mode. 3) font-lock-add-keywords DTRT 4) multiple-major-modes modes should be able to use nXML fontification now, though this remains untested
Hi Daniel,This sounds very interesting. As you might know in nXhtml I am using nxml-mode with mumamo (which is a framework for multiple major modes in a buffer). It works good even though mumamo requires that major modes uses font-lock.
You might wonder how that can be the case. To make it work I implemented a workaround where I use the parsing capabilities from nxml-mode to check that the files follows the DTD specified syntax, but syntax highlighting from another mode (xml-mode/html-mode) that supports font-lock.
There is one very disturbing thing with my solution: I can't stop nxml-mode from parsing the whole buffer. It parses also those parts where mumamo has assigned another major mode. (I hoped that someone some day might have the time and skill to look into this, but I did not have them.)
Does you solution handle this problem? If it does, then how does it handle it? Does font-lock-fontify-region-function handle also the parsing of the xml code? That would be great, but it seems difficult.
Another thing that would be great would be integration with CEDET. As you have probably seen nxml-mode is a part of CVS Emacs and CEDET will hopefully soon be. Eric Ludlam has done very much work on CEDET recently.
If the completion offered by nxml-mode could be used together with CEDET that would be very good. (nXhtml currently offer this in a visible way separately, but I believe the long term solution is to go with CEDET - at least as an option.)
BTW, there is a problem with hi-lock. It uses text properties which may be hidden by overlays. IMO it should use overlays with high priorities. (That seems to be the easiest solution.)
I've also added a new function: nxml-debug-region: Interactive function. Activate the region and callnxml-debug-region. The new region is what nxml thinks should be re-fontifiedif the original region is changed.The new code probably works only on Emacs 22. Lightly tested, but it seems tohandle corner highlighting cases fine. I removed a bunch of code that was "for redisplay", since I'm assuming font-lock handles those funky bits. In addition to the patch, I've attached a set of files that demonstrates extending nXML mode to work with the Genshi template engine. The examples ought to work with some slight modification of the embedded paths.
Genshi was new to me. I will add it to mumamo.el. How did you do the integration with xhtml?
(Does the Relax NG compact syntax offer a way to say "include the next file for this document type"?)
[Prev in Thread] | Current Thread | [Next in Thread] |