summaryrefslogtreecommitdiff
path: root/lisp/nxml
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2010-06-13 21:43:11 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2010-06-13 21:43:11 -0400
commitb263a4c43f492f50e0201c6656033b1e54224d54 (patch)
tree20f84e6da2a33c4cf4371ade1d1746018122941d /lisp/nxml
parent8c3a217f33026350610772132291a62ed866b1bf (diff)
downloademacs-b263a4c43f492f50e0201c6656033b1e54224d54.tar.gz
* lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Fixes: debbugs:6412
Diffstat (limited to 'lisp/nxml')
-rw-r--r--lisp/nxml/nxml-mode.el26
1 files changed, 15 insertions, 11 deletions
diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index 101b2585186..b428d8bf224 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el
@@ -1370,17 +1370,21 @@ of the inserted start-tag or nil if none was inserted."
(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."