Subject: bug#29401: 11.90.2.2017-07-25; Folding displays errors on valid LaTeX

From: Mosè Giordano <[email-masked]>
Date: Thu, 23 Nov 2017 00:34:44 +0100

Dear Koen,

2017-11-22 17:55 GMT+01:00 Koen van Greevenbroek
<[email-masked]>:
> Hi!
>
> Some valid LaTeX is parsed incorrectly by AUCTeX folding functions
> (i.e. 'TeX-fold-region'), and an annoying error is displayed. Here is
> an
> example:
>
> ===========================
> \documentclass{beamer}
> \begin{document}
> \begin{frame}
>   \begin{itemize}
>   \item \textbf<1>{One}
>   \item \textbf<1>{Two}
>   \end{itemize}
> \end{frame}
> \end{document}
> ===========================
>
> When folded, this code is displayed as follows:
>
> ===========================
> \documentclass{beamer}
> \begin{document}
> \begin{frame}
>   \begin{itemize}
>   * [Error: No content found]<1>{One}
>   * [Error: No content found]<2>{Two}
>   \end{itemize}
> \end{frame}
> \end{document}
> ===========================
>
> Another example, which doesn't involve beamer, is the following code:
>
> ===========================
> \usepackage{titlesec}
> \titleformat{\section}{\bfseries}{\thesection}{10pt}{}[\normalfont]
> ===========================
>
> which displays as:
>
> ===========================
> \usepackage{titlesec}
> \titleformat{[Error: No content
> found]}{\bfseries}{\thesection}{10pt}{}[\normalfont]
> ===========================
>
> Maybe it would be an idea to just not fold things like this where no
> content it found, instead of displaying an error?

Thanks for the detailed report.  I tried at least to track down the
culprit for the beamer case, I think a general solution would be to
teach `TeX-find-macro-boundaries' and related functions about <...>
specifications.  Unfortunately, I don't have right now the time to fix
it, but this should be a starting point for anyone willing to tackle
this issue.  Regarding the second case, I don't think there is an easy
fix for it.

Bye,
Mosè