From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Herbert Euler" Newsgroups: gmane.emacs.help Subject: Re: Is it possible to set a "goal column" for 'beginning-of-line'? Date: Wed, 23 Nov 2005 16:51:12 +0800 Message-ID: References: <87br0bbzdn.fsf-monnier+gnu.emacs.help@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-Trace: sea.gmane.org 1132739172 23364 80.91.229.2 (23 Nov 2005 09:46:12 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 23 Nov 2005 09:46:12 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 23 10:46:09 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EerBK-0002YJ-A8 for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Nov 2005 10:44:51 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EequW-0006ma-Ih for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Nov 2005 04:27:28 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EeqLV-0001Zm-HZ for help-gnu-emacs@gnu.org; Wed, 23 Nov 2005 03:51:17 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EeqLT-0001ZR-3z for help-gnu-emacs@gnu.org; Wed, 23 Nov 2005 03:51:16 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EeqLS-0001ZM-KB for help-gnu-emacs@gnu.org; Wed, 23 Nov 2005 03:51:14 -0500 Original-Received: from [65.54.249.29] (helo=omc2-s19.bay6.hotmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EeqLS-0002nR-Mn for help-gnu-emacs@gnu.org; Wed, 23 Nov 2005 03:51:14 -0500 Original-Received: from hotmail.com ([64.4.26.33]) by omc2-s19.bay6.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Wed, 23 Nov 2005 00:51:13 -0800 Original-Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Wed, 23 Nov 2005 00:51:13 -0800 Original-Received: from 64.4.26.200 by by112fd.bay112.hotmail.msn.com with HTTP; Wed, 23 Nov 2005 08:51:12 GMT X-Originating-IP: [202.43.217.195] X-Originating-Email: [herberteuler@hotmail.com] X-Sender: herberteuler@hotmail.com In-Reply-To: <87br0bbzdn.fsf-monnier+gnu.emacs.help@gnu.org> Original-To: help-gnu-emacs@gnu.org X-OriginalArrivalTime: 23 Nov 2005 08:51:13.0155 (UTC) FILETIME=[0EAE7D30:01C5F00B] X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:31293 Archived-At: >From: Stefan Monnier >To: help-gnu-emacs@gnu.org >Subject: Re: Is it possible to set a "goal column" for 'beginning-of-line'? >Date: Wed, 23 Nov 2005 02:25:14 -0500 > >I have trouble understanding your description, but it seems the best >approach is to hack the indentation code directly. I'll try to explain it more clearly as follows. Typically a php file contains content like this:

There are lots of elements in such files, e.g. HTML tags, PHP codes, and many other things (they are not shown here). We can provide a major mode to handle this well, but it means lots of existing work on each major mode could not help. Fortunately, mmm minor mode can glue several major modes together. With mmm minor mode, Emacs behaves like in HTML mode when point is between and

or between

and in the above example, and behaves like in PHP mode when point is between . If there are more elements in this file e.g. C code, Emacs can behave like in C mode as well. So it can be very useful of mmm mode. As you see, code between '' should be idented more than

. But if you really put point before 'if (something)' and press , it will be idented to column 0. That's why I said it's poor. This is because ident commands first go to column 0 with 'beginning-of-line' and then count columns starting from there. To solve this, we must modify mmm-mode itself, since it's the responsibility of mmm-mode to provide information of which column one line should be idented to. But either progmodes or Emacs itself must be modified as well if there is no vertical narrowing, because as far as I know all progmodes use 'beginning-of-line' to address the first location of a line. Options: 1. Modify all progmodes, so that each of them uses another function instead of 'beginning- of-line' to go to the beginning of a line, and then count columns. This function would read a variable specifies which column is the beginning of a line (but actually that's not necessary since the same information of which column is the starting column would be shared by several lines in practice). 2. Modify 'beginning-of-line' so that it reads the variable in option 1. Both could be difficult tasks, but option 1 seems to be more diffcult than option 2. But before doing that, I'd like to ask whether Emacs has provided such a feature so that only mmm-mode itself is needed to be modified. 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/