Skip to content

Latest commit

 

History

History
141 lines (100 loc) · 2.14 KB

README

File metadata and controls

141 lines (100 loc) · 2.14 KB

-*- mode: org -*-

Indentation in sml-mode doesn’t work well. Trying to understand someone else’s elisp code is a daunting task. In this case it involved tracking emacs’ point through various recursive functions. Even with edebug it is painful.

This is an SML program that indents SML code. It is fast enough to rebind TAB to indent the entire file. A 23k line file (hamlet.sml in the tests directory) takes about .3 seconds to indent.

Misc

Symbols can pop multiple stack elements. E.g. the second ‘val’ pops the context of the first val.

val x = 5 val y = 5

Indenting comments:

orig-indent

____(* ________foo works like this ___*) fun foo x =

______(* __________foo works like this ______*) fun foo x =

____(* ________foo works like this *) fun foo x =

______(* __________foo works like this *) fun foo x =

____(* ________foo works like this ___________and this __*) fun foo x =

______(* __________foo works like this _____________and this ______*) fun foo x =

Problems with indent.sml I don’t care about.


fun f x = 5

| f y = 5

I don’t use fun for pattern matching. I only use fn for this. *)


val f = fn x => x

y = 6

I’d write

val f = fn x => x

y = 6

val f = case f x of x => 5

y => 6

I’d write

val f = case f x of x => 5

y => 6

val _ = 5 handle A => 6

B => 7

I’d write

val _ = 5 handle A => 6

B => 7

if a then b else if c orelse d then e else f

This is hard to fix. We’d want

if a then b else if c orelse d then e else f

but this would make the andalso/orelse handling much more difficult. Both alternatives work:

if a then b else if c orelse d then e else f

if a then b else if c orelse d then e else f