From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Herbert Euler" Newsgroups: gmane.emacs.devel Subject: Indentation problem in corporating major modes Date: Mon, 28 Nov 2005 12:39:31 +0800 Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-Trace: sea.gmane.org 1133152834 1347 80.91.229.2 (28 Nov 2005 04:40:34 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 28 Nov 2005 04:40:34 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 28 05:40:31 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Egao2-0001ec-7Z for ged-emacs-devel@m.gmane.org; Mon, 28 Nov 2005 05:39:58 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Egao1-0005Al-L3 for ged-emacs-devel@m.gmane.org; Sun, 27 Nov 2005 23:39:57 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Eganf-00055X-2w for emacs-devel@gnu.org; Sun, 27 Nov 2005 23:39:35 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Egand-00054p-8l for emacs-devel@gnu.org; Sun, 27 Nov 2005 23:39:34 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Egand-00054k-16 for emacs-devel@gnu.org; Sun, 27 Nov 2005 23:39:33 -0500 Original-Received: from [64.4.26.38] (helo=hotmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Egand-0001mi-0X for emacs-devel@gnu.org; Sun, 27 Nov 2005 23:39:33 -0500 Original-Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sun, 27 Nov 2005 20:39:31 -0800 Original-Received: from 64.4.26.200 by by112fd.bay112.hotmail.msn.com with HTTP; Mon, 28 Nov 2005 04:39:31 GMT X-Originating-IP: [202.43.217.195] X-Originating-Email: [herberteuler@hotmail.com] X-Sender: herberteuler@hotmail.com Original-To: emacs-devel@gnu.org X-OriginalArrivalTime: 28 Nov 2005 04:39:31.0745 (UTC) FILETIME=[B99AF110:01C5F3D5] 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:46680 Archived-At: Hello everyone, Please take a look at this to see how to solve the indentation problem. There are several major modes in the standard Emacs, each of them consists of several customizations e.g. indentation, syntax highlighting etc. Major modes are exclusive to each other, so only one major mode can be active at one time. Indentation in one major mode works fine in this way. Multiple Major Mode, which is also called mmm-mode, is a minor mode that can glue several major modes together. In mmm-mode, there is one primary major mode, plus several submodes. While the point is in a submode region, Emacs behaves like in the major mode of that submode. This is pretty useful when editing files contain content should be identified as different kinds of text, such as CGI scripts, since this approach make existing work on different progmodes work together, instead of creating new major modes. Take the PHP file as example. Typically, a PHP file contains content like this:

Content between "" is PHP program, the other is HTML tags. The advantage of mmm-mode is that one can combine these two major modes without creating a new major mode trying to deal with file contains both HTML tags and PHP code. And more major modes could be involved in with little effort than creating new ones. But the indentation is not fine in now. The PHP code is better indented beyond "

" in the above example than indented to column 0. But in the current mmm-mode, PHP code will be indented from column 0. So the code in the above example will be indented like this:

This is more difficult to read than the former one. Tracing the indentation code, I found it might be because all progmodes use the function 'indent-to' to indent, and that command count from column 0. This is fine in a single major mode, but is a bit worse when several major modes corporate with each other in mmm-mode. I found lots of progmodes count by using 'beginning-of-line', so I asked a question in help-gnu-emacs about stopping 'beginning-of-line' beyond column 0, and was told to solve this problem with field property. 'Beginning-of-line' indeed stops at the field boundary, but indentation is not affected in my test of setting field property for some text in a program. So perhaps 'indent-to' should be modified? Because modifying all progmodes is really so difficult, I think it is easier and better to modify the 'indent-to' command, so that it supports indent from columns other than column 0. I'm not sure whether it's a good approach, so I post this message. Please give me some suggestions, thanks very much. Regards, Guanpeng Xu _________________________________________________________________ FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/