From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: Is it possible to set a "goal column" for 'beginning-of-line'? Date: Thu, 01 Dec 2005 10:49:31 -0500 Organization: Bell Sympatico Message-ID: <87k6epsedf.fsf-monnier+gnu.emacs.help@gnu.org> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1133459015 19739 80.91.229.2 (1 Dec 2005 17:43:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 1 Dec 2005 17:43:35 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 01 18:43:24 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EhsPD-0007iw-Fg for geh-help-gnu-emacs@m.gmane.org; Thu, 01 Dec 2005 18:39:40 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EhsP7-0007Gm-SD for geh-help-gnu-emacs@m.gmane.org; Thu, 01 Dec 2005 12:39:33 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nf3.bellglobal.com!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:PCREbFw5R9xalDvDoUlSBegV1do= Original-Lines: 62 Original-NNTP-Posting-Host: 67.71.25.91 Original-X-Complaints-To: abuse@sympatico.ca Original-X-Trace: news20.bellglobal.com 1133452171 67.71.25.91 (Thu, 01 Dec 2005 10:49:31 EST) Original-NNTP-Posting-Date: Thu, 01 Dec 2005 10:49:31 EST Original-Xref: shelby.stanford.edu gnu.emacs.help:135969 Original-To: help-gnu-emacs@gnu.org 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:31576 Archived-At: > I'll try to explain it more clearly as follows. > Typically a php file contains content like this: > > >

if (something) { > action; > } else { > action; > } > ?>

> > > 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. I see. While I'd be quite happy to see the PHP code at column 0, I can understand that some people may prefer it to be somewhere else. But I think the problem is slightly more complex than what you describe: - indentation code typically uses `current-column' and `current-indentation' to figure out the indentation of previous lines (and then compute the desired indentation of the current line) and then `indent-to' or `indent-line-to' in order to do the actual indentation. Those are coded directly in C and don't use beginning-of-line. - [ I don't know php-mode in particular. ] For some major modes column 0 is treated specially, typically by assuming that function definitions are at column 0. So if you really force all indentation to start at column 8, several things may not work correctly (e.g. font-lock highlighting, imenu, outline-minor-mode, ...). - Some indentation algorithms first go back to "the beginning of the function" or something similar and then move forward from there. This starting point is often searched with a regexp that assumes that it's placed at column 0. For the first point, maybe the best solution is to use `defadvice' on current-column, current-indentation, and indent-to. In many cases, it may be sufficient to pretend that the starting point of the PHP block is "at column 8" and then the indentation algorithm will automatically preserve this indentation. For the second point, the only solution I can think of is to really place the text in column 0. In order for you to see the text in column 8, you can do things like add an overlay on every newline and place on the overlay an after-string of " ". So the text will *appear* on screen in column 8, even though in the buffer and in the file it's actually in column 0. As for using fields, you can try, but I'd be surprised if it works. Stefan