When using cs-ts-mode, it incorrectly forces me to use paranthesis. For example:

  if (whatever == -1)

it won’t auto-indent the next line unless I use braces {} with the if statement, even if there is just one statement with a semi-colon after the if. Also, as I’m typing, it weirdly indents my functions as I type them.

Any way to fix these?

  • geza42@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    Emacs has electric-indent-chars. Whenever a character in this set is pressed, Emacs re-indents the current line. And as the indentation calculation is not perfect, it can happen that when you create a new line, its indentation calculated incorrectly, and during editing you press some electric-indent-char, which then re-indents the line.

  • eli-zaretskii@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    I cannot reproduce this. Maybe the surrounding code in your case caused what you describe, but if I take a valid C function and insert if (whatever == -1) into it, then after typing RET, the next line will be indented as expected.