emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org.el (org-do-latex-and-related): Fix duplicate 'latex-and-related faces
@ 2021-03-19 16:56 Sébastien Miquel
  2021-03-25  4:26 ` Kyle Meyer
  0 siblings, 1 reply; 4+ messages in thread
From: Sébastien Miquel @ 2021-03-19 16:56 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 667 bytes --]

Hi,

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.

#+BEGIN_SRC org
Foo
  $a^2 + b^2 = c^2$
#+END_SRC

  - Use (setq org-highlight-latex-and-related '(latex))
  - Write some text at the end of the first line, triggering
    refonfication of the line
  - For each character inserted, the org-latex-and-related face is
    added (as a duplicate) to the fragment, as you can check using
    describe-text-properties.

The attached patch fixes this.

-- 
Sébastien Miquel


[-- Attachment #2: 0001-org.el-org-do-latex-and-related-Fix-duplicate-latex-.patch --]
[-- Type: text/x-patch, Size: 899 bytes --]

From ccce24e08b903e0e955a6b22f6c7321851ec5750 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miquel@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.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-27  6:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 16:56 [PATCH] org.el (org-do-latex-and-related): Fix duplicate 'latex-and-related faces Sébastien Miquel
2021-03-25  4:26 ` Kyle Meyer
2021-03-25  7:09   ` Sébastien Miquel
2021-03-27  6:07     ` Kyle Meyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).