auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] Changes to auctex/latex.el,v


From: Ralf Angeli
Subject: [AUCTeX-diffs] Changes to auctex/latex.el,v
Date: Sat, 19 Jul 2008 17:09:14 +0000

CVSROOT:        /cvsroot/auctex
Module name:    auctex
Changes by:     Ralf Angeli <angeli>    08/07/19 17:09:13

Index: latex.el
===================================================================
RCS file: /cvsroot/auctex/auctex/latex.el,v
retrieving revision 5.446
retrieving revision 5.447
diff -u -b -r5.446 -r5.447
--- latex.el    19 Jul 2008 16:29:27 -0000      5.446
+++ latex.el    19 Jul 2008 17:09:13 -0000      5.447
@@ -3346,22 +3346,23 @@
 
 (defun LaTeX-mark-environment (&optional count)
   "Set mark to end of current environment and point to the matching begin.
-If passed a prefix argument COUNT, mark the outer environnment by COUNT levels.
-Example: if point is --!-- and COUNT=2, env1 is the marked environment.
-
-    \\begin{env1} \\begin{env2} --!-- \\begin{env2} \\begin{env1}
-
-Will not work properly if there are unbalanced begin-end pairs in
-comments and verbatim environments"
+If prefix argument COUNT is given, mark the respective number of
+enclosing environments.  The command will not work properly if
+there are unbalanced begin-end pairs in comments and verbatim
+environments."
   (interactive "p")
-  (unless count (seq count 1))
-  (let ( (cur (point)))
-    (unless (> count 0) (error "invalid prefix arg, expects a positive 
number"))
+  (setq count (if count (abs count) 1))
+  (let ((cur (point)) beg end)
+    ;; Only change point and mark after beginning and end were found.
+    ;; Point should not end up in the middle of nowhere if the search fails.
+    (save-excursion
     (dotimes (c count) (LaTeX-find-matching-end))
-    (beginning-of-line 2)
-    (set-mark (point))
+      (setq beg (line-beginning-position 2))
     (goto-char cur)
     (dotimes (c count) (LaTeX-find-matching-begin))
+      (setq end (point)))
+    (set-mark end)
+    (goto-char beg)
     (TeX-activate-region)))
 
 (defun LaTeX-fill-environment (justify)




reply via email to

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