diff options
| author | Lars Ingebrigtsen | 2021-08-15 15:43:35 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-08-15 15:43:39 +0200 |
| commit | 2a022e9be3a1f46dde2fa230d0b31fb6fbb5d66a (patch) | |
| tree | 5e09e628893263ff2b9aa397e75c4b2032dc2093 /lisp | |
| parent | ab23fa4eb22f6557414724769958a63f1c59b49a (diff) | |
| download | emacs-2a022e9be3a1f46dde2fa230d0b31fb6fbb5d66a.tar.gz emacs-2a022e9be3a1f46dde2fa230d0b31fb6fbb5d66a.zip | |
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')
| -rw-r--r-- | lisp/nxml/nxml-mode.el | 14 |
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 | |||
| 540 | (nxml-scan-prolog))))) | 540 | (nxml-scan-prolog))))) |
| 541 | (setq-local syntax-ppss-table sgml-tag-syntax-table) | 541 | (setq-local syntax-ppss-table sgml-tag-syntax-table) |
| 542 | (setq-local syntax-propertize-function #'nxml-syntax-propertize) | 542 | (setq-local syntax-propertize-function #'nxml-syntax-propertize) |
| 543 | (setq-local filter-buffer-substring-function #'nxml--buffer-substring-filter) | ||
| 543 | (add-hook 'change-major-mode-hook #'nxml-cleanup nil t) | 544 | (add-hook 'change-major-mode-hook #'nxml-cleanup nil t) |
| 544 | 545 | ||
| 545 | (when (not (and (buffer-file-name) (file-exists-p (buffer-file-name)))) | 546 | (when (not (and (buffer-file-name) (file-exists-p (buffer-file-name)))) |
| @@ -564,6 +565,19 @@ Many aspects this mode can be customized using | |||
| 564 | 565 | ||
| 565 | (with-demoted-errors (rng-nxml-mode-init))) | 566 | (with-demoted-errors (rng-nxml-mode-init))) |
| 566 | 567 | ||
| 568 | (defun nxml--buffer-substring-filter (beg end &optional delete) | ||
| 569 | (let ((string (buffer-substring--filter beg end delete))) | ||
| 570 | ;; The `rng-state' property is huge, so don't copy it to the kill | ||
| 571 | ;; ring. This avoids problems when saving the kill ring with | ||
| 572 | ;; savehist. | ||
| 573 | (when (seq-find (lambda (elem) | ||
| 574 | (plist-get (nth 2 elem) 'rng-state)) | ||
| 575 | (object-intervals string)) | ||
| 576 | (remove-text-properties 0 (length string) | ||
| 577 | '(rng-state nil fontified nil) | ||
| 578 | string)) | ||
| 579 | string)) | ||
| 580 | |||
| 567 | (defun nxml-cleanup () | 581 | (defun nxml-cleanup () |
| 568 | "Clean up after nxml-mode." | 582 | "Clean up after nxml-mode." |
| 569 | ;; Disable associated minor modes. | 583 | ;; Disable associated minor modes. |