GNU bug report logs - #7937
nxml-mode.el indenting wrong when more than one <> on a line

Previous Next

Package: emacs;

Reported by: jidanni <at> jidanni.org

Date: Sat, 29 Jan 2011 22:00:03 UTC

Severity: minor

Tags: confirmed, patch

To reply to this bug, email your comments to 7937 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7937; Package emacs. (Sat, 29 Jan 2011 22:00:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to jidanni <at> jidanni.org:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 29 Jan 2011 22:00:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: jidanni <at> jidanni.org
To: bug-gnu-emacs <at> gnu.org
Subject: nxml-mode.el indenting wrong when more than one <> on a line
Date: Sun, 30 Jan 2011 05:47:10 +0800
The nxml-mode indenting (C-x h TAB) is wrong as can be seen by the
</Folder></Folder> lining up on top of themselves, etc.
emacs-version "24.0.50.1" http://jidanni.org/comp/configuration/

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <Folder><name>噪音 Noise</name><description>http://jidanni.org/me/quiet.html</description>
    <Folder><name>慶福街 1-3 Qingfu St.</name>
    <Placemark><name>Luo Yuntian</name><LineString><coordinates>
    120.868205,24.176483 120.865225,24.181802</coordinates></LineString></Placemark>
    </Folder>
    <Folder><name>慶福街 1-6 Qingfu St.</name>
    <Placemark><name>Chen Chunlai</name><LineString><coordinates>
    120.877008,24.187393 120.866215,24.181668</coordinates></LineString></Placemark>
    </Folder>
    </Folder>
  </Document>
</kml>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#7937; Package emacs. (Mon, 14 Oct 2019 15:42:01 GMT) Full text and rfc822 format available.

Message #8 received at 7937 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 7937 <at> debbugs.gnu.org
Subject: Re: bug#7937: nxml-mode.el indenting wrong when more than one <> on a
 line
Date: Mon, 14 Oct 2019 17:41:15 +0200
jidanni <at> jidanni.org writes:

> The nxml-mode indenting (C-x h TAB) is wrong as can be seen by the
> </Folder></Folder> lining up on top of themselves, etc.
> emacs-version "24.0.50.1" http://jidanni.org/comp/configuration/
>
> <?xml version="1.0" encoding="UTF-8"?>
> <kml xmlns="http://www.opengis.net/kml/2.2">
>   <Document>
>     <Folder><name>噪音 Noise</name><description>http://jidanni.org/me/quiet.html</description>
>     <Folder><name>慶福街 1-3 Qingfu St.</name>
>     <Placemark><name>Luo Yuntian</name><LineString><coordinates>
>     120.868205,24.176483 120.865225,24.181802</coordinates></LineString></Placemark>
>     </Folder>
>     <Folder><name>慶福街 1-6 Qingfu St.</name>
>     <Placemark><name>Chen Chunlai</name><LineString><coordinates>
>     120.877008,24.187393 120.866215,24.181668</coordinates></LineString></Placemark>
>     </Folder>
>     </Folder>
>   </Document>
> </kml>

What's the expected indentation here?

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#7937; Package emacs. (Fri, 18 Oct 2019 08:20:02 GMT) Full text and rfc822 format available.

Message #11 received at 7937 <at> debbugs.gnu.org (full text, mbox):

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 7937 <at> debbugs.gnu.org
Subject: Re: bug#7937: nxml-mode.el indenting wrong when more than one <> on a
 line
Date: Fri, 18 Oct 2019 16:19:18 +0800
>>>>> "SK" == Stefan Kangas <stefan <at> marxist.se> writes:

SK> What's the expected indentation here?

Simple:
<Folder>
   <Folder>
etc.

We didn't close the Folder tag, so it has no "right" not to indent it!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#7937; Package emacs. (Fri, 07 Aug 2020 10:33:01 GMT) Full text and rfc822 format available.

Message #14 received at 7937 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 7937 <at> debbugs.gnu.org, Stefan Kangas <stefan <at> marxist.se>
Subject: Re: bug#7937: nxml-mode.el indenting wrong when more than one <> on
 a line
Date: Fri, 07 Aug 2020 12:32:17 +0200
積丹尼 Dan Jacobson <jidanni <at> jidanni.org> writes:

>>>>>> "SK" == Stefan Kangas <stefan <at> marxist.se> writes:
>
> SK> What's the expected indentation here?
>
> Simple:
> <Folder>
>    <Folder>
> etc.
>
> We didn't close the Folder tag, so it has no "right" not to indent it!

This bug is still present in Emacs 28.1.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) confirmed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 07 Aug 2020 10:33:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#7937; Package emacs. (Tue, 28 Mar 2023 19:28:03 GMT) Full text and rfc822 format available.

