At the end of VirTeX-common-initialization
(essentially) TeX-master-file
is added to find-file-hooks
. This is the source for the %%% Local Variables: %%% mode: latex %%% TeX-master: t %%% End:
stuff. (Note, that VirTeX-common-initialization
is the first thing in LaTeX-common-initialization
which is called in TeX-latex-mode
being an alias for latex-mode
.)
To get ride of the automagically added comments you can remove the hook:
(add-hook 'TeX-mode-hook '(lambda ()
(remove-hook 'find-file-hooks (car find-file-hooks) 'local)))
That looks like a hack. But adding TeX-master-file
is quite hard-coded without user-options. So, it seems to me that you have no other chance.
After that correction the auto-insert
stuff works automagically.
(At least for me.)
But, I have replaced the entries in auto-insert-alist
. Meaning, instead of
(define-auto-insert "\\.tex$" "my-latex-template.tex")
I have something like that:
(let ((el (assoc 'latex-mode auto-insert-alist)))
(if el
(setcdr el "/c/temp/autoinsert.tex")
(define-auto-insert "\\.tex$" "/c/temp/autoinsert.tex")))
Maybe, that is important, maybe not. I've got to get home now and I cannot further investigate that.