diff options
Diffstat (limited to 'lisp/nxml/nxml-mode.el')
-rw-r--r-- | lisp/nxml/nxml-mode.el | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el index 0602943db20..405f803325c 100644 --- a/lisp/nxml/nxml-mode.el +++ b/lisp/nxml/nxml-mode.el @@ -540,13 +540,15 @@ 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) + (add-function :filter-return (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)))) (when (and nxml-default-buffer-file-coding-system (not (local-variable-p 'buffer-file-coding-system))) (setq buffer-file-coding-system nxml-default-buffer-file-coding-system)) - ;; When starting a new file, insert the XML declaraction. + ;; When starting a new file, insert the XML declaration. (when (and nxml-auto-insert-xml-declaration-flag (zerop (buffer-size))) (nxml-insert-xml-declaration))) @@ -564,6 +566,15 @@ Many aspects this mode can be customized using (with-demoted-errors (rng-nxml-mode-init))) +(defun nxml--buffer-substring-filter (string) + ;; 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) string)) + string) + (defun nxml-cleanup () "Clean up after nxml-mode." ;; Disable associated minor modes. |