all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Lennart Borgman (gmail)" <lennart.borgman@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to edit "mixed" (e.g. HTML/JavaScript) files?
Date: Thu, 08 Mar 2007 17:06:53 +0100	[thread overview]
Message-ID: <45F0349D.5060602@gmail.com> (raw)
In-Reply-To: <87slcfhlks.fsf@localhorst.mine.nu>

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.

  reply	other threads:[~2007-03-08 16:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-06 19:45 How to edit "mixed" (e.g. HTML/JavaScript) files? kj
2007-03-06 21:07 ` Lennart Borgman (gmail)
     [not found] ` <mailman.552.1173217248.7795.help-gnu-emacs@gnu.org>
2007-03-07 18:06   ` kj
2007-03-08  9:48   ` Hadron
2007-03-08 11:02     ` Hadron
2007-03-08 11:49     ` David Hansen
2007-03-08 13:27       ` Lennart Borgman (gmail)
2007-03-08 14:11         ` David Hansen
2007-03-08 16:06           ` Lennart Borgman (gmail) [this message]
2007-03-08 16:43             ` David Hansen
2007-03-08 17:15               ` Lennart Borgman (gmail)
2007-03-08 18:14                 ` David Hansen
     [not found]       ` <mailman.655.1173360456.7795.help-gnu-emacs@gnu.org>
2007-03-08 13:51         ` Hadron

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=45F0349D.5060602@gmail.com \
    --to=lennart.borgman@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.