emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r100597: * lisp/nxml/nxml-mode.el (nx


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r100597: * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Date: Sun, 13 Jun 2010 21:43:11 -0400
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100597
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Sun 2010-06-13 21:43:11 -0400
message:
  * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
modified:
  lisp/ChangeLog
  lisp/nxml/nxml-mode.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-06-12 17:14:43 +0000
+++ b/lisp/ChangeLog    2010-06-14 01:43:11 +0000
@@ -1,3 +1,7 @@
+2010-06-14  Stefan Monnier  <address@hidden>
+
+       * nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
+
 2010-06-12  Chong Yidong  <address@hidden>
 
        * term/common-win.el (x-colors): Add all the color names defined

=== modified file 'lisp/nxml/nxml-mode.el'
--- a/lisp/nxml/nxml-mode.el    2010-05-20 15:12:20 +0000
+++ b/lisp/nxml/nxml-mode.el    2010-06-14 01:43:11 +0000
@@ -1370,17 +1370,21 @@
 
 (defun nxml-indent-line ()
   "Indent current line as XML."
-  (let ((indent (nxml-compute-indent))
-       (from-end (- (point-max) (point))))
-    (when (and indent
-              (/= indent (current-indentation)))
-      (beginning-of-line)
-      (let ((bol (point)))
-       (skip-chars-forward " \t")
-       (delete-region bol (point)))
-      (indent-to indent)
-      (when (> (- (point-max) from-end) (point))
-       (goto-char (- (point-max) from-end))))))
+  (let* ((savep (point))
+         (indent (condition-case nil
+                     (save-excursion
+                       (forward-line 0)
+                       (skip-chars-forward " \t")
+                       (if (>= (point) savep) (setq savep nil))
+                       (or (nxml-compute-indent) 0))
+                   (error 0))))
+    (if (not (numberp indent))
+        ;; If something funny is used (e.g. `noindent'), return it.
+        indent
+      (if (< indent 0) (setq indent 0)) ;Just in case.
+      (if savep
+          (save-excursion (indent-line-to indent))
+        (indent-line-to indent)))))
 
 (defun nxml-compute-indent ()
   "Return the indent for the line containing point."


reply via email to

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