emacs-devel
[Top][All Lists]
Advanced

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

Indentation in nxml-mode


From: Paul Landes
Subject: Indentation in nxml-mode
Date: Sun, 6 Jun 2010 22:56:18 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

When indenting in Emacs 23.2 nothing happens to the point/cursor
when hitting tab (indent-for-mode) when the line is already at
the correct indentation.  Before, the cursor would move to the
first character of the line and correct the indentation if
necessary (when the cursor was before any non-whitespace).

Is this the correct behavior now and if so, why is it now
different from every/most other modes?  If so, is there some kind
of customization to get it back?  If this is a bug, here's a
proposed fix (although it does have the side effect of NOT
correcting spaces being proceeded by tabs in some cases:

(defun nxml-indent-line ()
  "Indent current line as XML."
  (let ((indent (nxml-compute-indent))
        (from-end (- (point-max) (point))))
    (when indent
      (beginning-of-line)
      (if (= indent (current-indentation))
          (re-search-forward "[\t ]*")
        (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)))))))





reply via email to

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