Macaulay2 / M2-emacs

Macaulay2 emacs files
GNU General Public License v3.0
5 stars 3 forks source link

Indent after `->` #32

Open mahrud opened 2 years ago

mahrud commented 2 years ago

I think it would be nice to standardize an indent after symbols like ->. For example:

myFunction = {} >> o ->
    n -> if n > 0 then 10^n else error "an annoyingly long error message here"

myMethod ZZ := n ->
    n > 0 then 10^n else error "an annoyingly long error message here"

Not sure what other symbols, but probably all symbols associated to binary operators should get an indent if the second operand doesn't come before a newline.

@d-torrance do you happen to know how this would be implemented?

d-torrance commented 2 years ago

@d-torrance do you happen to know how this would be implemented?

We'd probably need to overhaul the indentation code quite a bit. Right now, we basically just assume it's Lisp code and use parse-partial-sexp to figure out how many levels of parentheses we're inside and indent that many times. We could probably get inspiration from some other major modes' indent-line-function's.

I agree this would be a really cool feature!