(X)Emacs, python-mode, mmm-mode, and Spyce 
Author Message
 (X)Emacs, python-mode, mmm-mode, and Spyce

Quote:

> Hi. I'm a very complete newbie to python and programming in
> general. Please read on anyway! ;-)

> I want to use XEmacs (or if need be, GNU Emacs) with
> python-mode to edit HTML pages including Spyce code
> ( http://www.*-*-*.com/ ).

[Snip details of question]

I don't know enough about Emacs to be able to answer your question.
There may be some people here who do. But if you don't get a productive
answer here, you might try asking this over on comp.emacs.xemacs -- my
guess is they would be much more able to help you.

Good luck getting this worked out!

--

http://www.*-*-*.com/
PGP key ID: 0x6AFB6838    50FF 2478 CFFB 081A 8338  54F7 845D ACFD 6AFB 6838



Sat, 23 Jul 2005 02:43:39 GMT  
 (X)Emacs, python-mode, mmm-mode, and Spyce

Quote:
> I want to use XEmacs (or if need be, GNU Emacs) with
> python-mode to edit HTML pages including Spyce code
> (http://spyce.sourceforge.net).

> Spyce uses delimiters [[ and ]]; between
> [[\
>         and
> ]]
> you put regularly indented Python code.

> So, having files consisting of HTML and Python, I've set up both
> Emacsen like this (Spyce files have .spy names):

>[mmm setup omitted)

> This works generally, nicely colouring ("font-locking") both the HTML
> and the Python code, but there is a problem: when pressing TAB inside
> this Spyce block at the beginning of the "print i," line:

> [[\
>    print 'world!',
>    for i in range(10):
>             print i,
> ]]

> the line gets indented like this:

> [[\
>    print 'world!',
>    for i in range(10):
>    print i,
> ]]

> which is wrong, of course. This happens at any code line ending with
> ":" as far as I can see. I have also tried two-mode-mode instead of
> mmm-mode; the result is the same.

I've never used mmm (I guess I should) but when editing empy code
expanding to xml I just bound two function keys to python-mode and
xml-mode and switched at will.  It's almost convenient so you could try it
if mmm fails...

Quote:
> Above code in a .py file / python-mode only buffer gets indented
> correctly.

Just the code - yes.  But when I also put the ``[[`` (with the backslash
or without), it doesn't indent correctly for me (in plain python-mode).
Actually sometimes it even flushes some code far to the left:

[[\
    #the empty line is significant
    if x:
if y:
    foo

]]

The problem, of course, is that python-mode scans backards and sees that
it's inside a list context, where indentation is not significant.  I don't
think mmm (or similars) can work around this.  The only chance I see is to
narrow to the python part for the duration of the command.  I tried it and
it seems to work (except for the first line - reindenting it keeps
increasing the indentation unless it's in the left column.  So write a
command to narrow to the lines between the ``[[`` and `]]`.  It will serve
you for big editing.  For quick usage, rebind TAB to call the narrowing
function, indent and widen.

If this doun't work, my best idea is to prefix the ``[[`` and ``]]``
markers with ``#``, so that they don't confuse python-mode and filter them
to get a version that works with Spyce.  If you want to be fancy, you can
convince emacs to run the filtering automatically when reading/saving...

--

Do not feed the Bugzillas.



Mon, 25 Jul 2005 01:52:50 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. eruby and emacs mmm-mode

2. Emacs VHDL editing mode (vhdl-mode.el version 2.74)

3. Emacs VHDL editing mode (vhdl-mode.el version 2.71)

4. Emacs VHDL editing mode (vhdl-mode.el version 2.56.1.1)

5. Emacs VHDL editing mode (vhdl-mode.el version 2.56.1.1)

6. VHDL mode for Emacs (vhdl-mode.el version 2.50)

7. emacs outline mode for fortran and f90 mode ?

8. Python Mode 3.77 for Emacs/XEmacs

9. Python outline mode in emacs

10. emacs python mode completion

11. Emacs python mode, pyshell behaving strangely (win2k)

12. emacs python mode

 

 
Powered by phpBB® Forum Software