Subject: bug#74009: 14.0.6.2024-10-22_10:04:26; LaTeX-fill-environment does strange things when % is present

From: Uwe Brauer <[email-masked]>
Date: Tue, 29 Oct 2024 18:33:41 +0100

>>> "AE" == Arash Esbati <[email-masked]> writes:

> Uwe Brauer via bug-auctex via Bug reporting list for AUCTeX <[email-masked]> writes:
>> running LaTeX-fill-environment results in 
>> formatting environment 41% I have to interrupt with C-g and obtain
>> 
>> \begin{definition}[homotopy relation on
>> 1-simplices]\label{defn:1-simplex-htpy}
>> \uses{defn:simplicial-set} A parallel pair of 1-sim\-plices $f,g$ in
>> a simplicial set $X$ are \textbf{homotopic} if there exists a
>> 2-simplex whose boundary takes either of the following
>> forms\footnote{The symbol ``$=$'' is used in diagrams to denote a
>> degenerate simplex or an identity arrow.}
>> % \footnote{The symbol
>> [...]
>> % ``$\!\!\!\!\!\begin{tikzcd}[ampersand replacement=\&, sep=small] ~\arrow[r, equals] \& ~ \end{tikzcd}\!\!\!\!\!$'' is used in diagrams to denote a degenerate simplex or an identity arrow.}
>> \begin{center}
>> \begin{tikzcd}[row sep=small, column sep=small]
>> & y \arrow[dr, equals] & && &  x \arrow[dr, "f"]  \\ x \arrow[ur, "f"] \arrow[rr, "g"'] & & y & & x \arrow[ur, equals] \arrow[rr, "g"'] & & y
>> \end{tikzcd}
>> \end{center}
>> or if $f$ and $g$ are in the same equivalence class generated by this relation.
>> \end{definition}
>> 
>> It could have been much longer because I think emacs entered a infinite
>> loop.
>> 
>> Any ideas?

> I didn't look closely, but slightly re-writting the code like this:

> \begin{definition}[homotopy relation on 1-simplices]\label{defn:1-simplex-htpy}
>   \uses{defn:simplicial-set} A parallel pair of 1-sim\-plices $f,g$ in a simplicial set $X$ are \textbf{homotopic} if there exists a 2-simplex whose boundary takes either of the following forms\footnote{The symbol ``$=$'' is used in diagrams to denote a degenerate simplex or an identity arrow.}
>    % \footnote{%
>    % The symbol ``$\!\!\!\!\!%
>    % \begin{tikzcd}[ampersand replacement=\&, sep=small]
>    %   ~\arrow[r, equals] \& ~
>    % \end{tikzcd}%
>    % \!\!\!\!\!$'' is used in diagrams to denote a degenerate simplex or an identity arrow.}
>    \begin{center}
>    \begin{tikzcd}[row sep=small, column sep=small]
>    & y \arrow[dr, equals] & && &  x \arrow[dr, "f"]  \\ x \arrow[ur, "f"] \arrow[rr, "g"'] & & y & & x \arrow[ur, equals] \arrow[rr, "g"'] & & y
>    \end{tikzcd}
>   \end{center}
>    or if $f$ and $g$ are in the same equivalence class generated by this relation.
> \end{definition}

> and running `LaTeX-fill-environment' on this gives:

> \begin{definition}[homotopy relation on
>     1-simplices]\label{defn:1-simplex-htpy}
>   \uses{defn:simplicial-set} A parallel pair of 1-sim\-plices $f,g$ in
>   a simplicial set $X$ are \textbf{homotopic} if there exists a
>   2-simplex whose boundary takes either of the following
>   forms\footnote{The symbol ``$=$'' is used in diagrams to denote a
>     degenerate simplex or an identity arrow.}
>   % \footnote{% The symbol ``$\!\!\!\!\!%
>   % \begin{tikzcd}[ampersand replacement=\&, sep=small]
>   %   ~\arrow[r, equals] \& ~
>   % \end{tikzcd}%
>   % \!\!\!\!\!$'' is used in diagrams to denote a degenerate simplex
>   % or an identity arrow.}
>   \begin{center}
>     \begin{tikzcd}[row sep=small, column sep=small]
>       & y \arrow[dr, equals] & && & x \arrow[dr, "f"] \\ x \arrow[ur,
>         "f"] \arrow[rr, "g"'] & & y & & x \arrow[ur, equals]
>       \arrow[rr, "g"'] & & y
>     \end{tikzcd}
>   \end{center}
>   or if $f$ and $g$ are in the same equivalence class generated by
>   this relation.
> \end{definition}

> So I suspect it has something to do with the placement of
> \begin/\end{tikzcd} in the comment.

Hi Arash

First thanks for looking into this

Two comments

    1. Confirmed, you are right, but

    2. I receive lately a lot of latex files, with very very long lines
       (it seems that a lot of latex editor now support soft line
       wrapping), emacs still struggles I use virtual-auto-fill-mode
       from time to time but it is inferior than running auctex latex
       fill commands. So mostly I run LaTeX-fill-section on those files,
       and as this example indicates this can result in a sort of
       catastrophe since emacs becomes idle but is then silently filling
       the buffer with these
       %
       %
       lines.

    3. This is why I sent this report. It might be helpful if emacs
       would just abort the filling process with an error message, but I
       am not sure how this could be implemented

Regards

Uwe 

-- 
I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the EU and NATO membership of Ukraine.