I have used the Emacs modeline for a while in my sources, to use tabs instead of spaces.
For example,
/* -*- indent-tabs-mode: t -*- */
For many uses (C++) this is not enough as Emacs insists in using tabulation for alignment. (See here: Modeline for indentation with tabs in Emacs)
Finally, I found a solution here: Emacs: Insert tab instead of spaces
(defun infer-indentation-style ()
;; if our source file uses tabs, we use tabs, if spaces spaces, and if
;; neither, we use the current indent-tabs-mode
(let ((space-count (how-many "^ " (point-min) (point-max)))
(tab-count (how-many "^\t" (point-min) (point-max))))
(if (> space-count tab-count) (setq indent-tabs-mode nil))
(if (> tab-count space-count) (setq indent-tabs-mode t))))
(setq indent-tabs-mode nil)
(infer-indentation-style)
However, it is not a replacement for a modeling since it is a bunch of complicated code that I can't put in a single line between /* */.
Is it possible to convert this complicated into a single line modeling directive?
I would suggest to put the function definition into your emacs configuration file so it loads up when ever you start emacs.
Then you can use that function to evaluate buffer local variable with
eval