From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lennart Borgman (gmail)" Newsgroups: gmane.emacs.help Subject: Re: How to edit "mixed" (e.g. HTML/JavaScript) files? Date: Thu, 08 Mar 2007 17:06:53 +0100 Message-ID: <45F0349D.5060602@gmail.com> References: <87hcsw2hhw.fsf@gmail.com> <87wt1sgdjs.fsf@localhorst.mine.nu> <45F00F30.60707@gmail.com> <87slcfhlks.fsf@localhorst.mine.nu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1173370067 15203 80.91.229.12 (8 Mar 2007 16:07:47 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 8 Mar 2007 16:07:47 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 08 17:07:39 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HPL9W-0008JX-RF for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Mar 2007 17:07:39 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HPL9k-0006an-6I for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Mar 2007 11:07:52 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HPL98-0006QB-IJ for help-gnu-emacs@gnu.org; Thu, 08 Mar 2007 11:07:14 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HPL94-0006PU-V6 for help-gnu-emacs@gnu.org; Thu, 08 Mar 2007 11:07:14 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HPL94-0006PR-OA for help-gnu-emacs@gnu.org; Thu, 08 Mar 2007 11:07:10 -0500 Original-Received: from ch-smtp01.sth.basefarm.net ([80.76.149.212]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HPL8q-0001SW-Ag for help-gnu-emacs@gnu.org; Thu, 08 Mar 2007 11:06:56 -0500 Original-Received: from c83-254-145-24.bredband.comhem.se ([83.254.145.24]:59561 helo=[127.0.0.1]) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.63) (envelope-from ) id 1HPL8o-0003tO-3I for help-gnu-emacs@gnu.org; Thu, 08 Mar 2007 17:06:54 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.5.666 In-Reply-To: <87slcfhlks.fsf@localhorst.mine.nu> X-Antivirus: avast! (VPS 000722-2, 2007-03-07), Outbound message X-Antivirus-Status: Clean X-Scan-Result: No virus found in message 1HPL8o-0003tO-3I. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1HPL8o-0003tO-3I 3f30f3c6b89d218cf79d957d542396d0 X-detected-kernel: Linux 2.6? (barebone, rare!) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:41800 Archived-At: David Hansen wrote: > On Thu, 08 Mar 2007 14:27:12 +0100 Lennart Borgman wrote: > >> Did you try nXhtml above? It should work OTB. Drawbacks is that it >> requires the Emacs 22 beta. Maybe also in the beginning that it uses >> nxhtml-mode for XHTML. >> >> nXhtml takes another approach to multiple modes. Since Emacs >> actually have no way to restrict a mode to only handle part of a >> buffer (not even in Emacs 22) it instead switches mode. See the home >> page for more info. > > My experiences all come from editing .jsp files. I doubt this > approach will work here. Java mode will be totally confused by the > html parts. Yes, I guess that is right. I therefore have two different approaches. The other approach narrows the buffer and shows just the narrowed part. This is used for embedded css and javascript, but could be used for other things as well. I have thought about instead of narrowing adding overlays to the part that belongs to the other mode, but I have not got down to actually implement it yet. Doing that could make it look like a mixing of major modes. > Also note that switching the mode may be OK for small files but > complete fortification of a >1k lines file takes some time that > is not acceptable during editing (but i have to admit that i haven't > tried nxhtml yet). > > The multi-mode.el approach is to have multiple indirect buffers with > different major modes and it narrows to the region with `point'. > You don't have to run the major-mode command all the time and the > current major mode won't get confused by the rest of the buffer but > indentation can only work within one region. > > There are a some more minor glitches (especially font-locking) but i > think it's at least a promising approach. I guess you mean that it is bad to switch major mode because of that it takes long time, or are there other reasons? If it is the time to change that is important, what do you believe is that takes too much time? When it comes to fontification the approach with indirect buffers can not work, unfortunately, since text properties (which are used for fontification) are shared between the buffers. This together with that a major mode wants to fontify the whole buffer makes it impossible as far as I can see. (There is nothing in Emacs 22 beta that can remedy this either.) > I hope this topic will get some more attention after the upcoming > (?) release of Emacs 22. Yes, that would be good. But I think we need some experiences then about what can work. As far as I can see switching major mode might not be that bad if it could be applied to a part of a buffer. Maybe I should say that I just found some glitches in the handling of mode switching between nXhtml mode and PHP mode so I have to find out what that could be. So if someone wants to test then please wait a little while.