Open bogolisk opened 5 days ago
Re-indent the entire file: C-x h
C-u Tab
. Or update your indentation settings to match the file's.
indent-bars
learns about indentation from the settings like c-basic-offset
. If your file doesn't respect that, problems ensue.
That is zephyr's official code, not mine. I'm just reading zephyr's code in emacs. They use linux style.
in that buffer: c-basic-offset is: set-from-style c-indentation-style is: linux
I understand, but the source of the code doesn't matter here. indent-bars
must be able to learn the indent block size to do its work. All it does for c-modes is:
((and (local-variable-p 'c-basic-offset) (numberp c-basic-offset))
c-basic-offset)
What is the value of c-basic-offset
after your buffer has initialized? Presumably it must be some number.
I'm using c-ts-mode, so this "patch" fixed the issue
$ diff -wu indent-bars.el.orig indent-bars.el
--- indent-bars.el.orig 2024-07-01 17:32:15.787381000 -0400
+++ indent-bars.el 2024-07-02 08:51:08.066778000 -0400
@@ -1506,6 +1506,9 @@
web-mode-html-offset)
((and (local-variable-p 'c-basic-offset) (numberp c-basic-offset))
c-basic-offset)
+ ((and (local-variable-p 'c-ts-common-indent-offset)
+ (symbolp c-ts-common-indent-offset))
+ (symbol-value c-ts-common-indent-offset))
((and (derived-mode-p 'yaml-mode) (boundp 'yaml-indent-offset))
yaml-indent-offset)
((and (derived-mode-p 'elixir-mode) (boundp 'elixir-smie-indent-basic))
Thanks. I'll check with the c*-mode people and implement something like this. I wonder why it doesn't update c-basic-offset
? It is unfortunate that emacs doesn't provision a single local variable for this widely used information.
Please see if 756cfb0 works.
The code is from https://elixir.bootlin.com/zephyr/latest/source/kernel/msg_q.c#L330
I just loaded the 2 .elc files and M-x indent-bars-mode. My emacs is 29.2.
Why the bars in the middle of the TABs?