summaryrefslogtreecommitdiff
path: root/lisp/nxml/nxml-mode.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-08-15 15:43:35 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-08-15 15:43:39 +0200
commit2a022e9be3a1f46dde2fa230d0b31fb6fbb5d66a (patch)
tree5e09e628893263ff2b9aa397e75c4b2032dc2093 /lisp/nxml/nxml-mode.el
parentab23fa4eb22f6557414724769958a63f1c59b49a (diff)
downloademacs-2a022e9be3a1f46dde2fa230d0b31fb6fbb5d66a.tar.gz
Filter out rng-state elements in nxml-mode buffers from the kill ring
* lisp/nxml/nxml-mode.el (nxml--buffer-substring-filter): Filter out `rng-state' objects (bug#50061). (nxml-mode): Set `filter-buffer-substring-function'.
Diffstat (limited to 'lisp/nxml/nxml-mode.el')
-rw-r--r--lisp/nxml/nxml-mode.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index 1bc905cee2d..5a3499dd165 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el
@@ -540,6 +540,7 @@ Many aspects this mode can be customized using
(nxml-scan-prolog)))))
(setq-local syntax-ppss-table sgml-tag-syntax-table)
(setq-local syntax-propertize-function #'nxml-syntax-propertize)
+ (setq-local filter-buffer-substring-function #'nxml--buffer-substring-filter)
(add-hook 'change-major-mode-hook #'nxml-cleanup nil t)
(when (not (and (buffer-file-name) (file-exists-p (buffer-file-name))))
@@ -564,6 +565,19 @@ Many aspects this mode can be customized using
(with-demoted-errors (rng-nxml-mode-init)))
+(defun nxml--buffer-substring-filter (beg end &optional delete)
+ (let ((string (buffer-substring--filter beg end delete)))
+ ;; The `rng-state' property is huge, so don't copy it to the kill
+ ;; ring. This avoids problems when saving the kill ring with
+ ;; savehist.
+ (when (seq-find (lambda (elem)
+ (plist-get (nth 2 elem) 'rng-state))
+ (object-intervals string))
+ (remove-text-properties 0 (length string)
+ '(rng-state nil fontified nil)
+ string))
+ string))
+
(defun nxml-cleanup ()
"Clean up after nxml-mode."
;; Disable associated minor modes.