GNU bug report logs - #79817
[PATCH] Fix indentation for CDATA section content

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Huang Jing <rne.kou@HIDDEN>; Keywords: patch; Done: Eli Zaretskii <eliz@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 79817 <at> debbugs.gnu.org:


Received: (at 79817) by debbugs.gnu.org; 25 Nov 2025 20:32:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 25 15:32:05 2025
Received: from localhost ([127.0.0.1]:42351 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vNzhk-00055p-TL
	for submit <at> debbugs.gnu.org; Tue, 25 Nov 2025 15:32:05 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:54940)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1vNX4F-0001Gb-J3
 for 79817 <at> debbugs.gnu.org; Mon, 24 Nov 2025 08:57:24 -0500
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3C43F440B67;
 Mon, 24 Nov 2025 08:57:17 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1763992635;
 bh=8qLCmPV9tXRZbfcLE+Jl1tgjDxAwYwj0Z4fOtra2VWg=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=Fed6M56xbzp5uRynWz3HWgLdKTzLdhBi2daG4uPUAgLrIOcTyfwcl3+RK06nYm2m/
 /4Cvc3Xsk7qAHDgzodFNJYaqPurC3EOOr7kEeANMTsDl+BvnL9qC/lspFgplwg7ItW
 Q20fLEjiAvmwmvSli4Gp0k1NqsofSmN+WRU5/lhDKLicPfwwmmxkWLIsMpq2paysWn
 CrjMYffZNWz7tV4rX6zT2At7OxmA6U1NZR5vV0t2zKBHEeWcz0TLK65o5E8umz96Gc
 UXN7kXO2fXH6IzGxzyIs5MxSXlmiGvPoOx9LSstDa4GxxOsUzwu3SgILZ3VI43Xmxz
 p6SK5hijKR/rg==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D5D17440716;
 Mon, 24 Nov 2025 08:57:15 -0500 (EST)
Received: from asado (unknown [181.28.45.30])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C85A5120241;
 Mon, 24 Nov 2025 08:57:14 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Huang Jing <rne.kou@HIDDEN>
Subject: Re: bug#79817: [PATCH] Fix indentation for CDATA section content
In-Reply-To: <m2fraklsqf.wl-rne.kou@HIDDEN>
Message-ID: <jwvwm3fa6oo.fsf-monnier+emacs@HIDDEN>
References: <m24ir0rf9e.wl-rne.kou@HIDDEN>
 <m2fraklsqf.wl-rne.kou@HIDDEN>
Date: Mon, 24 Nov 2025 08:57:11 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.114 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
 KAM_SHORT               0.001 Use of a URL Shortener for very short URL
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 79817
Cc: 79817 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Huang Jing [2025-11-11 19:21:44] wrote:
> According to https://www.w3.org/TR/REC-xml/#sec-cdata-sect, CDATA
> contains character data, not markup. Therefore I think we should
> preserve original CData indention.
> 
> Example:
> 
>  |      <verbatim lang="c" line="6"><![CDATA[
>  |while (int_tmp > 0) {
>  |  off_read = int_tmp > sizeof (buffer) ? sizeof (buffer) : int_tmp;
>  |  pos_tmp  = read (in_fd, buffer, off_read);
>  |  pos_tmp  = write (out_fd, buffer, off_read);
>  |  int_tmp -= off_read;
>  |}
>  |      ]]></verbatim>

Sounds right.

`indent-line-function` supports the specific return value `noindent` to
indicate that this is a line whose indentation we can't understand,
typically because we're inside some string or comment or other element
whose contents does not have a well-defined structure.

So I think that's what we should use.  E.g. with the patch below.

Any objection?

