GNU bug report logs - #76108
Call `modify_text' only on the text being replaced in `subst-char-in-region'

Previous Next

Package: emacs;

Reported by: Thuna <thuna.cing <at> gmail.com>

Date: Thu, 6 Feb 2025 23:42:01 UTC

Severity: normal

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thuna <thuna.cing <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Call `modify_text' only on the text being replaced in
 `subst-char-in-region'
Date: Fri, 07 Feb 2025 00:41:12 +0100
[Message part 1 (text/plain, inline)]
Currently `subst-char-in-region' calls `modify_text' on the entire text,
starting from the first match to the end of the text, which fires off
`before-change-functions' for (almost) every character in the region
it's called in.

The specific place where this caused a problem for me is while filling
paragraphs with latex fragments in org-mode.  Latex fragments are
overlays with the `modification-hooks' property set to delete the
overlay, so when a paragraph is filled, that calls
  (subst-char-in-region ?\n ?\s ...)
on the entire paragraph which then calls `modify_text' on the entire
paragraph (sans the first line), which causes all latex fragments to
disappear.

I'm assuming that there isn't any particular reason why `modify_text'
should be called on the whole paragraph, but if there is, then that's ok
too, I suppose.  I don't see any reason why this should be breaking
stuff, but I haven't actually checked.

[0001-Only-modify-the-text-being-replaced-in-subst-char-in.patch (text/x-patch, attachment)]

This bug report was last modified 125 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.