Despite the fact that using literal tab characters is clearly wrong, there are those in the world who insist on using them, and chances are you'll find yourself collaborating with such people.
For some file types
indent-tabs-modeshould always be
t(e.g. for ChangeLog and Makefile) and for others it should always be
nil(e.g. for LaTeX and TeXinfo).
(add-hook 'find-file-hook (lambda () (if (and (null indent-tabs-mode) (local-variable-p 'indent-tabs-mode) ; Trust the major mode. (save-excursion (goto-char (point-min)) ;; If there are at least 10 lines with a leading TAB, use TABs. (re-search-forward "^ " (+ (point) 100000) t 10))) (set (make-local-variable 'indent-tabs-mode) t))))