Subject: bug#54949: bug54949

From: Ikumi Keita <[email-masked]>
Date: Sun, 17 Apr 2022 20:11:28 +0900

Hi Robert,

Thanks for your comments, I understand what you expect: "AUCTeX should
be smart enough about indentation." :-)

However, it is very difficult to find out the "correct" indentation in
all cases. Thus AUCTeX actually uses only limited set of heuristics. In
particular, it assumes that there are only whitespaces between
\begin{xxx} and its beginning of line; this avoids that the amount of
computation of indentation goes beyond practical degree of complexity.

>>>>> Robert Morelli <[email-masked]> writes:
> 2. It is quite unexpected that indentation for an environment persists
> to the end of the file, even after the environment has ended. This
> seems to break the expectation that indentation reflects the
> compositional structure of a document.

Yeah. But it would be rather inefficient to re-calculate the indent
every time that an environment ends, which needs to find out the
corresponding \begin{xxx} skipping back over all potential inner nested
\begin-\end pairs, especially when indenting region with wide span.
(...but I began to feel that that idea isn't much bad. Maybe I try to
implement such behavior when I have spare time.)

> 1. It is common to use matrix environments in mathematical writing
> inline, rather than displayed.

Well, it isn't the matter of inline v.s. displayed style. LaTeX typesets
the following inline math expression without any problems:
----------------------------------------------------------------------
Let $E =
\begin{bmatrix}
  1 & 0\\
  0 & 1
\end{bmatrix}
$ be the identity matrix.
----------------------------------------------------------------------
Hence I expect you won't suffer from the heuristics that \begin{xxx}
stands on its own dedicated line as long as you enter environments by
C-c C-e in AUCTeX, because C-c C-e always put \begin{xxx} and \end{xxx}
on their own dedicated lines (except possible comment prefix).

If I understand correctly, this issue is only problematic for users who
frequently receive LaTeX documents written by other persons and compose
those into one large document, adapting the components accordingly. I
suppose you are in such a position, perhaps an editor of proceedings of
some math conferences?

Actually, reports about similar shortcoming in AUCTeX recurred recently:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28405#41
https://lists.gnu.org/r/auctex-devel/2022-02/msg00014.html
We haven't come up with a satisfactory solution for manuscripts which
don't conform to AUCTeX heuristics with respect to indentation.

> 3. Asking an end user to modify a variable like
> LaTeX-indent-environment-list puts an unwanted burden on the user.
> There are potentially many ways to remove an element from a list. One
> way is through the customization interface. Like many Emacs users, I
> avoid the customization interface because I find it awkward to us,

Sorry, what I had in mind was that awkward method. It's really awkward
since the default value contains dozens of matrix-like environments.
Currently I don't have good idea what to do about that tediousness. :-(

> 6. Like most people, I'm very busy. I don't have time to create a mini
> project out of investigating how to modify a single variable in a
> single one of the 100+ packages I use in my text editor, which is one
> of dozens of programs I use on my computer, which is only a part of my
> life. In the big scheme of things, it would be foolish of me to spend
> more time on LaTeX-indent-environment-list, so the simplest solution
> for me is probably to regress AUCTeX, if I can do that easily.

> 5. If I modify the variable in my init file, I potentially lose future
> improvements to AUCTeX's indentation algorithms.

Then you are expecting to have improvements to AUCTeX. The update in
`LaTeX-indent-environment-list' is one of such improvements, which
aligns "&" sign vertically in suitable environments. So your
inconvenience is someone's benefit. It's inevitable to have sometimes
such unfortunate conflicts as long as you are expecting to experience
improvements to AUCTeX.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine