[Top][All Lists]

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

Islands and streams [Was: convert regex.c, .... to standard C]

From: Alan Mackenzie
Subject: Islands and streams [Was: convert regex.c, .... to standard C]
Date: Mon, 22 Nov 2010 19:38:24 +0000
User-agent: Mutt/1.5.9i

Hi, Lennart!

On Mon, Nov 22, 2010 at 05:59:23PM +0100, Lennart Borgman wrote:
> On Mon, Nov 22, 2010 at 5:45 PM, Lars Magne Ingebrigtsen <address@hidden> 
> wrote:

> As you perhaps know I have written some code for multiple major modes
> in a buffer, mumamo.el in nXhtml. Different chunks of the buffer have
> different major modes. Some part of mumamo.el becomes quite complex and
> is easily broken because it is hard to stop a major mode from looking
> in chunks that are for other major modes.

> Examples of this problem are parsers of all kinds that belongs to a
> certain major mode.

> This is quite hard to fix and I have been thinking about a low level
> change where you could "hide" all the chunks has a different major
> mode when the major mode in question for a parser etc.

So have I, vaguely.  Here are my thoughts:

Emacs's syntax and movement routines should be enhanced to handle
"islands".  An @dfn{island} is a contiguous region of text where a
major mode different from the surrounding text's is in force.  It might
be feasible to mark an island with syntax-table text props, it might not.
Islands can be nested.

Movement commands normally don't recognise islands as anything unusual,
and just move into/out of them.  By binding variable "respect-islands" to
non-nil, any movement command would skip over any islands it encountered,
and such commands could not move point out of an island.

Several islands with the same major mode can by chained together as a
@dfn{stream}.  When respect-islands is non-nil, movement commands can
jump over the "ocean" to the next/previous island in the chain.

Some other Emacs features, such as font locking, would need enhancement.

(i) In mumamo.  This is obvious.
(ii) In CC Mode: implementing macros as islands would drastically
  simplify CC Mode.
(iii) In Shell-script mode: embedded "here documents" could be edited in
  their own mode (e.g. AWK Mode).
(iv) (Maybe) Line comments could be islands.  This might be a bit over
  the top.
(v) In putative LEX and YACC Modes.

(i) In literate programing.

What do people think (other than the obvious, that I should implement it
myself ;-)?

Alan Mackenzie (Nuremberg, Germany).

reply via email to

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