(defun LaTeX-indent-tabular () "Return indent column for the current tabular-like line." (let* ((beg-pos (car (LaTeX-env-beginning-pos-col))) (beg-col (save-excursion (goto-char beg-pos) (beginning-of-line) (+ (current-indentation) (LaTeX-indent-level-count) (- 2))))) ; Was hard coded elsewhere before me... (let ((tabular-like-end-regex (format "\\\\end{%s}" (regexp-opt (let (out) (mapc (lambda (x) (when (eq (cadr x) 'LaTeX-indent-tabular) (push (car x) out))) LaTeX-indent-environment-list) out))))) (cond ((looking-at tabular-like-end-regex) beg-col) ((looking-at "\\\\\\\\") (+ 4 beg-col)) ((looking-at "&") (+ 4 beg-col)) ;; If I put a newline it's that the line was too long (t (+ 2 (if (and (save-excursion (re-search-backward "\\\\\\\\\\|[^\\]&" beg-pos t)) (= ?& (char-before (match-end 0)))) ;; If a new line is inserted it probably means ;; that the line was too long (+ 2 beg-col) beg-col)))))))