Kyle Meyer writes:

> Please add a period after the changelog entry.

Done.

> Any reason not to pass limit as re-search-forward's BOUND instead?

I've looked at the history of this code, and some earlier comment
indicated that limit was ignored on purpose.

The only case where it'd make a difference with my patch is when limit
is in the middle of a latex fragment (since re-search-forward's BOUND
bounds the end of the match).

Now, AFAIU, this should almost never happen, since the fontified
region is extended
 + according to the font-lock-multiline text property, that latex
   fragment do have
 + and to contain matching begin/end delimiters.

I can think of a few edge cases where it may make a difference :
 - If you write a multiline fragment, and add $ delimiters
   afterwards, starting with the closing one. Then when you add the
   opening one, you wouldn't get fontification, I think
 - If you add an empty line in a multiline $ fragment by mistake, which
   breaks fontification, then remove it

--
Sébastien Miquel

>From 7fb4e2d408791742281bf220d227ccdcfd5baa71 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miq...@posteo.eu>
Date: Fri, 19 Mar 2021 16:55:27 +0100
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.
---
 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))
 	   ((cl-some (lambda (f)
 		       (memq f '(org-code org-verbatim underline
 					  org-special-keyword)))
-- 
2.31.0

Reply via email to