Function: reindent-then-newline-and-indent
reindent-then-newline-and-indent is an interactive and byte-compiled
function defined in simple.el.gz.
Signature
(reindent-then-newline-and-indent)
Documentation
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.
Probably introduced at or before Emacs version 24.3.
Key Bindings
Aliases
fortran-indent-new-line (obsolete since 29.1)
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(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))
(electric-indent-mode nil))
;; Be careful to insert the newline before indenting the line.
;; Otherwise, the indentation might be wrong.
(newline)
(save-excursion
(goto-char pos)
;; We are at EOL before the call to indent-according-to-mode, and
;; after it we usually are as well, but not always. We tried to
;; address it with `save-excursion' but that uses a normal marker
;; whereas we need `move after insertion', so we do the save/restore
;; by hand.
(setq pos (copy-marker pos t))
(indent-according-to-mode)
(goto-char pos)
;; Remove the trailing white-space after indentation because
;; indentation may introduce the whitespace.
(delete-horizontal-space t))
(indent-according-to-mode)))