auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] Changes to auctex/texmathp.el


From: Ralf Angeli
Subject: [AUCTeX-diffs] Changes to auctex/texmathp.el
Date: Sun, 02 Oct 2005 07:22:30 -0400

Index: auctex/texmathp.el
diff -u auctex/texmathp.el:5.16 auctex/texmathp.el:5.17
--- auctex/texmathp.el:5.16     Thu Sep 29 11:08:19 2005
+++ auctex/texmathp.el  Sun Oct  2 11:22:30 2005
@@ -316,17 +316,42 @@
   (catch 'exit
     (save-excursion
       (and (null texmathp-environments) (throw 'exit nil))
-      (let (end-list env)
+      ;; Check if the line we are starting with is a commented one.
+      (let ((orig-comment-flag
+            ;; Could be replaced by `TeX-in-commented-line'.
+            (progn
+              (save-excursion
+                (beginning-of-line)
+                (skip-chars-forward " \t")
+                (string= (buffer-substring-no-properties
+                          (point) (min (point-max)
+                                       (+ (point) (length comment-start))))
+                         comment-start))))
+           end-list env)
        (while (re-search-backward "\\\\\\(begin\\|end\\)[ \t]*{\\([^}]+\\)}"
                                   bound t)
-         (setq env (buffer-substring-no-properties
-                    (match-beginning 2) (match-end 2)))
-         (cond ((string= (match-string 1) "end")
-                (setq end-list (cons env end-list)))
-               ((equal env (car end-list))
-                (setq end-list (cdr end-list)))
-               ((member env texmathp-environments)
-                (throw 'exit (cons env (point))))))
+         ;; Check if the match found is inside of a comment.
+         (let ((current-comment-flag
+                ;; Could be replaced by `TeX-in-comment'.
+                (when (save-match-data
+                        (re-search-backward comment-start-skip
+                                            (line-beginning-position) t))
+                  ;; We need a t for comparison with `orig-comment-flag',
+                  ;; not a number.
+                  t)))
+           ;; Only consider matching alternatives with respect to
+           ;; "in-commentness", i.e. if we started with a comment
+           ;; only consider matches which are in comments as well and
+           ;; vice versa.
+           (when (eq orig-comment-flag current-comment-flag)
+             (setq env (buffer-substring-no-properties
+                        (match-beginning 2) (match-end 2)))
+             (cond ((string= (match-string 1) "end")
+                    (setq end-list (cons env end-list)))
+                   ((equal env (car end-list))
+                    (setq end-list (cdr end-list)))
+                   ((member env texmathp-environments)
+                    (throw 'exit (cons env (point))))))))
        nil))))
 
 (defun texmathp-match-macro (bound)




reply via email to

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