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

From: Arash Esbati <[email-masked]>
Date: Tue, 01 Feb 2022 22:23:31 +0100

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':

 ;; The following should have their own, smart indentation function.
 ;; Some other day.
 ("displaymath")
 ("equation")
 ("picture")
 ("tabbing"))

Best, Arash