Function: LaTeX-indent-line

LaTeX-indent-line is an interactive and byte-compiled function defined in latex.el.

Signature

(LaTeX-indent-line)

Documentation

Indent the line containing point, as LaTeX source.

Add LaTeX-indent-level indentation in each \begin{ - \end{ block. Lines starting with an item is given an extra indentation of LaTeX-item-indent.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/latex.el
(defun LaTeX-indent-line ()
  "Indent the line containing point, as LaTeX source.
Add `LaTeX-indent-level' indentation in each \\begin{ - \\end{ block.
Lines starting with an item is given an extra indentation of
`LaTeX-item-indent'."
  (declare (modes LaTeX-mode))
  (interactive)
  (let* ((case-fold-search nil)
         ;; Compute a fill prefix.  Whitespace after the comment
         ;; characters will be disregarded and replaced by
         ;; `comment-padding'.
         (fill-prefix
          (and (TeX-in-commented-line)
               (save-excursion
                 (beginning-of-line)
                 (looking-at
                  (concat "\\([ \t]*" TeX-comment-start-regexp "+\\)+"))
                 (concat (match-string 0) (TeX-comment-padding-string))))))
    (save-excursion
      (cond ((and fill-prefix
                  (eq major-mode 'docTeX-mode)
                  (TeX-in-line-comment))
             ;; If point is in a line comment in `docTeX-mode' we only
             ;; consider the inner indentation.  An exception is when
             ;; we're inside a verbatim environment where we don't
             ;; want to touch the indentation, notably with a
             ;; fill-prefix "% ":
             (unless (member (LaTeX-current-environment)
                             (LaTeX-verbatim-environments))
               (let ((inner-indent (LaTeX-indent-calculate 'inner)))
                 (when (/= (LaTeX-current-indentation 'inner) inner-indent)
                   (LaTeX-indent-inner-do inner-indent)))))
            ((and fill-prefix
                  LaTeX-syntactic-comments)
             ;; In any other case of a comment we have to consider
             ;; outer and inner indentation if we do syntax-aware
             ;; indentation.
             (let ((inner-indent (LaTeX-indent-calculate 'inner))
                   (outer-indent (LaTeX-indent-calculate 'outer)))
               (when (/= (LaTeX-current-indentation 'inner) inner-indent)
                 (LaTeX-indent-inner-do inner-indent))
               (when (/= (LaTeX-current-indentation 'outer) outer-indent)
                 (LaTeX-indent-outer-do outer-indent))))
            (t
             ;; The default is to adapt whitespace before any
             ;; non-whitespace character, i.e. to do outer
             ;; indentation.
             (let ((outer-indent (LaTeX-indent-calculate 'outer)))
               (when (/= (LaTeX-current-indentation 'outer) outer-indent)
                 (LaTeX-indent-outer-do outer-indent))))))
    (when (< (current-column) (save-excursion
                                (LaTeX-back-to-indentation) (current-column)))
      (LaTeX-back-to-indentation))))