> @@ -1430,6 +1430,8 @@ either nil or one of the symbols `start-tag', `end-tag', `markup',
>  	 (if (memq context '(nil end-tag comment))
>  	     'end-tag
>  	   'mixed))
> +        ((eq xmltok-type 'cdata-section)
> +         (or context 'markup))
>  	((eq xmltok-type 'comment)
>  	 (cond ((memq context '(start-tag end-tag comment))
>  		context)

I'm not sufficiently familiar with the nXML indentation code, could you
describe what that does, e.g. which behavior this fixes?


        Stefan


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 @@ nxml-compute-indent-in-token
 	 (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 @@ nxml-compute-indent-in-delimited-token
 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)))





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#79817; Package emacs. Full text available.

Message received at 79817 <at> debbugs.gnu.org:


Received: (at 79817) by debbugs.gnu.org; 25 Nov 2025 20:29:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 25 15:29:36 2025
Received: from localhost ([127.0.0.1]:42180 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vNzfL-00029F-SW
	for submit <at> debbugs.gnu.org; Tue, 25 Nov 2025 15:29:36 -0500
Received: from p-west1-cluster4-host3-snip4-8.eps.apple.com
 ([57.103.65.199]:22008 helo=outbound.pv.icloud.com)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <rne.kou@HIDDEN>)
 id 1vNnhq-0001F6-1y
 for 79817 <at> debbugs.gnu.org; Tue, 25 Nov 2025 02:43:23 -0500
Received: from outbound.pv.icloud.com (unknown [127.0.0.2])
 by p00-icloudmta-asmtp-us-west-1a-100-percent-6 (Postfix) with ESMTPS id
 EBF6D180010E; Tue, 25 Nov 2025 07:43:13 +0000 (UTC)
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai;
 bh=RN3yibOIQIJf4KSeNyQXyLOLMpF+hNyiSga+KGAQ8c0=;
 h=Date:Message-ID:From:To:Subject:MIME-Version:Content-Type:x-icloud-hme;
 b=WpJ9sNVGbCrr4rGqF9JfTGUpds7Et3FeVRpaZwuQU74ozr7N5+JK6EBJq11L3rWaEfbr79vdz6xMMlxhrCdVcmv+cJmqNywrVthO5l6TKilI14D+dJOw4sl1OeX1P6VvEuoAywwE2ot4HfFrI/UG28FZGlmBXxMP8TuCcflIkW+ciPmRo3cTV38L7yT+MaUegIe5X/cDD40xSZ1BDD9KnhKZVAUdBnuhhVRjc+Z7kHXUoJGB2YVjPeUG+ktU2FLeOWb65KjNl7VhOlG9fP2Onm1sYEXsNI50VIYCp7lNIx29jMwHWmwVBFg7sHzqhlC9d2GSsDG0gy+1y8zDJN2TxQ==
Received: from rne.local.icloud.com (unknown [17.56.9.36])
 by p00-icloudmta-asmtp-us-west-1a-100-percent-6 (Postfix) with ESMTPSA id
 A8095180011E; Tue, 25 Nov 2025 07:43:11 +0000 (UTC)
Date: Tue, 25 Nov 2025 15:43:07 +0800
Message-ID: <m21plm1rsk.wl-rne.kou@HIDDEN>
From: Huang Jing <rne.kou@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#79817: [PATCH] Fix indentation for CDATA section content
In-Reply-To: <jwvwm3fa6oo.fsf-monnier+emacs@HIDDEN>
References: <m24ir0rf9e.wl-rne.kou@HIDDEN>
 <m2fraklsqf.wl-rne.kou@HIDDEN>
 <jwvwm3fa6oo.fsf-monnier+emacs@HIDDEN>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (aarch64-apple-darwin24.6.0) MULE/6.0 (HANACHIRUSATO)
X-Face: "0XTV&77+1.L8mei_jIv?,$SI9YMI_L16Iv!+nC/as*WE|xh_Cz]cX\.kyAyE:yR!u)"H{;
 QZo'_9@M.+iEKMPM2PM0Km|k\+HA2@a>eTdL"}b4H~5fcj8XFtvcHRLa*",9{Nc*>!)>hf>f|gO}8rA[>|.#IL#IBHv'?kRAiLM@A>|R/&~C\:.0A{l`7W0D2r_$Iob;
 )7VZiR*!uN\4n#H<](bi4a/; b'II5>qmb; SG]=Glv2hD5%]MoElN'%/FpudX/LQ^%Cd2(.~iKi&{
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: text/plain; charset=US-ASCII
X-Proofpoint-GUID: B42dgWobA4w2ks7ahqM2UIe4cwQAYvmN
X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI1MDA2MyBTYWx0ZWRfX1xF/4mGBGsg7
 B5Cbssjqdh8dfP65OusEnD6l9eH/GSCheMMctop86ht9UMSuRjknJIfi2PtmFMV2N28YH4SU4p3
 Dl6VvqlWFossa7b7lZyAHMhqsSl/89ZH/IPvREweicuvL0ozIgz2t2/vvyc6egilPOKpJSlBQTs
 q8FKdNdDDgjZTefI/wZlkc5KP0qouL0XLzdlE8Lfreo/r8tkdDuDLfR+Me9Keu7li4wmZzy+AoV
 qezOQsvYQ9P0CNnGLrdvNIb9rp2vDgGv8/6XRxX7AZbFhXImN0Mal5TRhLh9N/iHOMb7iLDspgh
 6mFVSZLR3vKXOBWQHma
X-Authority-Info: v=2.4 cv=W/U1lBWk c=1 sm=1 tr=0 ts=69255e12 cx=c_apl:c_pps
 a=azHRBMxVc17uSn+fyuI/eg==:117 a=azHRBMxVc17uSn+fyuI/eg==:17
 a=kj9zAlcOel0A:10 a=6UeiqGixMTsA:10 a=x7bEGLp0ZPQA:10 a=EW7FI4N_MPcA:10
 a=VkNPw1HP01LnGYTKEx00:22 a=SSmOFEACAAAA:8 a=PfEV0CTCD2R7-XvRJnkA:9
 a=CjuIK1q_8ugA:10 a=mPsO-hJUlkSWBUsxGjm6:22 a=zblr9o9e3C7GZFZvko8r:22
X-Proofpoint-ORIG-GUID: B42dgWobA4w2ks7ahqM2UIe4cwQAYvmN
X-Proofpoint-Virus-Version: vendor=baseguard
 engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49
 definitions=2025-11-25_02,2025-11-24_02,2025-10-01_01
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0
 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 clxscore=1011
 mlxlogscore=999 spamscore=0 malwarescore=0 classifier=spam authscore=0
 adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001
 definitions=main-2511250063
X-JNJ: AAAAAAABgJ4ybxsKOO9zk1P4iBWlXFB7Nd9oNH6cEwBVkh2oBlrHD9f49ugOnrCJn1YjcvdQ8yQyOZXh1sh6+tntd5OQYhiAMrtLu8qQurgdaBXrFSfEO6FxXi+lVtqLJcU/JPd7P+2U7WRSDo/QX/iLU3qOlzXtzgYjF9uZJtsdYW9++SvxSRAXVl5dOj87PwMrlT1QKQMn0ReRhzYljxvXOAxHlhDsi/X8+jyox7r3JvFikMf255lAD0U3UUegbh2iyrQJ66yu7IObLsFaxzIhyn2xuCv6FC1hf2SqPs7hdxASirtGnS+/OYShL7vCwWhbXwaf+1RBUc33VgtT2neAmOHtYMQdLZEj5bCMo4wcIDA4nWCHUSXDitmicKt6XSsW08PD0mGNwCeNm8A45nlzMFpUr1/H5a4KlPJg2C5M3PvO9JDmtUar1SWrCc+kkV0yIE52tqDfIglYrVov6CMadPORndgtaQs2I8jr1jKIJPgvlAMCcaVqNkuvL6yxATYMgRcTu28AIup7KWobskf68iyhzUDRDA0MHdV6HjSJLqmsDGQE21861YwwadxKk9m9EhR/1ToKQ1wNNEvSOnijhl65D7hg8qsNg7AbyNBGUWM/035mgUHb23z9G1KrHCywIps=
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79817
Cc: Huang Jing <rne.kou@HIDDEN>, 79817 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Mon, 24 Nov 2025 21:57:11 +0800,
Stefan Monnier wrote:
> 
> Huang Jing [2025-11-11 19:21:44] wrote:
> > According to https://www.w3.org/TR/REC-xml/#sec-cdata-sect, CDATA
> > contains character data, not markup. Therefore I think we should
> > preserve original CData indention.
> > 
> > Example:
> > 
> >  |      <verbatim lang="c" line="6"><![CDATA[
> >  |while (int_tmp > 0) {
> >  |  off_read = int_tmp > sizeof (buffer) ? sizeof (buffer) : int_tmp;
> >  |  pos_tmp  = read (in_fd, buffer, off_read);
> >  |  pos_tmp  = write (out_fd, buffer, off_read);
> >  |  int_tmp -= off_read;
> >  |}
> >  |      ]]></verbatim>

Hi!

> Sounds right.
> 
> `indent-line-function` supports the specific return value `noindent` to
> indicate that this is a line whose indentation we can't understand,
> typically because we're inside some string or comment or other element
> whose contents does not have a well-defined structure.
> 
> So I think that's what we should use.  E.g. with the patch below.
> 
> Any objection?

Your approach seems to short-circuit the logic for cdata section
inside `nxml-compute-indent-in-token', which prevents
`nxml-compute-indent-in-delimited-token' from ever being called.

However I still think it's better to handle cdata section within
`nxml-compute-indent-in-delimited-token'. Conceptually a cdata section
is a delimited token, just like comments and processing instructions,
so its indentation should be determined by the same function. Even if
we ultimately preserve its indentation, it seems cleaner to return
`noindent' from `nxml-compute-indent-in-delimited-token', the function
responsible for delimited tokens, rather than from the top-level
`nxml-compute-indent-in-token', for the sake of consistent code
structure.

WDYT?

> > @@ -1430,6 +1430,8 @@ either nil or one of the symbols `start-tag', `end-tag', `markup',
> >  	 (if (memq context '(nil end-tag comment))
> >  	     'end-tag
> >  	   'mixed))
> > +        ((eq xmltok-type 'cdata-section)
> > +         (or context 'markup))
> >  	((eq xmltok-type 'comment)
> >  	 (cond ((memq context '(start-tag end-tag comment))
> >  		context)
> 
> I'm not sufficiently familiar with the nXML indentation code, could you
> describe what that does, e.g. which behavior this fixes?

This patch is necessary so `nxml-merge-indent-context-type' does not
return `mixed' when say, there is a cdata section after a start tag,
according to the rule `(context 'mixed)', resulting in the cdata
section being indented using:

  ;; If in the middle of a token that looks inline,
  ;; then indent relative to the previous non-blank line
  ((eq (nxml-merge-indent-context-type before-context)
       'mixed)
   (goto-char prev-bol)
   (throw 'indent (current-column)))

After patching, when a cdata section is encountered, it returns either
the previous context (similiar to the first case for comments):

  ((eq xmltok-type 'comment)
   (cond ((memq context '(start-tag end-tag comment))
  	context)

or `markup', which is consistent with the handling for cdata section
with nil context, according to `(t 'markup)'.

>         Stefan
> 
> 
> 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 @@ nxml-compute-indent-in-token
>  	 (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 @@ nxml-compute-indent-in-delimited-token
>  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)))




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#79817; Package emacs. Full text available.

Message received at 79817-done <at> debbugs.gnu.org:


Received: (at 79817-done) by debbugs.gnu.org; 25 Nov 2025 20:19:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 25 15:19:07 2025
Received: from localhost ([127.0.0.1]:41684 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vNzVC-0000Z3-Mt
	for submit <at> debbugs.gnu.org; Tue, 25 Nov 2025 15:19:07 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:35702)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1vMkUy-0002hI-OD
 for 79817-done <at> debbugs.gnu.org; Sat, 22 Nov 2025 05:05:45 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1vMkUm-0000sz-7l; Sat, 22 Nov 2025 05:05:32 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=sD6S2QD4Bol5JFuR1kjLM5EeWfsgxTeoNT6jghJWkKI=; b=o9MTUP4m8RqZ
 JWflBpgVAFur6EwFeXBpwIoDnhOSy0tsy6kexN5sEDc53eAWNivAPs/TT8y+J8tA5lMKE7VfKBXeC
 qy9LNkgcqw5o/ylAcgBHnkMN6/OkbN5U9UXQMwfzboPU7zqmRLhe+uYqOIza80UzeJppwmYX3ybqN
 Z7cKfz/GqPpIhVentHaZXRZV5WjC+l4qgGXdAfSjQBuw0tLyZQ6pB7ltNout2l0SZyrWq/Jb+7ILZ
 ca+LZt3EqJ/ZTCmbItjDRtRf7Lmhb/04V0fGfiwXnh2RwZIU6S569LY3URKLXDwgM2UJSxK2czC1c
 J6Dn719t3OutQ2pQ+EM7Wg==;
Date: Sat, 22 Nov 2025 12:05:14 +0200
Message-Id: <86pl9afkmd.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Huang Jing <rne.kou@HIDDEN>
In-Reply-To: <m2fraklsqf.wl-rne.kou@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#79817: [PATCH] Fix indentation for CDATA section content
References: <m24ir0rf9e.wl-rne.kou@HIDDEN>
 <m2fraklsqf.wl-rne.kou@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 79817-done
Cc: 79817-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Tue, 11 Nov 2025 19:21:44 +0800
> From:  Huang Jing via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> On Tue, 11 Nov 2025 19:16:13 +0800,
> Huang Jing wrote:
> > 
> > According to https://www.w3.org/TR/REC-xml/#sec-cdata-sect, CDATA
> > contains character data, not markup. Therefore I think we should
> > preserve original CData indention.
> > 
> > Example:
> > 
> >  |      <verbatim lang="c" line="6"><![CDATA[
> >  |while (int_tmp > 0) {
> >  |  off_read = int_tmp > sizeof (buffer) ? sizeof (buffer) : int_tmp;
> >  |  pos_tmp  = read (in_fd, buffer, off_read);
> >  |  pos_tmp  = write (out_fd, buffer, off_read);
> >  |  int_tmp -= off_read;
> >  |}
> >  |      ]]></verbatim>
> > 
> > should be kept as is, not being indented into
> > 
> >  |      <verbatim lang="c" line="6"><![CDATA[
> >  |      while (int_tmp > 0) {
> >  |      off_read = int_tmp > sizeof (buffer) ? sizeof (buffer) : int_tmp;
> >  |      pos_tmp  = read (in_fd, buffer, off_read);
> >  |      pos_tmp  = write (out_fd, buffer, off_read);
> >  |      int_tmp -= off_read;
> >  |      }
> >  |      ]]></verbatim>
> > 
> > 
> > In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.6.0, NS
> >  appkit-2575.70 Version 15.7 (Build 24G222)) of 2025-10-14 built on
> >  rne.local
> > Repository revision: c6475fa2f20e92a32453272a547367232a1e3e83
> > Repository branch: feature/igc
> > Windowing system distributor 'Apple', version 10.3.2575
> > System Description:  macOS 15.7.2
> > 
> > Configured using:
> >  'configure 'CFLAGS=-O3 -march=native -pipe'
> >  'CPPFLAGS=-I/tmp/emacs/esrc/../eart '
> >  'LDFLAGS=-L/tmp/emacs/esrc/../eart -Wl,-O3' --disable-gc-mark-trace
> >  --without-all --with-xml2 --with-native-image-api --with-ns
> >  --with-gnutls --with-toolkit-scroll-bars --with-small-ja-dic
> >  --with-tree-sitter --with-xwidgets --with-zlib --with-mps'
> > 
> > <#part type="text/x-patch" filename="~/Public/Projects/emacs-src/0001-Fix-indentation-for-CDATA-section-content.patch" disposition=attachment>
> > <#/part>
> 
> The patch, correctly appended.

Thanks, installed on the master branch, and closing the bug.




Notification sent to Huang Jing <rne.kou@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Eli Zaretskii <eliz@HIDDEN>:
You have taken responsibility. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 11 Nov 2025 14:10:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 11 09:10:43 2025
Received: from localhost ([127.0.0.1]:43910 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vIp50-0005Mm-W5
	for submit <at> debbugs.gnu.org; Tue, 11 Nov 2025 09:10:43 -0500
Received: from lists.gnu.org ([2001:470:142::17]:38094)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <rne.kou@HIDDEN>)
 id 1vImRl-0001cu-NC
 for submit <at> debbugs.gnu.org; Tue, 11 Nov 2025 06:22:02 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rne.kou@HIDDEN>)
 id 1vImRg-0003x6-4s
 for bug-gnu-emacs@HIDDEN; Tue, 11 Nov 2025 06:21:56 -0500
Received: from p-west1-cluster5-host4-snip4-3.eps.apple.com ([57.103.66.164]
 helo=outbound.pv.icloud.com)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rne.kou@HIDDEN>)
 id 1vImRe-0000uY-6U
 for bug-gnu-emacs@HIDDEN; Tue, 11 Nov 2025 06:21:55 -0500
Received: from outbound.pv.icloud.com (unknown [127.0.0.2])
 by p00-icloudmta-asmtp-us-west-1a-100-percent-10 (Postfix) with ESMTPS id
 BB91018000BF
 for <bug-gnu-emacs@HIDDEN>; Tue, 11 Nov 2025 11:21:50 +0000 (UTC)
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai;
 bh=tEeg9zZXtCi2UJOxd304CmQ3JqzvC7V5iyQMqIuhfAY=;
 h=Date:Message-ID:From:To:Subject:MIME-Version:Content-Type:x-icloud-hme;
 b=yhG2Z9Psa/+sHvJC/b0BRxzL4JoscsBFUODryibLMsB9/btxW3VEe5Wzb6fyHKDyMCtSxKeS3gKNgQG+2V2w7mhzlMbiJKYhtEvQNzRjs+DsJujrsufrQeS5+rctJ8jCP4+JGmNqPZsR/SwfJj4qhW+tNzqyTXR8A95QzwMqyrmUAhg9KTa5Q8S6iPxc2q1pYk8YGP0VBTCEcN+ZYL0ku3gcWeCto2keR2urV0XnAfAMD62DcXT5nV4AiqGtaYA3/X4a8uX/sbBeFekbBjCF4TYop1YC/1r1y29OAmp2f5KAFpT6uNLlOiHqGzqXSul8XtwXsiMHw1mkJzxr1hXJrw==
Received: from rne.local.icloud.com (unknown [17.56.9.36])
 by p00-icloudmta-asmtp-us-west-1a-100-percent-10 (Postfix) with ESMTPSA id
 1F4E31800138
 for <bug-gnu-emacs@HIDDEN>; Tue, 11 Nov 2025 11:21:48 +0000 (UTC)
Date: Tue, 11 Nov 2025 19:21:44 +0800
Message-ID: <m2fraklsqf.wl-rne.kou@HIDDEN>
From: Huang Jing <rne.kou@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: Re: [PATCH] Fix indentation for CDATA section content
In-Reply-To: <m24ir0rf9e.wl-rne.kou@HIDDEN>
References: <m24ir0rf9e.wl-rne.kou@HIDDEN>
User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue)
 FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0
 Emacs/31.0.50 (aarch64-apple-darwin24.6.0) MULE/6.0 (HANACHIRUSATO)
X-Face: "0XTV&77+1.L8mei_jIv?,$SI9YMI_L16Iv!+nC/as*WE|xh_Cz]cX\.kyAyE:yR!u)"H{;
 QZo'_9@M.+iEKMPM2PM0Km|k\+HA2@a>eTdL"}b4H~5fcj8XFtvcHRLa*",9{Nc*>!)>hf>f|gO}8rA[>|.#IL#IBHv'?kRAiLM@A>|R/&~C\:.0A{l`7W0D2r_$Iob;
 )7VZiR*!uN\4n#H<](bi4a/; b'II5>qmb; SG]=Glv2hD5%]MoElN'%/FpudX/LQ^%Cd2(.~iKi&{
MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue")
Content-Type: multipart/mixed; boundary="Multipart_Tue_Nov_11_19:21:44_2025-1"
X-Proofpoint-GUID: YphiW9HhwvXaIzJQ1yxfyPlRA5o94wij
X-Proofpoint-ORIG-GUID: YphiW9HhwvXaIzJQ1yxfyPlRA5o94wij
X-Authority-Info: v=2.4 cv=O5U0fR9W c=1 sm=1 tr=0 ts=69131c4f cx=c_apl:c_pps
 a=azHRBMxVc17uSn+fyuI/eg==:117 a=azHRBMxVc17uSn+fyuI/eg==:17
 a=6UeiqGixMTsA:10 a=x7bEGLp0ZPQA:10 a=EW7FI4N_MPcA:10
 a=VkNPw1HP01LnGYTKEx00:22 a=SSmOFEACAAAA:8 a=qRFC3GEZSn0unIMaeoMA:9
 a=CjuIK1q_8ugA:10 a=aqkiYpcMYk30ffMwgHEA:9 a=B2y7HmGcmWMA:10
 a=mPsO-hJUlkSWBUsxGjm6:22 a=WHP1k1oBom34GVUY1d1i:22 a=IwvVWueG1Ah0XQD6nzsO:22
 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=jd6J4Gguk5HxikPWLKER:22
X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTExMDA5MCBTYWx0ZWRfXzOUkotjAFO0X
 4kzGNfWSxD3oFkhcOomWfF4Hxh/dvHEgj7iitiuSlDavmJHphVr2vpq2Q+3SG+lS78GxSg4XIvk
 oYOoWwNmmj/mcveIwnkCxsnTowLB53IyvN4M4F4N4C/sREc3Q+vzGurBi/bczQdGAnJ/964h9fQ
 l6/7y6d3nX8fJgEczOfsLb2yxcaf+s/MLC91xUcwac5GWAn9sP+y68dYYJLrOlE2z9ZMbWuFY/m
 I84M/qiMmCfTBqetI2s19yVhKTPtHvi3sA5CZqyzNdd0JBhUM0eUr12A4ajyx0FbcfMo0hyKeZt
 rkOz3LSFi9EkLyg0QYd
X-Proofpoint-Virus-Version: vendor=baseguard
 engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49
 definitions=2025-11-11_02,2025-11-11_02,2025-10-01_01
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999
 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0
 clxscore=1015
 malwarescore=0 bulkscore=0 spamscore=0 classifier=spam authscore=0 adjust=0
 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511110090
X-JNJ: AAAAAAABK6AKNvR6w3Vuoe39Rbto37ER2wmz2j2VxXWgIe6hyhlrj7noiQ+bTwqs/6naBI49C3/+b1bBRbQ6x+DMCpzURyIXM5gnz2E6TgyFQHg+VmL08wdxlcadbfq19QP+WAyeP1BBnsd7QMutLtealVg/lzZV/FRb4rb3et8g4t9t8ypNYTv9gigcDY1+UZzTTVZLR5jkSQwU29KWuBCE2a91UTKZtOo8RbxP9qhdYn69+F03rpF9NLfs2D6kVHBDeNifRWkYOixPdndY7I1Fgj8O8bXNVW98zV04+Nk7xO/AWyVrTm9bZbUVumio195QvA7wzNWNy/7JHJNMsod4QRGtfK8cnC+UaF0rzXTC9MwKZHqay/sIFEBB+veXxoR1pPsKHfZFJkcueMp+4DiZmcmhLCTNqrMH70jmCTUeMFfmCGsJuQpIcHdtz7wAjDu0LY6BfRZ7tIuPxbAQ5REtX7lwdcyL1GKM/3cvvTqnNDk89ss+AAp5G1GfSRh0nTg5/M/EP9pcPU5oC49cIlXiy7quDQs0X1th5Vs8SkmzU9fMGM/inoQ8fPAn0CxNhtUYliYRAI7SdhGid8W93Q9ecwG9CQ==
Received-SPF: pass client-ip=57.103.66.164; envelope-from=rne.kou@HIDDEN;
 helo=outbound.pv.icloud.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Tue, 11 Nov 2025 09:10:40 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--Multipart_Tue_Nov_11_19:21:44_2025-1
Content-Type: text/plain; charset=US-ASCII

On Tue, 11 Nov 2025 19:16:13 +0800,
Huang Jing wrote:
> 
> According to https://www.w3.org/TR/REC-xml/#sec-cdata-sect, CDATA
> contains character data, not markup. Therefore I think we should
> preserve original CData indention.
> 
> Example:
> 
>  |      <verbatim lang="c" line="6"><![CDATA[
>  |while (int_tmp > 0) {
>  |  off_read = int_tmp > sizeof (buffer) ? sizeof (buffer) : int_tmp;
>  |  pos_tmp  = read (in_fd, buffer, off_read);
>  |  pos_tmp  = write (out_fd, buffer, off_read);
>  |  int_tmp -= off_read;
>  |}
>  |      ]]></verbatim>
> 
> should be kept as is, not being indented into
> 
>  |      <verbatim lang="c" line="6"><![CDATA[
>  |      while (int_tmp > 0) {
>  |      off_read = int_tmp > sizeof (buffer) ? sizeof (buffer) : int_tmp;
>  |      pos_tmp  = read (in_fd, buffer, off_read);
>  |      pos_tmp  = write (out_fd, buffer, off_read);
>  |      int_tmp -= off_read;
>  |      }
>  |      ]]></verbatim>
> 
> 
> In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.6.0, NS
>  appkit-2575.70 Version 15.7 (Build 24G222)) of 2025-10-14 built on
>  rne.local
> Repository revision: c6475fa2f20e92a32453272a547367232a1e3e83
> Repository branch: feature/igc
> Windowing system distributor 'Apple', version 10.3.2575
> System Description:  macOS 15.7.2
> 
> Configured using:
>  'configure 'CFLAGS=-O3 -march=native -pipe'
>  'CPPFLAGS=-I/tmp/emacs/esrc/../eart '
>  'LDFLAGS=-L/tmp/emacs/esrc/../eart -Wl,-O3' --disable-gc-mark-trace
>  --without-all --with-xml2 --with-native-image-api --with-ns
>  --with-gnutls --with-toolkit-scroll-bars --with-small-ja-dic
>  --with-tree-sitter --with-xwidgets --with-zlib --with-mps'
> 
> <#part type="text/x-patch" filename="~/Public/Projects/emacs-src/0001-Fix-indentation-for-CDATA-section-content.patch" disposition=attachment>
> <#/part>

The patch, correctly appended.


--Multipart_Tue_Nov_11_19:21:44_2025-1
Content-Type: text/plain; type=patch; name="0001-Fix-indentation-for-CDATA-section-content.patch"; charset=US-ASCII
Content-Disposition: attachment; filename="0001-Fix-indentation-for-CDATA-section-content.patch"
Content-Transfer-Encoding: 7bit

From 9d939fb20675f0f729dc4f7165d896e1d53a4603 Mon Sep 17 00:00:00 2001
From: RadioNoiseE <rne.kou@HIDDEN>
Date: Tue, 11 Nov 2025 18:46:26 +0800
Subject: [PATCH] Fix indentation for CDATA section content

* lisp/nxml/nxml-mode.el (nxml-merge-indent-context-type): Handle
'cdata-section type to prevent it from returning 'mixed.
* lisp/nxml/nxml-mode.el (nxml-compute-indent-in-delimited-token):
Preserve existing indentation for CDATA section content.
---
 lisp/nxml/nxml-mode.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index 9b780a9..b166615 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el
@@ -1430,6 +1430,8 @@ either nil or one of the symbols `start-tag', `end-tag', `markup',
 	 (if (memq context '(nil end-tag comment))
 	     'end-tag
 	   'mixed))
+        ((eq xmltok-type 'cdata-section)
+         (or context 'markup))
 	((eq xmltok-type 'comment)
 	 (cond ((memq context '(start-tag end-tag comment))
 		context)
@@ -1519,7 +1521,9 @@ 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 ((let ((end (+ pos (length close-delim))))
+  (cond ((string= open-delim "<![CDATA[")
+         (goto-char pos))
+        ((let ((end (+ pos (length close-delim))))
 	   (and (<= end (point-max))
 		(string= (buffer-substring-no-properties pos end)
 			 close-delim)))
-- 
2.50.1 (Apple Git-155)
--Multipart_Tue_Nov_11_19:21:44_2025-1--




Acknowledgement sent to Huang Jing <rne.kou@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#79817; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 25 Nov 2025 20:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.