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

* Re: Indentation problem in corporating major modes
  2005-12-01  2:21 Indentation problem in corporating major modes Herbert Euler
@ 2005-12-01 11:09 ` David Kastrup
  2005-12-02  2:07 ` Richard M. Stallman
  1 sibling, 0 replies; 5+ messages in thread
From: David Kastrup @ 2005-12-01 11:09 UTC (permalink / raw)
  Cc: emacs-devel

"Herbert Euler" <herberteuler@hotmail.com> writes:

> 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?

For one thing, it is not an integral part of Emacs.  For another, it
does not keep indentation, syntax coloring and similar separate for
chunks of different languages.  From the time I tried applying it to
my problems I seem to remember that it did not provide clean hooks for
adding new language combinations.  As a very simple example, take the
code at
<URL:http://cvs.sourceforge.net/viewcvs.py/*checkout*/preview-latex/preview/lib/listsort.tex>.
Can you coax mmm-mode into a mode of working where it will maintain
proper indentation across all corresponding C snippets and do paren
matching and stuff only for the C parts as long as you are in the C
sections?

That's what would be required for editing this sort of thing.

Basically, things like syntax tables and modes would need to be
specifiable by overlays or text properties, and one would need a way
to tie physically apart parts in one language together for the purpose
of syntactical matching and indentation.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Indentation problem in corporating major modes
  2005-12-01  2:21 Indentation problem in corporating major modes Herbert Euler
  2005-12-01 11:09 ` David Kastrup
@ 2005-12-02  2:07 ` Richard M. Stallman
  1 sibling, 0 replies; 5+ messages in thread
From: Richard M. Stallman @ 2005-12-02  2:07 UTC (permalink / raw)
  Cc: emacs-devel

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

I don't know.  What does mmm-mode do?  What are its limitations?
Would the developers sign copyright assignments for it?

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

* RE: Indentation problem in corporating major modes
  2005-11-28  4:39 Herbert Euler
@ 2005-12-02  2:33 ` Herbert Euler
  0 siblings, 0 replies; 5+ messages in thread
From: Herbert Euler @ 2005-12-02  2:33 UTC (permalink / raw)


I now realize the critical point in this problem. Before
solving it, I must be familiar with how Emacs indents,
how major modes work, how mmm-mode works,
and probably many other things. This will take time,
but I'll try my best.

Mmm-mode is an extension of Emacs, the homepage
of mmm-mode is http://mmm-mode.sourceforge.net/ ,
and it distributes with GNU GPL. Mmm-mode is a minor
mode for Emacs which allows Multiple Major Modes to
coexist in a single buffer.

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-12-01  2:21 Indentation problem in corporating major modes Herbert Euler
2005-12-01 11:09 ` David Kastrup
2005-12-02  2:07 ` Richard M. Stallman
  -- strict thread matches above, loose matches on Subject: below --
2005-11-28  4:39 Herbert Euler
2005-12-02  2:33 ` Herbert Euler

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