summaryrefslogtreecommitdiff
path: root/lisp/nxml/nxml-mode.el
diff options
context:
space:
mode:
authorYuuki Harano <masm+github@masm11.me>2021-11-11 00:39:53 +0900
committerYuuki Harano <masm+github@masm11.me>2021-11-11 00:39:53 +0900
commit4dd1f56f29fc598a8339a345c2f8945250600602 (patch)
treeaf341efedffe027e533b1bcc0dbf270532e48285 /lisp/nxml/nxml-mode.el
parent4c49ec7f865bdad1629d2f125f71f4e506b258f2 (diff)
parent810fa21d26453f898de9747ece7205dfe6de9d08 (diff)
downloademacs-4dd1f56f29fc598a8339a345c2f8945250600602.tar.gz
emacs-4dd1f56f29fc598a8339a345c2f8945250600602.tar.bz2
emacs-4dd1f56f29fc598a8339a345c2f8945250600602.zip
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs into feature/pgtk
Diffstat (limited to 'lisp/nxml/nxml-mode.el')
-rw-r--r--lisp/nxml/nxml-mode.el29
1 files changed, 21 insertions, 8 deletions
diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index 1bc905cee2d..98ce1d6993e 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el
@@ -106,9 +106,10 @@ nor UTF-8."
(defcustom nxml-prefer-utf-16-little-to-big-endian-flag (eq system-type
'windows-nt)
"Non-nil means prefer little-endian to big-endian byte-order for UTF-16.
-This is used only for saving a buffer; when reading the byte-order is
-auto-detected. It may be relevant both when there is no encoding declaration
-and when the encoding declaration specifies `UTF-16'."
+This is used only for saving a buffer; when reading the
+byte-order is auto-detected. It may be relevant both when there
+is no encoding declaration and when the encoding declaration
+specifies `UTF-16'."
:group 'nxml
:type 'boolean
:safe #'booleanp)
@@ -392,11 +393,11 @@ reference.")
(define-key map "/" 'nxml-electric-slash)
(define-key map "\M-\t" 'completion-at-point)
map)
- "Keymap for nxml-mode.")
+ "Keymap for `nxml-mode'.")
(defvar nxml-font-lock-keywords
'(nxml-fontify-matcher)
- "Default font lock keywords for nxml-mode.")
+ "Default font lock keywords for `nxml-mode'.")
(defsubst nxml-set-face (start end face)
(when (and face (< start end))
@@ -454,8 +455,9 @@ reference.")
;; because Emacs turns C-c C-i into C-c TAB which is hard to type and
;; not mnemonic.
"Major mode for editing XML.
-
+\\<nxml-mode-map>
\\[nxml-finish-element] finishes the current element by inserting an end-tag.
+
C-c C-i closes a start-tag with `>' and then inserts a balancing end-tag
leaving point between the start-tag and end-tag.
\\[nxml-balanced-close-start-tag-block] is similar but for block rather than inline elements:
@@ -540,6 +542,8 @@ 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))))
@@ -564,8 +568,17 @@ 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."
+ "Clean up after `nxml-mode'."
;; Disable associated minor modes.
(rng-validate-mode -1)
;; Clean up fontification.
@@ -2258,7 +2271,7 @@ ENDP is t in the former case, nil in the latter."
(defun nxml-dynamic-markup-word ()
"Dynamically markup the word before point.
This attempts to find a tag to put around the word before point based
-on the contents of the current buffer. The end-tag will be inserted at
+on the contents of the current buffer. The end-tag will be inserted at
point. The start-tag will be inserted at or before the beginning of
the word before point; the contents of the current buffer is used to
decide where.