[Top][All Lists]

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

reindent-then-newline-and-indent doesn't indent properly in emacs 22.1

From: nuxdoors
Subject: reindent-then-newline-and-indent doesn't indent properly in emacs 22.1
Date: Sat, 13 Oct 2007 01:02:09 +0200
User-agent: Icedove (X11/20070607)

Hi, In GNU Emacs 22.1:

reindent-then-newline-and-indent doesn't indent properly.

The command currently calls delete-horizontal-space after indenting the
line, which in effect deletes the re-indentation since at that very
moment the point is at the beginning of the text. If you swap the order
of the delete-horizontal-space and indent-according-to-mode functions it
then works as intended, like this :

(defun reindent-then-newline-and-indent ()
  "Reindent current line, insert newline, then indent the new line.
Indentation of both lines is done according to the current major mode,
which means calling the current value of `indent-line-function'.
In programming language modes, this is the same as TAB.
In some text modes, where TAB inserts a tab, this indents to the
column specified by the function `current-left-margin'."
  (interactive "*")
  (let ((pos (point)))
    ;; Be careful to insert the newline before indenting the line.
    ;; Otherwise, the indentation might be wrong.
      (goto-char pos)
      (delete-horizontal-space t)


reply via email to

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