help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Indentation in derived modes?


From: Stefan Monnier
Subject: Re: Indentation in derived modes?
Date: Wed, 15 Oct 2003 17:46:36 GMT
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

> I'm looking at various templating systems for embedding some
> kind of programming code within HTML, and would like Emacs to
> handle this as best as possible. It seems that basing it on an
> HTML-type mode, like psgml-mode (which seems only to indent if
> there's a DTD included, which may not always be the case if
> you're using templates) or html-helper-mode (does that indent,
> for that matter? I haven't used it), would be the way to start,
> and then adding to it some functionality for indenting the
> template's statements. Is that possible, or would I have to
> redo the entire indentation code to accommodate the possibility
> of embedded non-HTML statements? Is this a particularly difficult
> programming task?

Indentation is the only part of a major mode that requires thinking,
meaning that it can be pretty tricky and there's no accepted standard way
of solving the problem.  I.e. indenting can be tricky.

You might want to look into mmm-mode (on sourceforge) which tries to solve
the problem of multiple-major-modes in a single buffer and arrange to use
the proper indentation code for the corresponding zone of a buffer.

It's a difficult problem, so I recommend you try to use other people's work
before embarking on your own attempt.  Also, if mmm-mode doesn't work
well enough, it would be better to fix mmm-mode (or the modes with which it
interacts).

> Any pointers to tutorials for writing such code would also
> be appreciated! There wasn't anything on it in a few of the
> things I've looked at already.

I only know of one person who tried to describe how he wrote his
indentation code.  And sadly it's an approach that tends to have
serious limitations.

   http://www.emacswiki.org/cgi-bin/wiki/ModeTutorial

Hopefully some day things will be better.


        Stefan


reply via email to

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