From debbugs-submit-bounces@debbugs.gnu.org Tue May 25 08:33:44 2010 Received: (at submit) by debbugs.gnu.org; 25 May 2010 12:33:45 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OGtKJ-0003l1-UY for submit@debbugs.gnu.org; Tue, 25 May 2010 08:33:44 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OGpmV-0001N4-Te for submit@debbugs.gnu.org; Tue, 25 May 2010 04:46:36 -0400 Received: from lists.gnu.org ([199.232.76.165]:50647) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OGpmS-0002ES-Sr for submit@debbugs.gnu.org; Tue, 25 May 2010 04:46:32 -0400 Received: from [140.186.70.92] (port=45567 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OGpmQ-0006Q1-Tj for bug-gnu-emacs@gnu.org; Tue, 25 May 2010 04:46:32 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE autolearn=unavailable version=3.3.1 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OGpmP-0004YM-6I for bug-gnu-emacs@gnu.org; Tue, 25 May 2010 04:46:30 -0400 Received: from mailgw9.se.ericsson.net ([193.180.251.57]:53436) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OGpmO-0004Xv-Sz for bug-gnu-emacs@gnu.org; Tue, 25 May 2010 04:46:29 -0400 X-AuditID: c1b4fb39-b7c85ae000005565-08-4bfb8e61b60e Received: from esessmw0237.eemea.ericsson.se (Unknown_Domain [153.88.253.125]) by mailgw9.se.ericsson.net (Symantec Mail Security) with SMTP id 0B.4F.21861.16E8BFB4; Tue, 25 May 2010 10:46:25 +0200 (CEST) Received: from ESESSCMS0354.eemea.ericsson.se ([169.254.1.34]) by esessmw0237.eemea.ericsson.se ([153.88.115.90]) with mapi; Tue, 25 May 2010 10:46:24 +0200 From: =?iso-8859-1?Q?Patrik_H=E4gglund_H?= To: "bug-gnu-emacs@gnu.org" Date: Tue, 25 May 2010 10:46:24 +0200 Subject: 23.1; invalid XML in nested comments produced by comment-region Thread-Topic: 23.1; invalid XML in nested comments produced by comment-region Thread-Index: Acr75sGXUqjkwvfsS6aGgZBOdZGyrg== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: multipart/alternative; boundary="_000_AAEE17B01EA4FC4980FCD66E48DC49B42E874C045DESESSCMS0354e_" MIME-Version: 1.0 X-Brightmail-Tracker: AAAAAA== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 25 May 2010 08:33:41 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.0 (------) --_000_AAEE17B01EA4FC4980FCD66E48DC49B42E874C045DESESSCMS0354e_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable In xml mode, mark the following: and execute comment-region: This is invalid XML because '--' is not allowed inside comments. See http:/= /www.w3.org/TR/REC-xml/#sec-comments. (This is enforced by for example XML:= :Simple in perl 5.10.) For example, as an alternative, the following is valid: The offending code seems to be comment-quote-nested in newcomment.el. Shoul= d this code be changed, or the code for the xml mode, or both? In GNU Emacs 23.1.1 (i686-pc-linux-gnu, GTK+ Version 2.8.11) of 2009-09-08 on deacxl001 Windowing system distributor `The Cygwin/X Project', version 11.0.10800000 configured using `configure '--prefix=3D/app/emacs/23.1/LMWP2'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US value of $XMODIFIERS: nil locale-coding-system: iso-latin-1-unix default-enable-multibyte-characters: t Major mode: XML Minor modes in effect: tooltip-mode: t tool-bar-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t global-auto-composition-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: M-g g 3 0 6 C-SPC M-; C-a C-SPC M-; C-x C-s M-x r e p o r t - b u g Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Mark set [2 times] Mark activated Saving file /vobs/radio_testbeds_adv/platform/testapps/build/template/dul_a= /ulma_1/make/template.xml... Wrote /vobs/radio_testbeds_adv/platform/testapps/build/template/dul_a/ulma_= 1/make/template.xml --_000_AAEE17B01EA4FC4980FCD66E48DC49B42E874C045DESESSCMS0354e_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
In xml mode, mark the following:
 
  <!-- foo -->
  <bar/>
 
and execute comment-region:
 
  <!-- <\!-- foo -\-> -->
  <!-- <bar/> -->
 
This is invalid XML because '--' is not allowed inside comments. See <= a href=3D"http://www.w3.org/TR/REC-xml/#sec-comments">http://www.w3.org/TR/REC-xml/#sec-comments. (This is e= nforced by for example XML::Simple in perl 5.10.)
 
For example, as an alternative, the following is valid:
 
  <!-- <!-\- foo -\-> -->
  <!-- <bar/> -->
 
The offending code seems to be comment-quote-nested in newcomment.el. = Should this code be changed, or the code for the xml mode, or both?
 
 
In GNU Emacs 23.1.1 (i686-pc-linux-gnu, GTK+ Version 2.8.11)
of 2009-09-08 on deacxl001
Windowing system distributor `The Cygwin/X Project', version 11.0.1080= 0000
configured using `configure  '--prefix=3D/app/emacs/23.1/LMWP2''<= /div>
 
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US
  value of $XMODIFIERS: nil
  locale-coding-system: iso-latin-1-unix
  default-enable-multibyte-characters: t
 
Major mode: XML
 
Minor modes in effect:
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
 
Recent input:
M-g g 3 0 6 <return> <down> C-SPC <down> <down>= ; M-;
<up> <up> <right> <right> <right> <ri= ght> <backspace>
C-a C-SPC <down> <down> M-; C-x C-s M-x r e p o r t
- b u g <return>
 
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set [2 times]
Mark activated
Saving file /vobs/radio_testbeds_adv/platform/testapps/build/template/= dul_a/ulma_1/make/template.xml...
Wrote /vobs/radio_testbeds_adv/platform/testapps/build/template/dul_a/= ulma_1/make/template.xml
 
--_000_AAEE17B01EA4FC4980FCD66E48DC49B42E874C045DESESSCMS0354e_-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 18 17:14:08 2015 Received: (at 6267) by debbugs.gnu.org; 18 Sep 2015 21:14:08 +0000 Received: from localhost ([127.0.0.1]:37328 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zd2yt-00076Y-8T for submit@debbugs.gnu.org; Fri, 18 Sep 2015 17:14:08 -0400 Received: from mail-oi0-f43.google.com ([209.85.218.43]:36805) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zd2yq-00076M-6J; Fri, 18 Sep 2015 17:14:05 -0400 Received: by oibi136 with SMTP id i136so33329137oib.3; Fri, 18 Sep 2015 14:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=2kLTri9DmcR8LQolAjoqSLhl1HMa94j8wtZR7ge3P00=; b=ufyOsXCnIafjjR+ThGPHeKJoIADAScoR7ZVv5M0z+uqdxhxdIkAgrM33OP1AFc0QwD ZZy0BL2C+X+8CbA9K3oAyWsBu+lGz89O4NASrSb9EMnCtmkG5aAXGiCosZ0VD4qJfsC5 xQtS9QL8mAkPaymOKDg5arVIRvO9JSgH09XNaQFO77lpFYRO8L8WXgBdsU0sACUMFS/+ kfAi1gZidpz8Cb3mN3HSJL0oCbks2FVrXPwVOwQeHZlFAWvawvrwzwdX8XYYTzus2Q0L mOA8/uuCJ0DYyA/X094OyB0MrspMf2zA/SWCwHakbYSzBmnLDSU7r939itrVYC2pDQsO Pqtg== MIME-Version: 1.0 X-Received: by 10.202.81.136 with SMTP id f130mr4842970oib.94.1442610843655; Fri, 18 Sep 2015 14:14:03 -0700 (PDT) Received: by 10.202.169.13 with HTTP; Fri, 18 Sep 2015 14:14:03 -0700 (PDT) Date: Fri, 18 Sep 2015 15:14:03 -0600 Message-ID: Subject: Re: bug#6267: 23.1; invalid XML in nested comments produced by comment-region From: Ivan Andrus To: 6267@debbugs.gnu.org, patrik.h.hagglund@ericsson.com Content-Type: multipart/alternative; boundary=001a113b1954e2a61605200c0263 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 6267 Cc: 20001@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --001a113b1954e2a61605200c0263 Content-Type: text/plain; charset=UTF-8 I have a patch for this (and the duplicate bug #20001) that I would like some feedback on from a regular developer. I think the approach is reasonable, but any feedback would be welcome. I have commmit access, so I can commit it, but I've probably forgotten some important piece. It's not user facing (except fixing a bug), so I believe I don't need a NEWS entry. I'm not sure if or where it should be documented in the manual. There doesn't seem to be documentation for `comment-region-function' (at least I didn't find any with C-h S) which seemed the closest variable that I could think of. Thanks, Ivan Allow major-modes full control over quoting nested comments * newcomment.el (comment-quote-nested-function): New variable. (comment-quote-nested-default): New function. (comment-quote-nested): Use `comment-quote-nested-function'. --- lisp/newcomment.el | 66 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 60f35c8..4c01742 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el @@ -179,6 +179,11 @@ comments always start in column zero.") "Non-nil if nested comments should be quoted. This should be locally set by each major mode if needed.") +(defvar comment-quote-nested-function #'comment-quote-nested-default + "Function to quote nested comments in a region. +It takes the same arguments as `comment-quote-nested-default', +and is called with the buffer narrowed to a single comment.") + (defvar comment-continue nil "Continuation string to insert for multiline comments. This string will be added at the beginning of each line except the very @@ -412,28 +417,45 @@ function should first call this function explicitly." If UNP is non-nil, unquote nested comment markers." (setq cs (comment-string-strip cs t t)) (setq ce (comment-string-strip ce t t)) - (when (and comment-quote-nested (> (length ce) 0)) - (let ((re (concat (comment-quote-re ce unp) - "\\|" (comment-quote-re cs unp)))) - (goto-char (point-min)) - (while (re-search-forward re nil t) - (goto-char (match-beginning 0)) - (forward-char 1) - (if unp (delete-char 1) (insert "\\")) - (when (= (length ce) 1) - ;; If the comment-end is a single char, adding a \ after that - ;; "first" char won't deactivate it, so we turn such a CE - ;; into !CS. I.e. for pascal, we turn } into !{ - (if (not unp) - (when (string= (match-string 0) ce) - (replace-match (concat "!" cs) t t)) - (when (and (< (point-min) (match-beginning 0)) - (string= (buffer-substring (1- (match-beginning 0)) - (1- (match-end 0))) - (concat "!" cs))) - (backward-char 2) - (delete-char (- (match-end 0) (match-beginning 0))) - (insert ce)))))))) + (when (and comment-quote-nested + comment-quote-nested-function + (> (length ce) 0)) + (funcall comment-quote-nested-function cs ce unp))) + +(defun comment-quote-nested-default (cs ce unp) + "Quote comment delimiters in the buffer. +It expects to be called with the buffer narrowed to a single comment. +It is used as a default for `comment-quote-nested-function'. + +The arguments CS and CE are regular expressions matching comment +starting and ending delimiters respectively. + +If UNP is non-nil, comments are unquoted instead. + +To quote the delimiters, a \\ is inserted after the first +character of CS or CE. If CE is a single character it will +change CE into !CS." + (let ((re (concat (comment-quote-re ce unp) + "\\|" (comment-quote-re cs unp)))) + (goto-char (point-min)) + (while (re-search-forward re nil t) + (goto-char (match-beginning 0)) + (forward-char 1) + (if unp (delete-char 1) (insert "\\")) + (when (= (length ce) 1) + ;; If the comment-end is a single char, adding a \ after that + ;; "first" char won't deactivate it, so we turn such a CE + ;; into !CS. I.e. for pascal, we turn } into !{ + (if (not unp) + (when (string= (match-string 0) ce) + (replace-match (concat "!" cs) t t)) + (when (and (< (point-min) (match-beginning 0)) + (string= (buffer-substring (1- (match-beginning 0)) + (1- (match-end 0))) + (concat "!" cs))) + (backward-char 2) + (delete-char (- (match-end 0) (match-beginning 0))) + (insert ce))))))) ;;;; ;;;; Navigation -- 2.5.2 Properly quote nested xml comments (Bug#6267) (Bug#20001) * nxml-mode.el (nxml-comment-quote-nested): New function (nxml-mode): Set comment-quote-nested-function --- lisp/nxml/nxml-mode.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el index 6c5c85b..dc151a3 100644 --- a/lisp/nxml/nxml-mode.el +++ b/lisp/nxml/nxml-mode.el @@ -546,6 +546,8 @@ Many aspects this mode can be customized using (setq comment-end-skip "[ \t\r\n]*-->") (make-local-variable 'comment-line-break-function) (setq comment-line-break-function 'nxml-newline-and-indent) + (make-local-variable 'comment-quote-nested-function) + (setq comment-quote-nested-function 'nxml-comment-quote-nested) (use-local-map nxml-mode-map) (save-excursion (save-restriction @@ -1350,6 +1352,18 @@ of the inserted start-tag or nil if none was inserted." start-tag-indent))))) inserted-start-tag-pos)) +(defun nxml-comment-quote-nested (cs ce unp) + "Quote nested comments in buffer. +See `comment-quote-nested-function' for more information.") + (goto-char (point-min)) + (save-match-data + (while (re-search-forward "-[\\]*-" nil t) + (goto-char (match-beginning 0)) + (forward-char 1) + (if unp + (delete-char 1) + (insert "\\"))))) + ;;; Indentation (defun nxml-indent-line () -- 2.5.2 --001a113b1954e2a61605200c0263 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I have a = patch for this (and the duplicate bug #20001) that I would like
some fee= dback on from a regular developer.=C2=A0 I think the approach is
reasona= ble, but any feedback would be welcome.=C2=A0 I have commmit access,
so = I can commit it, but I've probably forgotten some important piece.
<= br>It's not user facing (except fixing a bug), so I believe I don't= need a
NEWS entry.=C2=A0 I'm not sure if or where it should be docu= mented in the
manual.=C2=A0 There doesn't seem to be documentation f= or
`comment-region-function' (at least I didn't find any with C-= h S) which
seemed the closest variable that I could think of.

Tha= nks,
Ivan


Allow major-modes full control over quoting nested = comments

* newcomment.el (comment-quote-nested-function): New variab= le.
(comment-quote-nested-default): New function.
(comment-quote-nest= ed): Use `comment-quote-nested-function'.
---
=C2=A0lisp/newcomme= nt.el | 66 ++++++++++++++++++++++++++++++++++++------------------
=C2=A0= 1 file changed, 44 insertions(+), 22 deletions(-)

diff --git a/lisp/= newcomment.el b/lisp/newcomment.el
index 60f35c8..4c01742 100644
--- = a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -179,6 +179,11 @@ co= mments always start in column zero.")
=C2=A0 =C2=A0"Non-nil if= nested comments should be quoted.
=C2=A0This should be locally set by e= ach major mode if needed.")
=C2=A0
+(defvar comment-quote-nested= -function #'comment-quote-nested-default
+ =C2=A0"Function to q= uote nested comments in a region.
+It takes the same arguments as `comme= nt-quote-nested-default',
+and is called with the buffer narrowed to= a single comment.")
+
=C2=A0(defvar comment-continue nil
=C2= =A0 =C2=A0"Continuation string to insert for multiline comments.
= =C2=A0This string will be added at the beginning of each line except the ve= ry
@@ -412,28 +417,45 @@ function should first call this function explic= itly."
=C2=A0If UNP is non-nil, unquote nested comment markers.&quo= t;
=C2=A0 =C2=A0(setq cs (comment-string-strip cs t t))
=C2=A0 =C2=A0= (setq ce (comment-string-strip ce t t))
- =C2=A0(when (and comment-quote= -nested (> (length ce) 0))
- =C2=A0 =C2=A0(let ((re (concat (comment-= quote-re ce unp)
- =C2=A0 = =C2=A0 =C2=A0 "\\|" (comment-quote-re cs unp))))
- =C2=A0 =C2= =A0 =C2=A0(goto-char (point-min))
- =C2=A0 =C2=A0 =C2=A0(while (re-searc= h-forward re nil t)
- (goto-= char (match-beginning 0))
- = (forward-char 1)
- (if unp (= delete-char 1) (insert "\\"))
- (when (=3D (length ce) 1)
- =C2=A0 ;; If the comment-end is a single char, adding a \ aft= er that
- =C2=A0 ;; "fi= rst" char won't deactivate it, so we turn such a CE
- =C2=A0 ;; into !CS.=C2=A0 I.e. for pasca= l, we turn } into !{
- =C2= =A0 (if (not unp)
- =C2=A0 = =C2=A0 =C2=A0 (when (string=3D (match-string 0) ce)
- (replace-match (concat "!" cs) t t))- =C2=A0 =C2=A0 (when (and (&= lt; (point-min) (match-beginning 0))
- =C2=A0 =C2=A0 =C2=A0 =C2=A0(string=3D (buffer-substring (1- (ma= tch-beginning 0))
- =C2= =A0 (1- (match-end 0)))
- (concat "!" cs)))
- =C2=A0 =C2=A0 =C2=A0 (backward-char 2)
- =C2=A0 =C2=A0 =C2=A0 (delete-char (- (match-end 0) (match-b= eginning 0)))
- =C2=A0 =C2= =A0 =C2=A0 (insert ce))))))))
+ =C2=A0(when (and comment-quote-nested+ =C2=A0 =C2=A0 =C2=A0comment-= quote-nested-function
+ =C2= =A0 =C2=A0 =C2=A0(> (length ce) 0))
+ =C2=A0 =C2=A0(funcall comment-q= uote-nested-function cs ce unp)))
+
+(defun comment-quote-nested-defa= ult (cs ce unp)
+ =C2=A0"Quote comment delimiters in the buffer.+It expects to be called with the buffer narrowed to a single comment.
= +It is used as a default for `comment-quote-nested-function'.
+
+= The arguments CS and CE are regular expressions matching comment
+starti= ng and ending delimiters respectively.
+
+If UNP is non-nil, comments= are unquoted instead.
+
+To quote the delimiters, a \\ is inserted a= fter the first
+character of CS or CE.=C2=A0 If CE is a single character= it will
+change CE into !CS."
+ =C2=A0(let ((re (concat (commen= t-quote-re ce unp)
+ =C2=A0= =C2=A0 "\\|" (comment-quote-re cs unp))))
+ =C2=A0 =C2=A0(got= o-char (point-min))
+ =C2=A0 =C2=A0(while (re-search-forward re nil t)+ =C2=A0 =C2=A0 =C2=A0(goto-char (match-beginning 0))
+ =C2=A0 =C2=A0 = =C2=A0(forward-char 1)
+ =C2=A0 =C2=A0 =C2=A0(if unp (delete-char 1) (in= sert "\\"))
+ =C2=A0 =C2=A0 =C2=A0(when (=3D (length ce) 1)+ ;; If the comment-end is a s= ingle char, adding a \ after that
+= ;; "first" char won't deactivate it, so we turn such = a CE
+ ;; into !CS.=C2=A0 I.= e. for pascal, we turn } into !{
+ = (if (not unp)
+ =C2= =A0 =C2=A0 (when (string=3D (match-string 0) ce)
+ =C2=A0 =C2=A0 =C2=A0 (replace-match (concat "!&= quot; cs) t t))
+ =C2=A0 (wh= en (and (< (point-min) (match-beginning 0))
+ =C2=A0 =C2=A0 =C2=A0(string=3D (buffer-substring (1- = (match-beginning 0))
+ = (1- (match-end 0)))
+ =C2= =A0 =C2=A0 =C2=A0 (concat "!" cs)))
+ =C2=A0 =C2=A0 (backward-char 2)
+ =C2=A0 =C2=A0 (delete-char (- (match-end 0) (matc= h-beginning 0)))
+ =C2=A0 = =C2=A0 (insert ce)))))))
=C2=A0
=C2=A0;;;;
=C2=A0;;;; Navigation--=C2=A0
2.5.2



Properly quote nested xml comments (Bug#= 6267) (Bug#20001)

* nxml-mode.el (nxml-comment-quote-nested): New fu= nction
(nxml-mode): Set comment-quote-nested-function
---
=C2=A0li= sp/nxml/nxml-mode.el | 14 ++++++++++++++
=C2=A01 file changed, 14 insert= ions(+)

diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el=
index 6c5c85b..dc151a3 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/= lisp/nxml/nxml-mode.el
@@ -546,6 +546,8 @@ Many aspects this mode can be= customized using
=C2=A0 =C2=A0(setq comment-end-skip "[ \t\r\n]*--= >")
=C2=A0 =C2=A0(make-local-variable 'comment-line-break-fu= nction)
=C2=A0 =C2=A0(setq comment-line-break-function 'nxml-newline= -and-indent)
+ =C2=A0(make-local-variable 'comment-quote-nested-func= tion)
+ =C2=A0(setq comment-quote-nested-function 'nxml-comment-quot= e-nested)
=C2=A0 =C2=A0(use-local-map nxml-mode-map)
=C2=A0 =C2=A0(sa= ve-excursion
=C2=A0 =C2=A0 =C2=A0(save-restriction
@@ -1350,6 +1352,1= 8 @@ of the inserted start-tag or nil if none was inserted."
=C2=A0= =C2=A0 =C2=A0 start-tag-inde= nt)))))
=C2=A0 =C2=A0 =C2=A0inserted-start-tag-pos))
=C2=A0
+(defu= n nxml-comment-quote-nested (cs ce unp)
+ =C2=A0"Quote nested comme= nts in buffer.
+See `comment-quote-nested-function' for more informa= tion.")
+ =C2=A0(goto-char (point-min))
+ =C2=A0(save-match-data=
+ =C2=A0 =C2=A0(while (re-search-forward "-[\\]*-" nil t)
= + =C2=A0 =C2=A0 =C2=A0(goto-char (match-beginning 0))
+ =C2=A0 =C2=A0 = =C2=A0(forward-char 1)
+ =C2=A0 =C2=A0 =C2=A0(if unp
+ =C2=A0 (delete-char 1)
+ (insert "\\")))))
+
=C2=A0;;; In= dentation
=C2=A0
=C2=A0(defun nxml-indent-line ()
--=C2=A0
2.5.= 2


--001a113b1954e2a61605200c0263-- From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 19 00:07:43 2015 Received: (at 6267) by debbugs.gnu.org; 19 Sep 2015 04:07:43 +0000 Received: from localhost ([127.0.0.1]:37397 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zd9R9-0002ME-Gx for submit@debbugs.gnu.org; Sat, 19 Sep 2015 00:07:43 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:39944) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zd9R6-0002Lw-Ff; Sat, 19 Sep 2015 00:07:41 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AxFgA731xV/2yixEVcgxCEAoVVu0CHSwQCAoE8OxIBAQEBAQEBgQpBBYNdAQEEViMQCw4mEhQYDSSIP88jAQEBAQYBAQEBHos6hQUHhC0FnxeDa5A9gUUjYYMzIoJ4AQEB X-IPAS-Result: A0AxFgA731xV/2yixEVcgxCEAoVVu0CHSwQCAoE8OxIBAQEBAQEBgQpBBYNdAQEEViMQCw4mEhQYDSSIP88jAQEBAQYBAQEBHos6hQUHhC0FnxeDa5A9gUUjYYMzIoJ4AQEB X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="165285987" Received: from 69-196-162-108.dsl.teksavvy.com (HELO ceviche.home) ([69.196.162.108]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 19 Sep 2015 00:07:39 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 32FA06619A; Sat, 19 Sep 2015 00:07:33 -0400 (EDT) From: Stefan Monnier To: Ivan Andrus Subject: Re: bug#6267: 23.1; invalid XML in nested comments produced by comment-region Message-ID: References: Date: Sat, 19 Sep 2015 00:07:33 -0400 In-Reply-To: (Ivan Andrus's message of "Fri, 18 Sep 2015 15:14:03 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 6267 Cc: 20001@debbugs.gnu.org, 6267@debbugs.gnu.org, patrik.h.hagglund@ericsson.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) The approach looks fine, thank you. > +(defvar comment-quote-nested-function #'comment-quote-nested-default [...] > + (when (and comment-quote-nested > + comment-quote-nested-function comment-quote-nested-function will always be a function so it should never be nil, so there's no need to test it here. > +The arguments CS and CE are regular expressions matching comment > +starting and ending delimiters respectively. AFAICT this is not true. They're just strings, not regexps. > + (make-local-variable 'comment-quote-nested-function) > + (setq comment-quote-nested-function 'nxml-comment-quote-nested) I know the rest of the file doesn't use it, but please in new code use: (setq-local comment-quote-nested-function #'nxml-comment-quote-nested) -- Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 23 20:02:56 2015 Received: (at 6267) by debbugs.gnu.org; 24 Sep 2015 00:02:56 +0000 Received: from localhost ([127.0.0.1]:43134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zeu00-0005kS-0b for submit@debbugs.gnu.org; Wed, 23 Sep 2015 20:02:56 -0400 Received: from mail-ig0-f174.google.com ([209.85.213.174]:36650) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zetzy-0005kE-9J; Wed, 23 Sep 2015 20:02:54 -0400 Received: by igcrk20 with SMTP id rk20so110805803igc.1; Wed, 23 Sep 2015 17:02:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:message-id:date :to:mime-version; bh=6m4mz+zJKbqWwvfExMxv+HKvNoa2fJEBn2LtyAkiUa4=; b=i+kjCyC6HJktqjO++4Um42yDKlfzKrQ580ot4Fh+BH3csJeGjhTNYMJVKJYGQ+c1Rj PRyNgRpwewydaisyJp6EX/cKRjzAk9qREsEgWxKEYiPAt/sOlkmC2d+lXohSgITzkxgR yE+tEqrcelw+Vrw3i3gjyr8N3/OsngX1MQJv0xn67f5PkW0oTUqjuFDvmchNxavNheYa k/6PqIGGUtO5gsmgkJybmq5xYofAZFIHYZWVcZFe9f7oXWjZFGa15YavOYSTFgdV3Dmp qmfM4nnFRKbUtq9tjxYRvAdK2b0KxLNqzhkAE2l9FYlunbQAigZ70vseQPoUhk8y8t3l 4AQQ== X-Received: by 10.50.143.10 with SMTP id sa10mr26533740igb.66.1443052973632; Wed, 23 Sep 2015 17:02:53 -0700 (PDT) Received: from [192.168.0.3] (97-117-23-179.slkc.qwest.net. [97.117.23.179]) by smtp.gmail.com with ESMTPSA id pl9sm4427309igb.8.2015.09.23.17.02.52 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Sep 2015 17:02:53 -0700 (PDT) From: Ivan Andrus Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: close bugs 6267 and 20001 Message-Id: Date: Wed, 23 Sep 2015 18:02:50 -0600 To: 20001@debbugs.gnu.org, 6267@debbugs.gnu.org Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) X-Mailer: Apple Mail (2.2104) X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 6267 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) close 6267 25.1 close 20001 25.1 From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 23 20:50:26 2015 Received: (at control) by debbugs.gnu.org; 24 Sep 2015 00:50:26 +0000 Received: from localhost ([127.0.0.1]:43149 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zeujy-0006sx-8W for submit@debbugs.gnu.org; Wed, 23 Sep 2015 20:50:26 -0400 Received: from mail-ig0-f177.google.com ([209.85.213.177]:34492) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zeujv-0006sn-G5 for control@debbugs.gnu.org; Wed, 23 Sep 2015 20:50:23 -0400 Received: by igcpb10 with SMTP id pb10so4390562igc.1 for ; Wed, 23 Sep 2015 17:50:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:message-id:date :to:mime-version; bh=6m4mz+zJKbqWwvfExMxv+HKvNoa2fJEBn2LtyAkiUa4=; b=hp+p8P1zNKh6gzTGPUQ837JPmzYNgxGjXGnZaSmIWfsNOyU4rm0WPp6DlL0bn5+EcL Pu50zu7yMTxQmXmOKp+UtnE0+ypbGnd8VL/CQm8BpCY8uT1T8i+c74bBjmBNOMNPK4mg 8VMaMmSlMJLr3wF02KqxnH4ToHRd16pqQnojvR0AYrK/cRxFjibZmp/8j+IgmiiSinb8 7O2WPtnTpjwv8lPz+w5KX6tYvObgOWeJe8bcuvD5pcSZqHScUWDo02OQM7XXE/TNXPid +wnyynU7wF73uk1u7RFJKpSSJJHtZjXtPs/dmm56/m9aSdxDlP/QO+2a450qKpxNounh MsNA== X-Received: by 10.50.141.166 with SMTP id rp6mr14582854igb.29.1443055822953; Wed, 23 Sep 2015 17:50:22 -0700 (PDT) Received: from [192.168.0.3] (97-117-23-179.slkc.qwest.net. [97.117.23.179]) by smtp.gmail.com with ESMTPSA id 39sm4706921ioh.38.2015.09.23.17.50.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Sep 2015 17:50:22 -0700 (PDT) From: Ivan Andrus Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: close bugs 6267 and 20001 Message-Id: <7386510A-BFD4-4421-BAC9-5B77D320BDCF@gmail.com> Date: Wed, 23 Sep 2015 18:50:21 -0600 To: control@debbugs.gnu.org Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) X-Mailer: Apple Mail (2.2104) X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) close 6267 25.1 close 20001 25.1 From unknown Fri Aug 15 21:28:23 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 22 Oct 2015 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator