bug-auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65648: 13.2; indentation of nested environments


From: Ikumi Keita
Subject: bug#65648: 13.2; indentation of nested environments
Date: Mon, 04 Sep 2023 16:47:12 +0900

Hi Uwe and Paul, thank you for your discussion.

>>>>> Paul Nelson <ultrono@gmail.com> writes:
> There's no important difference here between indent-region and the
> LaTeX fill commands -- unless I'm mistakaen, they all ultimately call
> LaTeX-indent-line, one line at a time.

That's right. The doc strings of `LaTeX-fill-region',
`LaTeX-fill-environment', `LaTeX-fill-section' and `LaTeX-fill-buffer'
say "Fill and indent ...".

> Let's put three of those examples in a row and format them according
> to current AUCTeX and my proposal.

[...]

> The current AUCTeX indentation here is obviously broken;

Indeed :-(

>>>>> Uwe Brauer <oub@mat.ucm.es> writes:
> To summarise, you convinced me, sigh. 
> Not sure what the others think.

OK, I don't object.

>>> What's about a new variable then.
>>> 
>>> (defvar LaTeX-fill-sloppy t
>>> "When t, Paul's proposal, when nil, Uwe's proposal, that is the old 
>>> behavior")
>>> 
>>> Or does this make the code more difficult to maintain?

>> It seems possible to fine-tune the indentation code to give the
>> "optimum", at the cost of making that code slightly less efficient due
>> to additional checks for matching \begin's.  I think that if any "new
>> variable" should be given, then its purpose should be to determine
>> whether to give such a fine-tuning, and not whether to fix the noted
>> "obviously broken" behavior.

> I think the maintainers should decide that. I am in favor of such a
> variable, however I don't know enough of the code to really judge it.

I tried to implement the idea of such customize option as
`LaTeX-indent-always-align-end-with-begin'. See the attached patch.

When this option is non-nil, the "optimum" indentation
\begin{equation}
  n u m=\left[\begin{array}{ll}
                2 & 25
              \end{array}\right]
\end{equation}
is obtained while
Let $E = \begin{bmatrix}
           1 & 0\\
           0 & 1
         \end{bmatrix}$ be the
         identity matrix.
is formatted badly.

When the option is nil, Paul's proposal takes effect so
\begin{equation}
  n u m=\left[\begin{array}{ll}
                2 & 25
  \end{array}\right]
\end{equation}
and
Let $E = \begin{bmatrix}
           1 & 0\\
           0 & 1
\end{bmatrix}$ be the
identity matrix.
are obtained.

This is only a tentative patch. Comments are welcome.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine

Attachment: tentative-patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]