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.
This commit is contained in:
Carsten Dominik 2009-08-11 16:32:05 +02:00
parent 1d18043506
commit 5834ad01b6
2 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,7 @@
2009-08-11 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-format-latex): Avoid nested overlays.
* org-latex.el (org-export-latex-listings-langs): Add a few more
languages.

View File

@ -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)