Subject: Re: bug#28405: Adding entries to LaTeX-indent-environment-list

From: Uwe Brauer <[email-masked]>
Date: Wed, 02 Feb 2022 11:48:41 +0100

>>> "AE" == Arash Esbati <[email-masked]> writes:
Hi Arash
> Uwe Brauer <[email-masked]> writes:
>> I am deeply puzzled now.
>> 
>> 1. I like Keita's patch because it results in filling with a much
>> better indenting.
>> 
>> 2. But, are you saying the price for this is that auto-filling is
>> disabled and I have to deal with very long equations myself? Why
>> is this so? I'd rather would like to have nice indentation and
>> auto-filling. Rational: more and more (No emacs) users use editor
>> that support virtual filling and that results in long equation.
>> It is true that virtual-auto-fill-mode (available in MELPA) is quite
>> good, but I still prefer good all breaks at 70 chars, and
>> therefore auto-fill-mode

> I'm not sure if we're talking about the same thing.  Docstring of
> `LaTeX-indent-environment-list' says:

> ,----[ C-h v LaTeX-indent-environment-list RET ]
> | LaTeX-indent-environment-list is a variable defined in ‘latex.el’.
> | 
> | Alist of environments with special indentation.
> | The second element in each entry is the function to calculate the
> | indentation level in columns.
> | 
> | Environments present in this list are not filled by filling
> | functions, see ‘LaTeX-fill-region-as-paragraph’.
> | 
> |   You can customize this variable.
> | 
> | Value:
> | (("verbatim" current-indentation)
> |  ("verbatim*" current-indentation)
> |  ("filecontents" current-indentation)
> |  ("filecontents*" current-indentation)
> |  ("tabular" LaTeX-indent-tabular)
> |  ("tabular*" LaTeX-indent-tabular)
> |  ("array" LaTeX-indent-tabular)
> |  ("eqnarray" LaTeX-indent-tabular)
> |  ("eqnarray*" LaTeX-indent-tabular)
> |  ("displaymath")
> |  ("equation")
> |  ("picture")
> |  ("tabbing"))
> `----

> and the one for `LaTeX-fill-region-as-paragraph' says:

> ,----[ C-h f LaTeX-fill-region-as-paragraph RET ]
> | LaTeX-fill-region-as-paragraph is an interactive native compiled Lisp
> | function in ‘latex.el’.
> | 
> | (LaTeX-fill-region-as-paragraph FROM TO &optional JUSTIFY-FLAG)
> | 
> | Fill region as one paragraph.
> | Break lines to fit ‘fill-column’, but leave all lines ending with
> | \\ (plus its optional argument) alone.  Lines with code
> | comments and lines ending with ‘\par’ are included in filling but
> | act as boundaries.  Prefix arg means justify too.  From program,
> | pass args FROM, TO and JUSTIFY-FLAG.
> | 
> | You can disable filling inside a specific environment by adding
> | it to ‘LaTeX-indent-environment-list’, only indentation is
> | performed in that case.
> | 
> `----

> Now take this small example:

>   \documentclass[a4paper]{article}
>   \begin{document}
>   \begin{equation}
>     a
>     a
>     a
>     a
>   \end{equation}
>   \end{document}
>   %%% Local Variables:
>   %%% mode: latex
>   %%% TeX-master: t
>   %%% End:

> Put the point inside the equation environment and hit 'M-q', nothing
> happens.  When you type in material, there is a line-wrapping at
> `fill-column', but that's all.

> So basically this is what happens with Keita's patch: line-wrapping will
> happen when you enter math, but hitting 'M-q' later is disabled.
> Hitting 'TAB' will adjust the indentation of a line, but there is no
> filling.  And there is a comment in `LaTeX-indent-environment-list':

Hm, here is a situation that you did not cover. I am not talking about
editing an equation, I am taking about filling a badly formatted equation

Suppose you have (or have a received) a file of that form

\documentclass[a4paper]{article}
\begin{document}
\begin{equation}
a = \left.\int very very long expression in one line\begin{array}
  a
  a
  a
\end{equation}
\end{document}

So the equation is badly indented and consist of very long lines.

So I basically want  LaTeX-fill-environment to indent the environment
correctly, and that thanks to the patch is no better, but I also want
long lines to be broken/wrapped

So far I have seen that I have to jump the end of long lines, press
space and the line is broken/wrapped, but this extra typing is not very
comfortable.

Did I explain this now better?

Regards

Uwe