branch: externals/auctex
commit 163dcb75bd0b67e850b9e4c4f3ba2f2d310360a0
Author: Ikumi Keita <ik...@ikumi.que.jp>
Commit: Ikumi Keita <ik...@ikumi.que.jp>

    Fix label insertion at env. insertion with active region (bug#28382)
    
    * latex.el (LaTeX-env-label): Add management of positions of point and
    mark and indent region when region is active.
---
 latex.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/latex.el b/latex.el
index 27c865a420..bfd5b8c605 100644
--- a/latex.el
+++ b/latex.el
@@ -1274,9 +1274,18 @@ Just like array and tabular."
 (defun LaTeX-env-label (environment)
   "Insert ENVIRONMENT and prompt for label."
   (LaTeX-insert-environment environment)
+  (when (TeX-active-mark)
+    ;; Point is at the end of the region.  Move it back to the
+    ;; beginning of the region.
+    (exchange-point-and-mark)
+    (indent-according-to-mode))
   (when (LaTeX-label environment 'environment)
     (LaTeX-newline)
-    (indent-according-to-mode)))
+    (indent-according-to-mode))
+  (when (TeX-active-mark)
+    (indent-region (point) (mark))
+    ;; Restore the positions of point and mark.
+    (exchange-point-and-mark)))
 
 (defun LaTeX-env-list (environment)
   "Insert ENVIRONMENT and the first item."


_______________________________________________
auctex-diffs mailing list
auctex-di...@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-diffs

Reply via email to