# Strange behaviour debugging a document with AUCTeX-GNUEmacs in math mode

When I try to compile this document

\documentclass{article}
\usepackage{amsmath}

\begin{document}
A simple fraction with an error $\frac{a}{b$
\end{document}


I obviously get an error because there is a missing } in the fraction and then the minibuffer says:

LaTeX errors in *c:/Program Files/emacs-23.3/bin/debug_error output*'. Use C-c  to display.


So I press C-c  and then the windows splits in half and I have two buffers: the lower is the expected TeX Help buffer and the upper is a strange empty buffer called MiKTeX 2.8 in Nroff mode. I also noticed that this happens when there are errors in math commands or something like that.

How to prevent the MiKTeX 2.8 buffer appear? It would be nice to have a workaround.

EDIT: After reading the documentation I found this:

C-c ‘ should always stay in the current window, also when it finds a new file.

-

Invoking latex with -file-line-error-style will fix most of these problems. Your example, however, it will not. You can read the discussion on this Stack Overflow answer. One work around mentioned there is to change what file is the default to be the master file. That way when latex can't say what file the error was in, then AUCTeX will assume it was in the file you are editing. I suspect this will be right over 90% of the time, and extremely confusing the rest. :-)

Adding the following advice to your .emacs file should do the trick.

(defadvice TeX-parse-reset (after make-master-file-default () activate)
(push (concat (substring (buffer-name) 1 (- (length (buffer-name)) 8))
"." TeX-default-extension) TeX-error-file)
(push nil TeX-error-offset))

-
Yes, some kinds of errors like that open a strange buffer. On my machine (with Aquamacs) it's empty and named TeX Live`. –  egreg Apr 20 '12 at 14:43