(nxml-compute-indent-in-token): Use `noindent` in CDATA - emacs.git

1 min read Original article ↗
authorStefan Monnier <monnier@iro.umontreal.ca>2025-12-27 15:27:49 -0500
committerStefan Monnier <monnier@iro.umontreal.ca>2025-12-27 15:27:49 -0500
commitcc2a0e90ab1f50145bcfb948a3483cc13b846177 (patch)
tree8ff272de25bed431736101b5c3689bc0d22345eb
parent2b6161a19f63105c6f744f6be8019acb9e308744 (diff)

(nxml-compute-indent-in-token): Use `noindent` in CDATAHEADmaster

`noindent` is more precise than what we did since it gives more info to the caller: `indent-for-tab-command` can treat it differently (e.g. fall back to `indent-relative`) than `indent-region`. * lisp/nxml/nxml-mode.el (nxml-compute-indent-in-token): Use `noindent` in CDATA. (nxml-compute-indent-in-delimited-token): Remove CDATA case, not used any nmore.

-rw-r--r--lisp/nxml/nxml-mode.el7

1 files changed, 2 insertions, 5 deletions

diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index b1666156ecc..3e9bd7a159a 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el

@@ -1451,8 +1451,7 @@ This expects the xmltok-* variables to be set up as by `xmltok-forward'."

(nxml-compute-indent-in-start-tag pos))

((eq xmltok-type 'comment)

(nxml-compute-indent-in-delimited-token pos "<!--" "-->"))

- ((eq xmltok-type 'cdata-section)

- (nxml-compute-indent-in-delimited-token pos "<![CDATA[" "]]>"))

+ ((eq xmltok-type 'cdata-section) 'noindent)

((eq xmltok-type 'processing-instruction)

(nxml-compute-indent-in-delimited-token pos "<?" "?>"))

(t

@@ -1521,9 +1520,7 @@ OPEN-DELIM and CLOSE-DELIM are strings giving the opening and closing

delimiters. POS is the position of the first non-whitespace character

of the line. This expects the xmltok-* variables to be set up as by

`xmltok-forward'."

- (cond ((string= open-delim "<![CDATA[")

- (goto-char pos))

- ((let ((end (+ pos (length close-delim))))

+ (cond ((let ((end (+ pos (length close-delim))))

(and (<= end (point-max))

(string= (buffer-substring-no-properties pos end)

close-delim)))