bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#7937: nxml-mode indenting bug fix.


From: Eli Zaretskii
Subject: bug#7937: nxml-mode indenting bug fix.
Date: Thu, 30 Mar 2023 09:56:36 +0300

> From: Stephen Meister <pallagun@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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]