GNU bug report logs - #73206
28.2; xml comment with blank lines to do not indent correctly, nxml-mode.el

Previous Next

Package: emacs;

Reported by: ciolfi <at> mathworks.com

Date: Thu, 12 Sep 2024 18:04:03 UTC

Severity: normal

Found in version 28.2

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


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

From: Eli Zaretskii <eliz <at> gnu.org>
To: John Ciolfi <ciolfi <at> mathworks.com>, Stefan Kangas <stefankangas <at> gmail.com>
Cc: 73206 <at> debbugs.gnu.org, rpluim <at> gmail.com
Subject: Re: bug#73206: 28.2;
 xml comment with blank lines to do not indent correctly, nxml-mode.el
Date: Sat, 28 Sep 2024 11:45:46 +0300
Stefan, does the patch with the regexp fix look correct to you?

> Date: Sun, 15 Sep 2024 12:08:17 +0000
> msip_labels: 
> From:  John Ciolfi via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> Thanks for catching my typo and for moving the fix along.
> -----------------------------------------------------------------------------
> From: Robert Pluim <rpluim <at> gmail.com>
> Sent: Friday, September 13, 2024 3:43 AM
> To: 73206 <at> debbugs.gnu.org <73206 <at> debbugs.gnu.org>
> Cc: John Ciolfi <ciolfi <at> mathworks.com>
> Subject: Re: bug#73206: 28.2; xml comment with blank lines to do not indent correctly, nxml-mode.el 
>  
> >>>>> On Thu, 12 Sep 2024 13:53:26 -0400, John Ciolfi via "Bug reports for GNU Emacs, the Swiss army
> knife of text editors" <bug-gnu-emacs <at> gnu.org> said:
> 
>     John> 1. Create foo.xml containing:
> 
>     John> <foo>
>     John>     <!--
>     John>         foo
> 
>     John> bar
>     --> 
>     John> </foo>
> 
>     John> Notice that we have a blank line in the xml comment.
> 
>     John> 2. Put the point on 'bar' and press TAB.
> 
>     John> Notice that the 'bar' line is not indented correctly.
> 
>     John> Solution
>     John> --------
> 
>     John> The problem is that in nxml-compute-indent-in-delimited-token, there
>     John> is a (forward-line -1) which assumes that the prior line is indented. In
>     John> this case the prior line is a blank line and thus doesn't have
>     John> indentation. After the (forward-line -1), we need to keep going back
>     John> until we see a non-blank line:
> 
>     John>           (forward-line -1)
>     John> +           (while (looking-at "^[:blank:]*$")
>     John> +          (forward-line -1))
>  
>     John> Attached is a patch for nxml-mode.el that fixes the issue. 
> 
> Your patch does the right thing, but for the wrong reasons. Regexp
> character classes only have meaning with a bracket expression, so what
> you’re matching here is actually any lines containing zero or more of
> ':', 'b', 'l', 'a', 'n', or 'k'. IOW, you should use:
> 
>      (looking-at "^[[:blank:]]*$")
> 
> Robert
> -- 




This bug report was last modified 12 days ago.

Previous Next


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