nim-lang / nim-mode

An emacs major mode for the Nim programming language
139 stars 46 forks source link

Fix smie's indent #73

Closed yuutayamada closed 8 years ago

yuutayamada commented 8 years ago

This PR fix following case

when true:
  if true: break
# <- wrong indent starts here

and most commit are refactoring to avoid avoid smie.el's warnings like ; is both neither and closer. (I seem there is no critical effect, but not good to see.)

yuutayamada commented 8 years ago

Should I remove highlight branch's commits? I thought it will disappear after merging #72, but please let me know I'm doing wrong.

yuutayamada commented 8 years ago

I think I shouldn't. Once I thought it should be dedented, but I realized that we can write other statement or elif/else statement after that if. (But if the break is only one token in the line, dedent next line FYI)

reactormonk commented 8 years ago

Then change that test to contain break as the only token in the line.

yuutayamada commented 8 years ago

There are break tests already in block/while/for, so I merged it.

yuutayamada commented 8 years ago

I changed the break's behavior if the line is else: break:

block:
  if true: echo "else break"
  else: break
echo "`else` with `break` should be dedented"
yuutayamada commented 8 years ago

Also I added finally: break. Probably no more exception? (except template/macro)

yuutayamada commented 8 years ago

Sorry, I was moron. Even if it's else/finally, it doesn't mean next line should be dedented. There is still possibility to indent as same previous line. I'm not sure what is best way...

yuutayamada commented 8 years ago

I made customize variable for it, so users can change the behavior.

yuutayamada commented 8 years ago

Sorry, for those some fixes. I didn't much check about single line including ":". (it worked old indentation code, so). I hope getting stable...