this post was submitted on 19 Nov 2023
1 points (100.0% liked)

Emacs

313 readers
2 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

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?

top 2 comments
sorted by: hot top controversial new old
[–] geza42@alien.top 1 points 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.top 1 points 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.