Subject: bug#19624: RefTeX TOC should not scan words in verbatim environments

From: Zengxu Yang <[email-masked]>
Date: Sun, 18 Jan 2015 20:16:27 -0500

RefTeX TOC scans words in verbatim environments, too. And this makes TOC
incorrect. For example,

\documentclass{article}

\begin{document}
\section{First}
\label{sec:first}

\section{Second}
\label{sec:second}

\begin{verbatim}
\section{Third}
\end{verbatim}

\section{Last}
\label{sec:last}

\end{document}

Section "Third" is in a verbatim environment and should not be shown in
RefTeX TOC. But the RefTeX TOC buffer is shown as:

TABLE-OF-CONTENTS on ~/Documents/test/emacs/reftextest.tex
SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r
[?]Help
------------------------------------------------------------------------------
     1 First
     2 Second
     3 Third
     4 Last

Verified using Emacs 24.4 with AucTeX 11.87 on Debian 8.

The best solution is skipping scanning all predefined and user defined
verbatim environments in AucTeX(for example, verbatim, Verbatim, minted).