unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Indentation problem in corporating major modes
@ 2005-11-28  4:39 Herbert Euler
  2005-12-02  2:33 ` Herbert Euler
  0 siblings, 1 reply; 5+ messages in thread
From: Herbert Euler @ 2005-11-28  4:39 UTC (permalink / raw)


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:

   <html>
     <body>
       <h1><?php
         if (something) {
              action;
         } else {
              action;
         }
       ?></h1>
     </body>
   </html>

Content between "<?php" and "?>" 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 "<h1>" 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:

   <html>
     <body>
       <h1><?php
   if (something) {
        action;
   } else {
        action;
   }
       ?></h1>
     </body>
   </html>

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/

^ permalink raw reply	[flat|nested] 5+ messages in thread
* RE: Indentation problem in corporating major modes
@ 2005-12-01  2:21 Herbert Euler
  2005-12-01 11:09 ` David Kastrup
  2005-12-02  2:07 ` Richard M. Stallman
  0 siblings, 2 replies; 5+ messages in thread
From: Herbert Euler @ 2005-12-01  2:21 UTC (permalink / raw)


I saw the following in etc/TODO:

>** Implement a clean way to use different major modes for
>   different parts of a buffer.  This could be useful in editing
>   Bison input files, for instance, or other kinds of text
>   where one language is embedded in another language.

What does clean mean here? Is mmm-mode not clean enough?


Regards,
Guanpeng Xu

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-12-02  2:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-28  4:39 Indentation problem in corporating major modes Herbert Euler
2005-12-02  2:33 ` Herbert Euler
  -- strict thread matches above, loose matches on Subject: below --
2005-12-01  2:21 Herbert Euler
2005-12-01 11:09 ` David Kastrup
2005-12-02  2:07 ` Richard M. Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).