0

I see some odd Emacs behavior in C-mode recently. I suspect that the change happened either when switching from SLES 12 SP4 to SLES12 SP5 (both have Emacs 24.3), or when switching from SLES 11 SP4 (Emacs 22.3) to SLES 12 (SP3).

The effect is that indentation suddenly seems broken while writing C code, and surprisingly neither a redraw, nor a revert-buffer does fix the problem.

When Emacs is unable to indent the code correctly, the code compiles fine (so it does not have any syntax errors in it). However killing the buffer and reopening the file fixes the problem.

When formatting is broken, all lines are moved "flush left" as can bee seen in this simple example:

C code with correct formatting

When I move the cursor to the first line of code and press TAB, then formatting changes like this:

C-code after having pressed TAB on the first code line

The only customization I had made is set c-default-style to "bsd" for c-mode.

I suspect the problem might have to do with inserting a line break between "static inline" and the function type, but I want to avoid very long lines.

Questions:

What might be causing this effect? How can I fix the problem more elegantly than reopening the file?

2
  • What is TAB bound to? Do C-h c TAB to find out. That's the first step.
    – NickD
    Aug 13, 2021 at 16:04
  • TAB is bound to c-indent-line-or-region (and the indent shown in the screen shots in one TAB).
    – U. Windl
    Aug 16, 2021 at 5:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.