From 5834ad01b617430c0207627ad425758bcf9b921a Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 11 Aug 2009 16:32:05 +0200 Subject: [PATCH] LaTeX snippets: Avoid Overlap It is possible that the regular expressions for LaTeX snippets match at nested locations. For example, Nick Dokos submitted this: ,---- | #+LaTeX_HEADER: \usepackage{amsmath} | | * foo | | \[ | \begin{matrix} | 1&d\\ | d&d\\ | \end{matrix} | \] | `---- where the snippet regexps match at \[ ... \] and also at \\begin{matrix}. This would lead to two nested overlays being placed. With this commit, only the outer one will remain. --- lisp/ChangeLog | 2 ++ lisp/org.el | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cd882a843..ae6b1333d 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,7 @@ 2009-08-11 Carsten Dominik + * org.el (org-format-latex): Avoid nested overlays. + * org-latex.el (org-export-latex-listings-langs): Add a few more languages. diff --git a/lisp/org.el b/lisp/org.el index 639da00e1..6a37acd2d 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -13902,7 +13902,11 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]." (while (re-search-forward re nil t) (when (and (or (not at) (equal (cdr at) (match-beginning n))) (not (get-text-property (match-beginning n) - 'org-protected))) + 'org-protected)) + (or (not overlays) + (not (eq (get-char-property (match-beginning n) + 'org-overlay-type) + 'org-latex-overlay)))) (setq txt (match-string n) beg (match-beginning n) end (match-end n) cnt (1+ cnt) @@ -13926,7 +13930,13 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]." txt movefile opt forbuffer) (if overlays (progn + (mapc (lambda (o) + (if (eq (org-overlay-get o 'org-overlay-type) + 'org-latex-overlay) + (org-delete-overlay o))) + (org-overlays-in beg end)) (setq ov (org-make-overlay beg end)) + (org-overlay-put ov 'org-overlay-type 'org-latex-overlay) (if (featurep 'xemacs) (progn (org-overlay-put ov 'invisible t)