I believe I have found a bug in LaTeX-current-environment which reads:

(defun LaTeX-current-environment (&optional arg)
  (setq arg (if arg (if (< arg 1) 1 arg) 1))
  (let* ((in-comment (TeX-in-commented-line))
         (comment-prefix (and in-comment (TeX-comment-prefix))))
    (save-excursion
      (while (and (/= arg 0)
                  (re-search-backward
                   "\\\\\\(begin\\|end\\) *{ *\\([A-Za-z*]+\\) *}" nil t))
        (when (or [omitted]
                  (and (not LaTeX-syntactic-comments)
*here* ->              (not (TeX-in-commented-line))))
(setq arg (if (string= (match-string 1) "end") (1+ arg) (1- arg)))))
      (if (/= arg 0)
          "document"
        (match-string-no-properties 2)))))

The problem is that when LaTeX-syntactic-comments is nil (TeX-in-commented-line) only recognizes comment-only lines as comments. Its seems that one should really just check to see the point is inside a comment, even if there are noncomment code on the
same line.  For example, when the function encounters the LaTeX code

b %&= \begin{bmatrix}
  %     1 \\ 2
  %   \end{bmatrix}
  &= (1,2)

it ignores the "\end{bmatrix}" because the comment is on a line by itself but counts the "\begin{bmatrix}" and everything is screwed up from that point on.

Best regards,
Gerard


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

Reply via email to