emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sébastien Miquel" <sebastien.miquel@posteo.eu>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org.el (org-do-latex-and-related): Fix duplicate 'latex-and-related faces
Date: Fri, 19 Mar 2021 17:56:54 +0100	[thread overview]
Message-ID: <580b0b82-798f-0b82-aaf7-67015aae1c6c@posteo.eu> (raw)

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


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.

  $a^2 + b^2 = c^2$

  - 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

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))
+           ((>= (match-beginning 0) limit)
+	    (throw 'found nil))
 	   ((cl-some (lambda (f)
 		       (memq f '(org-code org-verbatim underline

             reply	other threads:[~2021-03-19 16:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19 16:56 Sébastien Miquel [this message]
2021-03-25  4:26 ` [PATCH] org.el (org-do-latex-and-related): Fix duplicate 'latex-and-related faces Kyle Meyer
2021-03-25  7:09   ` Sébastien Miquel
2021-03-27  6:07     ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=580b0b82-798f-0b82-aaf7-67015aae1c6c@posteo.eu \
    --to=sebastien.miquel@posteo.eu \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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