- (+ (if (and (looking-at "\\\\begin *{\\([^\n}]+\\)")
- (member (match-string 1)
- latex-noindent-environments))
- 0 tex-indent-basic)
- indent (latex-find-indent 'virtual))))
- ;; We're now at the "beginning" of a line.
- ((not (and (not virtual) (eq (char-after) ?\\)))
- ;; Nothing particular here: just keep the same indentation.
- (+ indent (current-column)))
- ;; We're now looking at a macro call.
- ((looking-at tex-indent-item-re)
- ;; Indenting relative to an item, have to re-add the outdenting.
- (+ indent (current-column) tex-indent-item))
- (t
- (let ((col (current-column)))
- (if (or (not (eq (char-syntax (or (char-after pos) ?\s)) ?\())
- ;; Can't be an arg if there's an empty line inbetween.
- (save-excursion (re-search-forward "^[ \t]*$" pos t)))
- ;; If the first char was not an open-paren, there's
- ;; a risk that this is really not an argument to the
- ;; macro at all.
- (+ indent col)
- (forward-sexp 1)
- (if (< (line-end-position)
- (save-excursion (forward-comment (point-max))
- (point)))
- ;; we're indenting the first argument.
- (min (current-column) (+ tex-indent-arg col))
- (skip-syntax-forward " ")
- (current-column))))))))))
+ (if (and (not tex-indent-allhanging)
+ (save-excursion
+ ;; Make sure we're an argument to a macro and
+ ;; that the macro is at the beginning of a line.
+ (condition-case nil
+ (progn
+ (while (eq (char-syntax (char-after)) ?\()
+ (forward-sexp -1))
+ (and (eq (char-syntax (char-after)) ?/)
+ (progn (skip-chars-backward " \t&")
+ (bolp))))
+ (scan-error nil)))
+ (> pos (progn (latex-down-list)
+ (forward-comment (point-max))
+ (point))))
+ ;; Align with the first element after the open-paren.
+ (current-column)
+ ;; We're the first element after a hanging brace.
+ (goto-char up-list-pos)
+ (+ (if (and (looking-at "\\\\begin *{\\([^\n}]+\\)")
+ (member (match-string 1)
+ latex-noindent-environments))
+ 0 tex-indent-basic)
+ indent (latex-find-indent 'virtual))))
+ ;; We're now at the "beginning" of a line.
+ ((not (and (not virtual) (eq (char-after) ?\\)))
+ ;; Nothing particular here: just keep the same indentation.
+ (+ indent (current-column)))
+ ;; We're now looking at a macro call.
+ ((looking-at tex-indent-item-re)
+ ;; Indenting relative to an item, have to re-add the outdenting.
+ (+ indent (current-column) tex-indent-item))
+ (t
+ (let ((col (current-column)))
+ (if (or (not (eq (char-syntax (or (char-after pos) ?\s)) ?\())
+ ;; Can't be an arg if there's an empty line inbetween.
+ (save-excursion (re-search-forward "^[ \t]*$" pos t)))
+ ;; If the first char was not an open-paren, there's
+ ;; a risk that this is really not an argument to the
+ ;; macro at all.
+ (+ indent col)
+ (forward-sexp 1)
+ (if (< (line-end-position)
+ (save-excursion (forward-comment (point-max))
+ (point)))
+ ;; we're indenting the first argument.
+ (min (current-column) (+ tex-indent-arg col))
+ (skip-syntax-forward " ")
+ (current-column)))))))))))