emacs-devel
[Top][All Lists]

## Re: address@hidden: tex-mode: too many _ (underscores) interpreted as su

 From: Ralf Angeli Subject: Re: address@hidden: tex-mode: too many _ (underscores) interpreted as subscripts] Date: Tue, 05 Oct 2004 12:16:16 +0200 User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

[My last mail was sent prematurely.  Here is the rest of the answer.]

* Richard Stallman (2004-10-04) writes:

> Meanwhile, why is texmathp so slow?

It can happen that texmathp' has to re-search-backward' through the
whole buffer.  We had a bug report in AUCTeX where a file was supplied
which demonstrated the problem in a highly exaggerated way which lead
to fontification eating up a large amount of CPU resources.  The file
was about 10,000 lines and repeatedly contained

--8<---------------cut here---------------start------------->8---
\newcommand{\mycontent}{\ensuremath{\lambda_{1}}}%
\begin{itemize}%
\item
\begin{align*}%
\left\{
\begin{array}{l}
b_{c} \text{some long line with $\mycontent$}
\end{array}
\right\}
\end{align*}%
\end{itemize}%
--8<---------------cut here---------------end--------------->8---

texmathp' tries to limit the backward search by finding empty lines
which may denote a paragraph separation.  In the file there were no
empty lines, so at the end, it had to search all the way up those
10,000 lines for math environments.

The search involves two passes: One for commands and one for
environments.  The closer match is selected.  Currently both passes
can be limited only by the empty-line heuristic.  One could probably
speed the process up by limiting one search by the result of the
other.

--
Ralf

`