From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Islands and streams [Was: convert regex.c, .... to standard C] Date: Mon, 22 Nov 2010 19:38:24 +0000 Message-ID: <20101122193824.GA2745@muc.de> References: <201011201200.06827.bruno@clisp.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1290454291 18674 80.91.229.12 (22 Nov 2010 19:31:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 22 Nov 2010 19:31:31 +0000 (UTC) Cc: Lars Magne Ingebrigtsen , rms@gnu.org, emacs-devel@gnu.org To: Lennart Borgman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 22 20:31:27 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PKc6m-0001A3-SV for ged-emacs-devel@m.gmane.org; Mon, 22 Nov 2010 20:31:25 +0100 Original-Received: from localhost ([127.0.0.1]:59012 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PKc6m-0000uE-9V for ged-emacs-devel@m.gmane.org; Mon, 22 Nov 2010 14:31:24 -0500 Original-Received: from [140.186.70.92] (port=46220 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PKc6g-0000tr-9O for emacs-devel@gnu.org; Mon, 22 Nov 2010 14:31:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PKc6c-0003HL-2i for emacs-devel@gnu.org; Mon, 22 Nov 2010 14:31:18 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:2837 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PKc6b-0003Gz-Q1 for emacs-devel@gnu.org; Mon, 22 Nov 2010 14:31:14 -0500 Original-Received: (qmail 25178 invoked by uid 3782); 22 Nov 2010 19:24:30 -0000 Original-Received: from acm.muc.de (pD9E51A85.dip.t-dialin.net [217.229.26.133]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Mon, 22 Nov 2010 20:24:28 +0100 Original-Received: (qmail 3313 invoked by uid 1000); 22 Nov 2010 19:38:24 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 4.6-4.9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:133025 Archived-At: 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 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. POSSIBLE USES OF ISLANDS: (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. POSSIBLE USE OF STREAMS: (i) In literate programing. What do people think (other than the obvious, that I should implement it myself ;-)? -- Alan Mackenzie (Nuremberg, Germany).