[Top][All Lists]

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

Re: Multiple Major Modes

From: Lennart Borgman
Subject: Re: Multiple Major Modes
Date: Mon, 2 Nov 2009 13:32:24 +0100

On Sun, Nov 1, 2009 at 10:24 PM, Dave Love <address@hidden> wrote:
> I'm rather baffled by this nxhtml thing referred to, and its complexity.
> It claims to be trying to solve a problem that the indirect buffer
> approach doesn't have.  Can someone explain why?

Hi Dave,

I guess you mean the complexity of MuMaMo, which is a part of nXhtml?
nXhtml contains much more.

I you have asked some years ago about the indirect buffer thing I
could have answered it quickly, but I have forgotten all details about
why I abondoned that approach. (It was the first approach I tried.) I
am not sure whether to use indirect buffers for just fontification is
useful. It does create problems for other elisp code since they might
be interested in the actual buffer used. Please notice that some minor
modes for example work for a whole buffer and some just within a major
mode. So some buffer local variables should be preserved across chunks
while others should not. (That problem is quite hard to solve with the
current limitations of Emacs though. I have made some suggestions (in
private messages) for how to solve it but they require low level
changes in Emacs and it is quite hard to figure out exactly what is

I really think some simplifications can be made to mumamo.el, but
maybe not as much as one might expect without looking closer at the
problems it tries to solve. Some of the complexity comes from my bad
understanding of complex parts of Emacs from the beginning so there
are some left-over code. It should of course be removed later. The
code in mumamo.el is not always pretty and should be simplified in
many cases. It is however hard to do since complicated cases easily
breaks. I have tried to write some unit tests to simplify the
rewriting work.

On the other hand most of the complexity comes from the problems that
mumamo.el tries to solve. Caching of chunk information and state
information is for example essential. You have a comment in
multi-mode.el that it would be hard to implement chunks in chunks if
chunk information was cached. It is rather the opposite since you have
to search the file from the beginning to get chunks right and that is
especially important for chunks in chunks. I did not realize the full
impact of this from the beginning and I have had to rewrite much of
the chunk dividing code because of this. (And there is still
unnecessary complexity from my rather worthless attempts trying to
make chunk dividing stable without always finding them from the start
of the file.)

Looking at the bug database in Launchpad for nXhtml (and also the old
bugs stored on EmacsWiki) will perhaps make it more clear what the
complexity in mumamo.el is about.

I have tried to avoid discussing the complexities with multi major
modes on Emacs devel since it would take too much time and space. I
have tried to do that in some private messages instead. If you are
interested I could send you some of my suggestions.

I would very much prefer merging different approaches to multi major
modes. It is actually very complex (though on the surface it does not
seem so). Having several approaches will waste a lot of time. On the
other hand forgetting good ideas will also do that. Suggestions for
simplifications of mumamo.el are very welcome.

> Doing this sort of thing properly really needs support from Emacs, which
> was originally meant to be added as necessary.

Yes, but it is hard to find out what support is needed without
actually trying to solve the problems first.

reply via email to

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