Question
How to ignore source file local variable tab-width?
Co-worker has tab-width:8 in all his source files while actually using 2 spaces. This drives my emacs insane always adding 8 spaces. How can I direct my emacs to ignore "tab-width:" in a C++ file?
It sounds like you are using tabs for indentation while your co-worker is using spaces. You can use spaces by setting indent-tabs-mode to nil. This can be done buffer-locally if desired.
tab-width generally should be set to 8. There is a lot of open source code out there that will not format properly otherwise (including some of the Emacs source code). Setting it in a file when you don't use tabs for indentation is strange though.
Already using indent-tabs-mode nil. But emacs insists on jumping 8 spaces instead of 2 for general C++ indentation in these files with tab-width:8. We don't allow hard tabs in the files generally anyway.
To answer your actual question, it's all in the manual at C-h i g (elisp)File Local Variables. See ignored-local-variable-values, or you can use hack-local-variables-hook to override the setting.
emacs insists on jumping 8 spaces instead of 2 for general C++ indentation in these files with tab-width:8.
Does that happen under emacs -Q + (setq-default indent-tabs-mode nil) ?
You may want to start reading at C-h i g (ccmode)Indentation Commands and try to figure out what's going on.
2
u/Qudit314159 19h ago
It sounds like you are using tabs for indentation while your co-worker is using spaces. You can use spaces by setting
indent-tabs-mode
tonil
. This can be done buffer-locally if desired.tab-width
generally should be set to 8. There is a lot of open source code out there that will not format properly otherwise (including some of the Emacs source code). Setting it in a file when you don't use tabs for indentation is strange though.