GNU bug report logs - #65648
13.2; indentation of nested environments

Previous Next

Package: auctex;

Reported by: Paul Nelson <ultrono <at> gmail.com>

Date: Thu, 31 Aug 2023 04:57:01 UTC

Severity: normal

Found in version 13.2

Done: Ikumi Keita <ikumi <at> ikumi.que.jp>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Uwe Brauer <oub <at> mat.ucm.es>, Paul Nelson <ultrono <at> gmail.com>
Cc: 65648 <at> debbugs.gnu.org
Subject: bug#65648: 13.2; indentation of nested environments
Date: Mon, 04 Sep 2023 16:47:12 +0900
[Message part 1 (text/plain, inline)]
Hi Uwe and Paul, thank you for your discussion.

>>>>> Paul Nelson <ultrono <at> 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 <at> 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

[tentative-patch (text/x-diff, attachment)]

This bug report was last modified 1 year and 254 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.