emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sébastien Miquel" <sebastien.miquel@posteo.eu>
To: Kyle Meyer <kyle@kyleam.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org.el (org-do-latex-and-related): Fix duplicate 'latex-and-related faces
Date: Thu, 25 Mar 2021 08:09:40 +0100	[thread overview]
Message-ID: <7447ad40-4711-bd04-79d8-0a5bad199938@posteo.eu> (raw)
In-Reply-To: <87czvnuacs.fsf@kyleam.com>

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

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


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

From 7fb4e2d408791742281bf220d227ccdcfd5baa71 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.31.0


  reply	other threads:[~2021-03-25  7:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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=7447ad40-4711-bd04-79d8-0a5bad199938@posteo.eu \
    --to=sebastien.miquel@posteo.eu \
    --cc=emacs-orgmode@gnu.org \
    --cc=kyle@kyleam.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

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