Message #19 received at 7937 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Meister <pallagun <at> gmail.com>
To: 7937 <at> debbugs.gnu.org
Subject: bug#7937: nxml-mode indenting bug fix.
Date: Tue, 28 Mar 2023 15:05:05 -0400
[Message part 1 (text/plain, inline)]
Hi,
  I've tried to put a fix in place for bug 7937 (and possibly 7768
unintentionally).  The repair I've made will cause changes in the way that
nxml indents lines under normal circumstances.  I'm not sure if a change
like this is acceptable given that I'm only trying to fix a bug.  The
behavior change is most visible in a situation such as:

<root>
  <a><b><c>
    inner
  </c>
</b>
  </a>
</root>

Which would now be indented as:
<root>
  <a><b><c>
        inner
      </c>
    </b>
  </a>
</root>

There are additional tests which show more of the indenting changes as well.

This is my first bug fix, please let me know if I've missed anything
(procedurally or otherwise).  I'm happy to rework/restructure this based on
any suggestions.

-steve
[Message part 2 (text/html, inline)]
[bug7937.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#7937; Package emacs. (Thu, 30 Mar 2023 06:57:01 GMT) Full text and rfc822 format available.

Message #22 received at 7937 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stephen Meister <pallagun <at> gmail.com>
Cc: 7937 <at> debbugs.gnu.org
Subject: Re: bug#7937: nxml-mode indenting bug fix.
Date: Thu, 30 Mar 2023 09:56:36 +0300
> From: Stephen Meister <pallagun <at> gmail.com>
> Date: Tue, 28 Mar 2023 15:05:05 -0400
> 
>   I've tried to put a fix in place for bug 7937 (and possibly 7768 unintentionally).  The repair I've made will
> cause changes in the way that nxml indents lines under normal circumstances.  I'm not sure if a change like
> this is acceptable given that I'm only trying to fix a bug.  The behavior change is most visible in a situation
> such as:
> 
> <root>
>   <a><b><c>
>     inner
>   </c>
> </b>
>   </a>
> </root>
> 
> Which would now be indented as:
> <root>
>   <a><b><c>
>         inner
>       </c>
>     </b>
>   </a>
> </root>

Sounds like the new behavior is better.  So I'm okay with this change
in behavior.

> This is my first bug fix, please let me know if I've missed anything (procedurally or otherwise).  I'm happy to
> rework/restructure this based on any suggestions.

Thanks, please see a few minor comments below.

> diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
> index 3869d0327fd..74108fa9d73 100644
> --- a/lisp/nxml/nxml-mode.el
> +++ b/lisp/nxml/nxml-mode.el

Please accompany the patches with a ChangeLog-style commit log
message.  The file CONTRIBUTE in the Emacs source tree describes our
conventions for writing log messages, and you can use "git log" to see
these conventions in action in our repository.

Also, please try to use "git format-patch" to format the patches, as
that makes it easier for us to install the patches.

> @@ -1352,15 +1354,19 @@ nxml-compute-indent-from-matching-start-tag
>  	     (goto-char xmltok-start)
>  	     (skip-chars-backward " \t")
>  	     (bolp))
> -	   (current-indentation)))))
> +	   (+ (current-indentation)
> +              ;; in the case of a line starting with data, keep the
> +              ;; indent level above the starting tag.

Comments should start with a capitalized letter.

> +          (nxml-tokenize-forward)
> +          (when (> (point) bol)         ; one token spans this and the line before
> +            (throw 'indent (nxml-compute-indent-in-token bol)))
> +          
> +          ;; Scan over the prevous line to determine the change in element depth
> +          (setq start-type-before xmltok-type)
> +          (while (< (point) bol)        ; examine all tags on the previous line

Comments should end with a period (i.e., should be full English
sentences), and should not overflow the 80-column line length, and
preferably not the fill-column as well.




Added tag(s) patch. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 30 Sep 2023 23:03:02 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 255 days ago.

Previous Next


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