I author web apps with the web-mode
in GNU Emacs, and I use 2 spaces for indentation.
After I examined the web-mode
source, I found out that the mode defaults to the standard-indent
variable, which in turn defaults to 4
; and if standard-indent
is unset, web-mode
defaults to 2
. I'm not sure if I got the terminology correct, and I guess some older versions of Emacs didn't set the variable, so I got 2-space indent out of the box.
Excerpt from web-mode.el
:
(defcustom web-mode-css-indent-offset
(if (and (boundp 'standard-indent) standard-indent) standard-indent 2)
"CSS indentation level."
:type 'integer
:safe #'integerp
:group 'web-mode)
Obviously, the custom variables' defaults are set during load.
How can I set standard-indent
to 2
while web-mode
loads? Given the way web-mode
initializes its costomization variables, I think it has to be done while the mode is being loaded into Emacs, and not when I enter the major mode. How do I do that?