Subject: Re: bug#48518: 13.0.11; LaTeX environment C-c C-e on region doesn't indent properly

From: Ikumi Keita <[email-masked]>
Date: Fri, 21 May 2021 17:26:58 +0900

Hi Berthold,

>>>>> Berthold Lorke <[email-masked]> writes:
> I don't see how "no indent" was requested by Florian.  All he wanted was
> no line wrapping of highlighted text after executing a latex-environment
> C-c C-e command.  Which I also do not want.  So there is nothing he
> suggested that I want changed.

Your argument is logical and convincing. ;-)

>> Maybe AUCTeX should do only indentation, not filling, when
>> `auto-fill-mode' is disabled. (I'm not sure what is the best behavior
>> because I always enable `auto-fill-mode'.)

> Yes!  This is exactly what I am requesting :)

Could you test the attached patch to see whether it works as expected?

Regards,
Ikumi Keita

diff --git a/latex.el b/latex.el
index 2e2d2098..abad7ecb 100644
--- a/latex.el
+++ b/latex.el
@@ -825,7 +825,9 @@ environment just inserted, the buffer position just before
           (or (assoc environment LaTeX-indent-environment-list)
               (if auto-fill-function
                   ;; Fill the region only when `auto-fill-mode' is active.
-                  (LaTeX-fill-region content-start (line-beginning-position 2))))
+                  (LaTeX-fill-region content-start (line-beginning-position 2))
+                ;; Else just indent the region. (bug#48518)
+                (indent-region content-start (line-beginning-position 2))))
           (set-mark content-start))
       (indent-according-to-mode))
     ;; Indent \end{foo}.