2
votes

I'm writing a major mode for editing my custom language sources with Emacs (although I don't know Lisp). Syntax highlighting is very easy to implement, but now I'm trying to setup the auto-indentation and I can't.

I have test this code and it is perfect for '{', '[', ']' and '}' characters. For example, in my tests, if I change "[[{]" regex by "[[:]", it doesn't auto-indent with ':'. Why? I'm going crazy!

My real purpose is to indent blocks between if and endif keywords, and between while and endwhile keywords. For example:

if a > 0
    b = 2
    while b = 2
        a = 0
    endwhile
endif
1

1 Answers

1
votes

Auto-indentation is not as simple as syntax highlighting, by a long stretch. There is precious little generic support for indentation. If you're using a recent enough Emacs, you might like to try and use the SMIE package. Maybe a good way to try it out is to look at how octave-mod.el uses it (e.g. in Emacs-24). But don't expect it to be easy.