mako-nhxtml-mumamo-mode doesn't indent correctly

Asked by Francesco Mazzoli

When editing mako files, the indentation doesn't work properly for control flow statements using the "%" character.
For example, this code gets indentated like that:
       % if True:
            <br> hello </br>
            % else:
            <br> world </br>
                % endif

The % else and % endif get indentated 4 spaces forward instead of being at the same level as % if True:.
I am using emacs 23.2-r2 with the last bzr revision of nxhtml.

Question information

Language:
English Edit question
Status:
Answered
For:
nXhtml Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
lborgman (lennart-borgman) said :
#1

Hi rostayob, thanks for the report.

However please look in the bug database. Indentation in mako is broken and it is a bit of work to fix it. Contributions are welcome!

Revision history for this message
Francesco Mazzoli (rostayob) said :
#2

Thanks for the answer.
Sadly i don't know much about emacs lisp, so I guess I'll have to wait...
Do you think the issues will be solved soon?

Revision history for this message
lborgman (lennart-borgman) said :
#3

Unfortunately I think it will not be fixed soon. I have a lot of other things to fix in Emacs that I must priorities over this. (If someone is willing to help it can be fixed soon, of course.)

Revision history for this message
Francesco Mazzoli (rostayob) said :
#4

Thanks for the answer.
Where would you suggest to start if I wanted to learn just enough emacs lisp to fix this :P?
I code in mako all the time and I love emacs, but it's quite a pain right now.

Revision history for this message
lborgman (lennart-borgman) said :
#5

I would be glad for your help especially since you know Mako and I don't, but please be aware that it is not very simple to fix this.

At the moment I have not even been trying to get the logic for indenting Mako right. And I am not sure the available "building blocks" in nXhtml for doing it is there yet.

Indentation is a quite difficult problem since it may require some kind of parsing of the code to determine the desired indentation level. And it does not get easier with code that mixes what Emacs thinks are major modes. And on top of this Emacs does not yet have good basic functions for writing support for multiple major modes. (And it is not trivial to add this to Emacs and keep backward compatibility though I have ideas for how to do it.)

If this did not scare you too much then please look in mumamo.el where you can see how indentation is generally handled. Too see more specific things please look in mumamo-chunks.el and mumamo-fun.el.

Some of the tricks for eRuby can perhaps be used for Mako, but mako is a bit more complicated. Maybe a totally different road for indentation should be used for Mako.

Revision history for this message
Francesco Mazzoli (rostayob) said :
#6

Ok, as soon I will have some free time - which might be in a long time... - I'll study emacs lisp and see, since it's an issue that really interests me.
You'll hear from me soon!

Can you help with this problem?

Provide an answer of your own, or ask Francesco Mazzoli for more information if necessary.

To post a message you must log in.