auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] [elpa] externals/auctex 163dcb75bd 02/60: Fix label inser


From: Tassilo Horn
Subject: [AUCTeX-diffs] [elpa] externals/auctex 163dcb75bd 02/60: Fix label insertion at env. insertion with active region (bug#28382)
Date: Fri, 8 Apr 2022 11:52:45 -0400 (EDT)

branch: externals/auctex
commit 163dcb75bd0b67e850b9e4c4f3ba2f2d310360a0
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Commit: Ikumi Keita <ikumi@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."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]