# Setting Emacs TeX-engine locally does not work

I'd like to follow the advice from @egreg in his answer to the question AUCTeX and XeTeX. However the given code does not work for me.

I have:

\documentclass{article}
\usepackage{fontspec}

\begin{document}
\section{title}

test

\end{document}

%%% Local Variables:
%%% coding: utf-8
%%% mode: latex
%%% TeX-engine: luatex
%%% End:


but when I try to compile with C - c C - c I get the classic:

fatal error, fontspec requires...

If I change the TeX-engine globally with M - x -> customize-variable -> TeX-engine everything works fine.

I have emacs 24.4.1 and AUCTex 11.88

• The change to the local variables is recognized only the next time the file is visited. – egreg Nov 26 '14 at 12:55
• @egreg I see... Is there a way to force the reload or something similar without closing/reopening the file? – skey Nov 26 '14 at 13:10
• Go to the "Command>TeXing Options" menu and choose "Use LuaTeX engine" – egreg Nov 26 '14 at 13:15
• well, that's it. I removed the menubar but this may be a reason to put it back. thanks – skey Nov 26 '14 at 13:26
• Or issue C-c C-n, this resets AUCTeX. – giordano Nov 26 '14 at 13:58

The error pointed out in comment is that the file must be reload to change the local variable. Emacs permit to do it using M-x revert-buffer and answer yes to the confirmation.

• Alternatively you can run M-x normal-mode on the buffer. – Andrew Swann Aug 14 '15 at 7:56
• @AndrewSwann Or M-x TeX-normal-mode... Or C-c C-n... – Paul Gaborit Aug 18 '15 at 21:50

There is also the function hack-local-variables. C-h f hack-local-variables RET says:

hack-local-variables is a compiled Lisp function in files.el'.

(hack-local-variables &optional MODE-ONLY)

Parse and put into effect this buffer's local variables spec. Uses hack-local-variables-apply' to apply the variables. [...]

M-: (hack-local-variables) RET in a buffer should do the trick.