Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Missing: Proper Indentation and Code Folding #4

Closed
mxmerz opened this Issue · 3 comments

2 participants

@mxmerz

Hi, I use the Erlang bundle a lot and I'd like to point out two things that really bug me: Indentation and Code Folding.

For example, I start typing this (caret indicates the caret):

function() ->
    my_module:do_stuff().‸

and then hit return, I stay on the same indentation level:

function() ->
    my_module:do_stuff().
    ‸

Even worse, if I delete the tab, hit return and start with my next function, I get back-indented.
I've got the same problem with the semicolon:

function () ->
    my_module:do_stuff(),
    case expression of
        pattern when guard ->
            do_stuff();‸
    end.

I hit return:

function () ->
    my_module:do_stuff(),
    case expression of
        pattern when guard ->
            do_stuff();
            ‸
    end.

I tried to fix this myself by modifying decreaseIndentPattern but I'm not that good with regular expressions (and therefore failed). As far as I know, code folding doesn't exist at all in the Erlang bundle.

Is it even possible to solve this indentation-/code-folding-problem with Textmate bundles, regarding the "unusual" syntax of Erlang?

@mxmerz

Okay, I digged a bit deeper and now I'm frustrated. The problem seems to be how TextMate handles indentation and code folding:
TextMate seems to be incapable of assigning more than one indentation- or folding-attribute to a single line. Also, the "closing" line has to be at the same indentation level as the "opening" line to let folding work.
Both of these limitations make it impossible to do proper Erlang code indentation/folding:

%% How you would normally write Erlang:
function1(Tralala) -> %% opening statement (1)
    case morgen_kommt_der() of %% opening statement (2)
        nikolaus -> %% opening statement (3)
            bi:ba(),
            butzemann; %% closing statement (3), one indentation level 
                       %% above it's opening statement
        {ok, haenschen} -> %% opening statement (4)
            [klein, Tralala] %% implicit closing statement (4)
    end. %% closing statements (2) and (1) in one line
%% What I got working in TextMate:
function2(Tralala) ->
    case morgen_kommt_der() of
        nikolaus ->
            bi:ba(),
            butzemann
        ;
        {ok, haenschen} ->
            [klein, Tralala]
        ; %% compile error 
    end
.

The latter would be rather ugly and wrong Erlang code.
I hope I'm missing some undocumented feature of TextMate 2.0 that makes Erlang indentation and code folding possible, but I'm not too optimistic.

@infininight
Owner

Fully correct indentation isn't currently possible with TextMate. I have disabled the re-indentation it will do in abafcb9 and added folding for functions in 9c884e3.

@mxmerz

Wow, thank you!

@mxmerz mxmerz closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.