I use evil, which got
(defcustom evil-shift-width 4
"The offset used by \\<evil-normal-state-map>\\[evil-shift-right] \
and \\[evil-shift-left]."
:type 'integer
:group 'evil)
I’d like to set evil-shift-width to the buffer-local indent width (the variable indent).
(add-hook 'after-change-major-mode-hook
(function (lambda ()
(setq evil-shift-width indent))))
What did I miss?
Without more information, I believe I understand the problem to be that desire is for
evil-shift-widthto be set to 4 inpython-modeand 2 inruby-mode(for two examples), yet it is always set to 2.The problem in this case comes from the fact that
indentisn’t defined globally in Emacs, and certainly not inpython-mode. Inpython-modethere is a variablepython-indent, which is set to 4, and that is the variable to use.While annoying to have to use custom variables for each of the major modes, that’s what each of the modes actually use, and that’s probably the solution that will actually work:
Adding a new one for each major-mode you want supported.