> I am creating a new language mode for Erlang (http://www.erlang.org)
> and I am having a bit of troubles with the indentation. Here are a
> few examples of simple things (to get an idea for the indentation).
> (I added the prefixing '.' characters for space indents).
> say_hello() -> io:format("Hello, World!\n");
> say_hello(Name) ->
> ....io:format("Hello, ~w\n", [Name]),
> ....io:format("How are you doing?\n", ).
> That was easy and is fully functional. Here's one area I am having a
> problem with though:
> say_bye() ->
> ....case to_who() of
> ........person ->
> ............io:format("Bye Person");
> ........Other ->
> ............io:format("Bye Other")
> The above example is correct but I cannot make it work like this.
> First, the io:format("Bye Other") does not contain any special
> character on the end of it to indicate an outdent, but it should be
> outdented -4.
> Second, the "end."... the "end" part should indicate outdent this
> line -4, but then the "." on the end of the "end." line should
> indicate outdent the next line -4. So, it's like a multipart end.
> Now, I did make this part work ("end.") by matching "end." and
> outdenting it -8, but that was confusing to read because it aligned
> with the person, Other selection not the "case" in which it end's.
> For the indent engine, this is what I currently have. If anyone
> could be of assistance with this I would greatly appriciate it.
> !if &sin "d" .fhook-erlang.setup
> ; define indentation scheme
> 0 indent .hilight.erlang 0 10
> indent .hilight.erlang n "->" 4
> indent .hilight.erlang n "case" 4
> indent .hilight.erlang n "\\." -4
> indent .hilight.erlang n "end." -8
> indent .hilight.erlang o "end" -4
> indent .hilight.erlang n "[;.]" -4
> indent .hilight.erlang b "(" ")"
> indent .hilight.erlang i "fun.*end"
> indent .hilight.erlang i "%"
> P.S. please respond to the list as I do not yet have email back up
> and working after the hack to my main server.
0 indent .hilight.erl 0 10
indent .hilight.erl n "->" 4
indent .hilight.erl n "case" 4
indent .hilight.erl o "end" -4
indent .hilight.erl n "[;\\.][ \t]*$" -4
indent .hilight.erl n ")[ \t]*$" -4
; indent .hilight.erl b "(" ")"
indent .hilight.erl i "fun.*end"
indent .hilight.erl i "%"
By loosing the "b" on () token then it seems to work
better and use the fact that the a ) at the end of
a line causes an indent. Then the ends are the
same and the '.' also moves back an indent.
There are problems with the bracket when
you define a bracket then you cannot cause
an indent on the bracket token. This is
a bit of a shame it would be nice to
be able to define the bracket and still
have the indent detect that a )$ causes
an indent. The "end." works nicely as
the end causes the current line to be
indented by -4 and then . indents
the next by -4.