I have my tab width set to two spaces and this has worked fine for many years. I have just upgraded to Emacs 27.1, and now js-mode
is displaying tabs as three spaces wide, ignoring my preferred settings (which still apply to other modes, it's only js-mode
that isn't respecting my preference.)
I can't work out how to make it go back to 2. The tab width is still set to 2 in my init.el
file, which hasn't changed during the Emacs upgrade.
If I press M-x and run set-variable
then set tab-width
to 2, the file goes back to the correct tab width. But I can't work out how to make it apply to all files. If I press ?
instead of 2
when setting tab-width
then it tells me it is already set to 2 (which it is, in my init.el
) however it seems I have to set it to 2 again, even though it's ready 2, for every .js
file that I open.
How can I make it so that js-mode
respects the tab widths I have set in init.el
, as it did in earlier Emacs versions?
I've looked through all the options but I can only see two that are related to the tab width and they are already set to 2.
Is anyone else running Emacs 27.1 or newer? Have you successfully changed the tab width for .js
files?
debug-on-variable-change
ontab-width
and found that it was invariably being set to2
byjs-mode
because of git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/…. Can you do the same and see what is changing it when you open a JS file? I ended up settingc-default-style
touser
, which for me defaults to4
.4
, then somehow ending up as 3 anyway. Myc-default-style
is already set to my own custom one but strangely if I useM-x set-variable c-default-style
it won't accept anything, including my custom one in init.el oruser
...