Function: LaTeX-hanging-ampersand-position
LaTeX-hanging-ampersand-position is a byte-compiled function defined
in latex.el.
Signature
(LaTeX-hanging-ampersand-position &optional POS COL)
Documentation
Return indent column for a hanging ampersand (that is, ^\s-*&).
When you know the position of the beginning of the current environment and indent of its line, supply them as optional arguments POS and COL for efficiency.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/latex.el
(defun LaTeX-hanging-ampersand-position (&optional pos col)
"Return indent column for a hanging ampersand (that is, ^\\s-*&).
When you know the position of the beginning of the current
environment and indent of its line, supply them as optional
arguments POS and COL for efficiency."
(cl-destructuring-bind
(beg-pos . beg-col)
(if pos
(cons pos col)
(LaTeX-env-beginning-pos-indent))
(let ((cur-pos (point)))
(save-excursion
(if (and (search-backward "\\\\" beg-pos t)
;; Give up if the found "\\" belongs to an inner env.
(= beg-pos
(save-excursion
(LaTeX-find-matching-begin)
(point))))
;; FIXME: This `how-many' fails to count correctly if
;; there is an inner env with "&" but without "\\", e.g.
;; \begin{pmatrix}
;; a & b
;; \end{pmatrix}
(let ((cur-idx (how-many "[^\\]&" (point) cur-pos)))
(goto-char beg-pos)
;; FIXME: This regex search fails if there is an inner
;; env with "&" in it.
(if (re-search-forward "[^\\]&" cur-pos t (+ 1 cur-idx))
(- (current-column) 1)
;; If the above searchs fails, i.e. no "&" found,
;; (- (current-column) 1) returns -1, which is wrong.
;; So we use a fallback (+ 2 beg-col) whenever this
;; happens:
(+ 2 beg-col)))
(+ 2 beg-col))))))