Sébastien Miquel writes: > With the current org-do-latex-and-related function, fontification of > a region before a LaTeX fragment repeatedly adds the > 'org-latex-and-related face to the fragment. > > You can reproduce with an org buffer with the following content. [...] > The attached patch fixes this.
Thanks for the clear reproduction steps and for the patch. > Subject: [PATCH] org.el (org-do-latex-and-related): Fix duplicate 'latex faces > > * lisp/org.el (org-do-latex-and-related): Do not add a > 'org-latex-and-related face beyond the fontification limit Please add a period after the changelog entry. https://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html > --- > lisp/org.el | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/lisp/org.el b/lisp/org.el > index 4db2dbe04..a0c703630 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -5502,6 +5502,8 @@ highlighting was done, nil otherwise." > (while (and (< (point) limit) > (re-search-forward org-latex-and-related-regexp nil t)) > (cond > + ((>= (match-beginning 0) limit) > + (throw 'found nil)) Any reason not to pass limit as re-search-forward's BOUND instead?