I\'ve been unsuccessful in getting Emacs to switch from 8 space tabs to 4 space tabs when pressing the TAB in buffers with the major mode text-mode
.
Have you tried
(setq tab-width 4)
Modified this answer without any hook:
(setq-default
indent-tabs-mode t
tab-stop-list (number-sequence 4 200 4)
tab-width 4
indent-line-function 'insert-tab)
By the way, for C-mode, I add (setq-default c-basic-offset 4)
to .emacs. See http://www.emacswiki.org/emacs/IndentingC for details.
You may find it easier to set up your tabs as follows:
M-x customize-group
At the Customize group:
prompt enter indent
.
You'll see a screen where you can set all you indenting options and set them for the current session or save them for all future sessions.
If you do it this way you'll want to set up a customisations file.
(customize-variable (quote tab-stop-list))
or add tab-stop-list entry to custom-set-variables in .emacs file:
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(tab-stop-list (quote (4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120))))
(setq tab-width 4)
(setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80))
(setq indent-tabs-mode nil)