auctex-diffs
[Top][All Lists]
Advanced

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

master 3e8aa71e: Fix bug#58689 with a bit of optiomization


From: Ikumi Keita
Subject: master 3e8aa71e: Fix bug#58689 with a bit of optiomization
Date: Thu, 8 Dec 2022 00:36:06 -0500 (EST)

branch: master
commit 3e8aa71ef28ad05bd32bedf18bbeb4d8cd35c069
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Commit: Ikumi Keita <ikumi@ikumi.que.jp>

    Fix bug#58689 with a bit of optiomization
    
    * latex.el (LaTeX-modify-environment): Comment out redundant
    `beginning-of-line' and `end-of-line'.
---
 latex.el | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/latex.el b/latex.el
index 69924b21..04caaf53 100644
--- a/latex.el
+++ b/latex.el
@@ -871,30 +871,32 @@ position just before \\begin and the position just before
                                                 (LaTeX-environment-name-regexp)
                                                 "\\)"
                                                 (regexp-quote TeX-grcl))
-                                        (save-excursion (beginning-of-line 1) 
(point)))))
+                                        (line-beginning-position))))
         (goto-begin (lambda ()
                       (LaTeX-find-matching-begin)
                       (prog1 (point)
                         (re-search-forward (concat (regexp-quote TeX-esc)
                                                    "begin"
                                                    (regexp-quote TeX-grop)
-                                                   "\\("
+                                                   "\\(?:"
                                                    
(LaTeX-environment-name-regexp)
                                                    "\\)"
                                                    (regexp-quote TeX-grcl))
-                                           (save-excursion (end-of-line 1) 
(point)))))))
+                                           (line-end-position))))))
     (save-excursion
       (funcall goto-end)
-      (let ((old-env (match-string 1)))
+      (let ((old-env (match-string-no-properties 1))
+            beg-pos)
         (replace-match environment t t nil 1)
-        (beginning-of-line 1)
-        (funcall goto-begin)
+        ;; This failed when \begin and \end lie on the same line. (bug#58689)
+        ;; (beginning-of-line 1)
+        (setq beg-pos (funcall goto-begin))
         (replace-match environment t t nil 1)
-        (end-of-line 1)
+        ;; (end-of-line 1)
         (run-hook-with-args 'LaTeX-after-modify-env-hook
                             environment old-env
-                            (save-excursion (funcall goto-begin))
-                            (progn (funcall goto-end) (point)))))))
+                            beg-pos
+                            (funcall goto-end))))))
 
 (defvar LaTeX-syntactic-comments) ;; Defined further below.
 



reply via email to

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