From: "Herbert Euler" <herberteuler@hotmail.com>
Subject: Re: Is it possible to set a "goal column" for 'beginning-of-line'?
Date: Wed, 23 Nov 2005 16:51:12 +0800 [thread overview]
Message-ID: <BAY112-F23E3DC6DB48603AB3284DADA550@phx.gbl> (raw)
In-Reply-To: <87br0bbzdn.fsf-monnier+gnu.emacs.help@gnu.org>
>From: Stefan Monnier <monnier@iro.umontreal.ca>
>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:
<html>
<body>
<h1><?php
if (something) {
action;
} else {
action;
}
?></h1>
</body>
</html>
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
<html> and <h1> or between </h1> and </html>
in the above example, and behaves like in
PHP mode when point is between <?php and ?>.
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 '<?php' and '?>'
should be idented more than <h1>. But if
you really put point before 'if (something)'
and press <TAB>, 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/
next prev parent reply other threads:[~2005-11-23 8:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.16414.1132712222.20277.help-gnu-emacs@gnu.org>
2005-11-23 7:25 ` Is it possible to set a "goal column" for 'beginning-of-line'? Stefan Monnier
2005-11-23 8:51 ` Herbert Euler [this message]
[not found] <mailman.16440.1132735879.20277.help-gnu-emacs@gnu.org>
2005-12-01 15:49 ` Stefan Monnier
[not found] <mailman.16320.1132664052.20277.help-gnu-emacs@gnu.org>
2005-11-22 18:29 ` rgb
2005-11-22 20:35 ` Stefan Monnier
2005-11-23 2:16 ` Herbert Euler
2005-11-23 2:32 ` Herbert Euler
2005-11-22 12:50 Herbert Euler
2005-11-22 15:35 ` Henrik Enberg
2005-11-22 17:46 ` Henrik Enberg
2005-11-26 9:58 ` Herbert Euler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BAY112-F23E3DC6DB48603AB3284DADA550@phx.gbl \
--to=herberteuler@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).