Open fice-t opened 8 years ago
I guess there are two camps of people: those coming from the tabs world perhaps want to set tab-width
to their preferred value and use that everywhere.
Myself, I do want the behaviour described above, so I've added the following to my .emacs
:
(defvar mavit:smart-tabs-languages
(list 'c 'c++ 'java 'javascript 'cperl 'ruby 'nxml)
"A list of languages for which smart-tabs-mode should be enabled.")
(defun mavit:smart-tabs-tab-width-from-mode ()
"Apply the mode's usual indentation when using smart-tabs-mode."
(when smart-tabs-mode
(dolist (language mavit:smart-tabs-languages)
(when (string-equal major-mode
(concat (symbol-name language) "-mode"))
(setq tab-width (symbol-value (nth 2 (nth 3 (nth 2 (nth 3 (assoc language smart-tabs-insinuate-alist)))))))
(return)))))
(add-hook 'hack-local-variables-hook 'mavit:smart-tabs-tab-width-from-mode)
(apply 'smart-tabs-insinuate mavit:smart-tabs-languages)
Would automatically setting
tab-width
to the value ofc-basic-offset
in C/C++ buffers be a good idea?For example, if
tab-width
is 8 andc-default-style
for C/C++ is a style that hasc-basic-offset
of 4 (e.g. stroustrup), then I thinksmart-tabs-insinuate
should settab-width
to 4 to match the offset.