all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#75224: RNG validation unnecessarily marks buffer as changed
@ 2024-12-31 12:31 Vili Aapro
  0 siblings, 0 replies; only message in thread
From: Vili Aapro @ 2024-12-31 12:31 UTC (permalink / raw)
  To: 75224

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

Gentle people,

I found a bug in RNG Validation mode in the file `nxml/rng-valid.el' that unnecessarily marks buffer as changed.  The bug can be fixed with a simple application of `with-silent-modifications' in the function `rng-do-some-validation-1'.  I've attached a patch that does so.  However, in the long run, in my opinion the application of `with-silent-modifications' should be moved to `rng-clear-cached-state'; that is where it properly belongs.  Perhaps this has been left undone because of efficiency reasons; perhaps there is work to be done to make `with-silent-modifications' less expensive.

To reproduce, visit a big enough RNG-validatable XML file, such as the included `rdfxml.rng'; goto and end-tag, say on line 22; kill it; undo.

Undo runs `after-change-functions' and thus `rng-after-change-function' and thus `rng-do-some-validation-1', reproducing the bug.

Best regards and thank you,
Vili Aapro


[-- Attachment #2: 0001-Fix-bug-in-rng-valid-that-unnecessarily-marks-buffer.patch --]
[-- Type: text/x-patch, Size: 889 bytes --]

From b5f7706165cfd2ef2c865303fe4530699d33d41b Mon Sep 17 00:00:00 2001
From: viliaapro <vili.aapro@iki.fi>
Date: Tue, 31 Dec 2024 14:07:43 +0200
Subject: [PATCH] Fix bug in rng-valid that unnecessarily marks buffer as
 changed

---
 lisp/nxml/rng-valid.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/nxml/rng-valid.el b/lisp/nxml/rng-valid.el
index 9a44356835e..b533545c52c 100644
--- a/lisp/nxml/rng-valid.el
+++ b/lisp/nxml/rng-valid.el
@@ -545,7 +545,8 @@ rng-do-some-validation-1
 	      ((or (>= pos next-cache-point)
 		   (not continue))
 	       (setq next-cache-point (+ pos rng-state-cache-distance))
-	       (rng-clear-cached-state remove-start pos)
+	       (with-silent-modifications
+		 (rng-clear-cached-state remove-start pos))
 	       (when have-remaining-chars
 		 (rng-cache-state (1- pos)))
 	       (setq remove-start pos)
-- 
2.34.1


[-- Attachment #3: rdfxml.rng --]
[-- Type: application/xml, Size: 12775 bytes --]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-12-31 12:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-31 12:31 bug#75224: RNG validation unnecessarily marks buffer as changed Vili Aapro

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.