Update:
I've tested the problem in detail, and the results are appended at the end of the question. I guess now the problem becomes: How to avoid stupid diagnostic of AUCTeX when curly braces mismatch?
Original question:
I have the following line
(add-hook 'LaTeX-mode-hook 'TeX-global-PDF-mode)
in my ~.emacs
that turns on global pdf mode by default. This way, by configuring TeXShop for external editor, I can use it as the previewer every time I C-c C-c LaTeX
in emacs.
However, sometimes after a typesetting error occurs and C-c (backtick)
is used to view error (details below), the pdf mode seems to be disabled. After fixing the mistake, dvi is generated rather than pdf, and the pdf never gets updated again. I need to exit emacs and restart to restore pdf mode.
Why does this behavior occur? Any fix? I'm using Emacs 24.3.0 with AUCTeX 11.87 (both are the current version).
Update:
The detailed workflow that triggers the problem:
-
Start emacs with a
.tex
file and(add-hook 'LaTeX-mode-hook 'TeX-global-PDF-mode)
in startup file. The initial mode isLaTeX/P Fill
,LaTeX-mode
major mode, withTeX-PDF-mode
andauto-fill-mode
minor modes (that autofill mode may be due to my turning on auto fill in my startup file; I didn't test whether AUCTeX start with autofill by default). -
Make a non-standard curly braces mismatch error, for instance,
% header \begin{document} \MACRO{ \end{document}
where
\MACRO
is not a default macro, but maybe something defined in% header
withnewcommand
. StillLaTeX/P Fill
. -
C-c C-c RET
(useLaTeX
to typeset by default). Error is reported:LaTeX errors in `*DIR/FILE output*'. Use C-c ` to display.
Still
LaTeX/P Fill
. -
C-c (backtick)
to trigger functionTeX-next-error
. A strange buffer appears, namedTeX Live 2012
. The minibuffer below prompts foroptions, RET:
At this time, the mode becomesLaTeX Fill
; pdf mode is toggled away. -
C-g
to quit the function. The buffer is returned to the original editing buffer (but note that theTeX Live 2012
buffer is still in the background; you will be prompted to save it when you try to quit emacs). StillLaTeX Fill
. -
Now fix the buggy code and
C-c C-c RET
again. This time, dvi is generated instead of pdf since nowTeX-PDF-mode
isnil
.
Stray away: if I follow the prompts in step 4 instead of C-g
, I will end up with the buffer TeX Live 2012
containing
\documentclass[OPTIONS]{CLASS}
\begin{document}
\end{document}
A new file! Well, not very helpful. I just missed one curly brace… And you ask me to rewrite the file… Nevertheless, the TeX Live 2012
buffer at this time will be LaTeX/P Fill
.
At last, a small working example that triggers this behavior:
\documentclass{amsart}
\newcommand{\set}[1]{\left\{#1\right\}}
\begin{document}
$\set{$
\end{document}
Best Answer
Here is my setup and I never have had an issue over a compiling error. I just fix whatever the error says and run it again.
You MWE doesn't cause the same issue when I run the code. It might be your Emacs setup.