diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 33b123678..a7c546c1b 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -3,6 +3,8 @@ * org-latex.el (org-export-latex-quotation-marks): Fix export of quotation makrs in parenthesis. (org-remove-initial-hash): New function. + (org-export-latex-preprocess): Fix bug with infinite loop if + environment is not properly closed. * org-table.el (org-table-get-remote-range): Find #+TBLNAME also when indented. diff --git a/lisp/org-latex.el b/lisp/org-latex.el index 394208347..dbdad7004 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -1542,13 +1542,14 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." (goto-char (point-min)) (while (re-search-forward "^[ \t]*\\\\begin{\\([a-zA-Z]+\\*?\\)}" nil t) (let* ((start (progn (beginning-of-line) (point))) - (end (or (and (re-search-forward - (concat "^[ \t]*\\\\end{" - (regexp-quote (match-string 1)) - "}") nil t) - (point-at-eol)) - (point-max)))) - (add-text-properties start end '(org-protected t)))) + (end (and (re-search-forward + (concat "^[ \t]*\\\\end{" + (regexp-quote (match-string 1)) + "}") nil t) + (point-at-eol)))) + (if end + (add-text-properties start end '(org-protected t)) + (goto-char (point-at-eol)))))) ;; Preserve math snippets