Function: LaTeX-indent-calculate
LaTeX-indent-calculate is a byte-compiled function defined in
latex.el.
Signature
(LaTeX-indent-calculate &optional FORCE-TYPE)
Documentation
Return the indentation of a line of LaTeX source.
FORCE-TYPE can be used to force the calculation of an inner or
outer indentation in case of a commented line. The symbols
inner and outer are recognized.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/latex.el
(defun LaTeX-indent-calculate (&optional force-type)
"Return the indentation of a line of LaTeX source.
FORCE-TYPE can be used to force the calculation of an inner or
outer indentation in case of a commented line. The symbols
`inner' and `outer' are recognized."
(save-excursion
(LaTeX-back-to-indentation force-type)
(let ((i 0)
(list-length (safe-length docTeX-indent-inner-fixed))
(case-fold-search nil)
entry
found)
(cond ((save-excursion (beginning-of-line) (bobp)) 0)
((and (eq major-mode 'docTeX-mode)
fill-prefix
(TeX-in-line-comment)
(progn
(while (and (< i list-length)
(not found))
(setq entry (nth i docTeX-indent-inner-fixed))
(when (looking-at (nth 0 entry))
(setq found t))
(setq i (1+ i)))
found))
(if (nth 2 entry)
(- (nth 1 entry) (if (integerp comment-padding)
comment-padding
(length comment-padding)))
(nth 1 entry)))
((looking-at (concat (regexp-quote TeX-esc)
"\\(begin\\|end\\){"
(LaTeX-verbatim-regexp t)
"}"))
;; \end{verbatim} must be flush left, otherwise an unwanted
;; empty line appears in LaTeX's output.
0)
((and LaTeX-indent-environment-check
;; Special environments.
(let ((entry (assoc (or LaTeX-current-environment
(LaTeX-current-environment))
LaTeX-indent-environment-list)))
(and entry
(nth 1 entry)
(funcall (nth 1 entry))))))
((looking-at (concat (regexp-quote TeX-esc)
"\\("
LaTeX-end-regexp
"\\)"))
;; Backindent at \end.
(- (LaTeX-indent-calculate-last force-type) LaTeX-indent-level))
((looking-at (concat (regexp-quote TeX-esc) "right\\b"))
;; Backindent at \right.
(- (LaTeX-indent-calculate-last force-type)
LaTeX-left-right-indent-level))
((looking-at (concat (regexp-quote TeX-esc)
"\\("
LaTeX-item-regexp
"\\)"))
;; Items.
(+ (LaTeX-indent-calculate-last force-type) LaTeX-item-indent))
;; Other (La)TeX programming constructs which end
;; something, \fi for example where we backindent:
((looking-at (concat (regexp-quote TeX-esc)
"\\("
LaTeX-indent-end-regexp-local
"\\)"))
(- (LaTeX-indent-calculate-last force-type) LaTeX-indent-level))
;; (La)TeX programming contructs which backindent only the
;; current line, for example \or or \else where we backindent:
((looking-at (concat (regexp-quote TeX-esc)
"\\("
LaTeX-indent-mid-regexp-local
"\\)"))
(- (LaTeX-indent-calculate-last force-type) LaTeX-indent-level))
((memq (char-after) (append
TeX-indent-close-delimiters '(?\})))
;; End brace in the start of the line.
(- (LaTeX-indent-calculate-last force-type)
TeX-brace-indent-level))
(t (LaTeX-indent-calculate-last force-type))))))