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

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

Comment indentation problems in nxml


From: Steinar Bang
Subject: Comment indentation problems in nxml
Date: Sun, 11 Nov 2018 15:51:45 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (windows-nt)

Emacs version: GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 
2017-09-15, modified by Debian
               (I'm using the version of nxml delivered with emacs)

I recently changed the copyright headers in XML files in one of my
projects from the massive
    <!-- Copyright 2018 Steinar Bang                                            
         -->
    <!--                                                                        
         -->
    <!-- Licensed under the Apache License, Version 2.0 (the "License");        
         -->
    <!-- you may not use this file except in compliance with the License.       
         -->
    <!-- You may obtain a copy of the License at                                
         -->
    <!--   http://www.apache.org/licenses/LICENSE-2.0                           
         -->
    <!-- Unless required by applicable law or agreed to in writing,             
         -->
    <!-- software distributed under the License is distributed on an "AS IS" 
BASIS,      -->
    <!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.        -->
    <!-- See the License for the specific language governing permissions and 
limitations -->
    <!-- under the License.                                                     
         -->


to the more "airy" an (I think) estetic

    <!--
        Copyright 2018 Steinar Bang

        Licensed under the Apache License, Version 2.0 (the "License");
        you may not use this file except in compliance with the License.
        You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

        Unless required by applicable law or agreed to in writing,
        software distributed under the License is distributed on an "AS IS" 
BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        See the License for the specific language governing permissions and 
limitations
        under the License.
    -->
    
However, this doesn't play well with my formatting fixup function:
(defun ide-fix ()
  "Remove trailing spaces and fix indentation"
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (replace-regexp "[ \t]+$" "")
    (goto-char (point-min))
    (replace-string "\t" " ")
    (indent-region (point-min) (point-max))))


After running "ide-fix", the indentation of the first line is kept, but
all of the other lines are moved to the left margin:

    <!--
        Copyright 2018 Steinar Bang

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations
under the License.
    -->


Is it possible to make nxml preserve the original indentation in these
comments?

(Or should I just bite the bullet and go back to the old copyright
headers?)

Thanks!


- Steinar



reply via email to

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