Open pacien opened 6 years ago
Yes I can confirm this. It is even worse that this. Sometimes nim-indent-post-self-insert-function
breaks the code after typing a ":". So I recommend to disable electric-indent-mode
for Nim if you don't want nim-mode to break your code automatically during typing.
you can set nim-smie-indent-dedenters
to nil
for your case
@yuutayamada I think you miss the point. Electric indent should never ever break the logic in the code. When electric indentation isn't 100% sure of what it is doing it is better if it isn't doing anything at all.
@pacien I have an open PR that rewrites the readme, this is how I would write it: https://github.com/nim-lang/nim-mode/blob/ea6fad3be9b16773f3769581992b1208d3b4342e/README.md
Maybe you get some valuable information from it.
@krux02 I think he is mentioning indent-region. electric-indent is for manual indentation line by line.
isn't electric indentation and indent-region besad on the exact same rules?
@krux02 in pacien's example, it's clearly the problem comes from the variable I mentioned (I tested), not from electric indentation
If you are talking about nim-indent-post-self-insert-function
for electric-indent-mode
, it has condition below and I think it will be blocked due to (eq (char-before) last-command-event)
because you gonna need to mark the region.
(when (and electric-indent-mode
(eq (char-before) last-command-event))
It's a nightmare to learn all the pitfall of automatic code breaking indentation changes in electric-indent-mode. You save every Nim developer who wants to use emacs a lot of trouble and time if you just delete without substitution nim-indent-post-self-insert-function
.
maybe but it's off topic in this issue board
Conforming Bugs
Please tell us below:
*Messages*
buffer? noAnd describe your problem:
Original file: correctly indented manually
After
mark-whole-buffer
andindent-region
: indent is broken