Function: default-indent-new-line

default-indent-new-line is an interactive and byte-compiled function defined in simple.el.gz.

Signature

(default-indent-new-line &optional SOFT FORCE)

Documentation

Break line at point and indent.

If a comment syntax is defined, call comment-line-break-function.

The inserted newline is marked hard if variable use-hard-newlines(var)/use-hard-newlines(fun) is true, unless optional argument SOFT is non-nil.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun default-indent-new-line (&optional soft force)
  "Break line at point and indent.
If a comment syntax is defined, call `comment-line-break-function'.

The inserted newline is marked hard if variable `use-hard-newlines' is true,
unless optional argument SOFT is non-nil."
  (interactive (list nil t))
  (if comment-start
      ;; Force breaking the line when called interactively.
      (if force
          (let ((comment-auto-fill-only-comments nil))
            (funcall comment-line-break-function soft))
        (funcall comment-line-break-function soft))
    ;; Insert the newline before removing empty space so that markers
    ;; get preserved better.
    (if soft (insert-and-inherit ?\n) (newline 1))
    (save-excursion (forward-char -1) (delete-horizontal-space))
    (delete-horizontal-space)

    (if (and fill-prefix (not adaptive-fill-mode))
	;; Blindly trust a non-adaptive fill-prefix.
	(progn
	  (indent-to-left-margin)
	  (insert-before-markers-and-inherit fill-prefix))

      (cond
       ;; If there's an adaptive prefix, use it unless we're inside
       ;; a comment and the prefix is not a comment starter.
       (fill-prefix
	(indent-to-left-margin)
	(insert-and-inherit fill-prefix))
       ;; If we're not inside a comment, just try to indent.
       (t (indent-according-to-mode))))))