Function: TeX-brace-count-line

TeX-brace-count-line is a byte-compiled function defined in tex.el.

Signature

(TeX-brace-count-line)

Documentation

Count indent caused by open/closed braces.

In addition to "{" and "}", characters in TeX-indent-open-delimiters and TeX-indent-close-delimiters are also taken into account. Ignore them when they are escaped by "\\". In comments, ignore "{" and "}" but don't ignore additional characters.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-brace-count-line ()
  "Count indent caused by open/closed braces.
In addition to \"{\" and \"}\", characters in
`TeX-indent-open-delimiters' and `TeX-indent-close-delimiters'
are also taken into account.  Ignore them when they are escaped
by \"\\\".  In comments, ignore \"{\" and \"}\" but don't ignore
additional characters."
  (save-excursion
    (let ((count 0) (limit (line-end-position)) char)
      (while (progn
               (skip-chars-forward
                (concat "^{}\\\\"
                        TeX-indent-open-delimiters
                        TeX-indent-close-delimiters)
                limit)
               (when (and (< (point) limit)
                          (not (and (memq (setq char (char-after))
                                          '(?\{ ?\} ?\\))
                                    (TeX-in-comment))))
                 (forward-char)
                 ;; We have to cater for verb-macros with braces and
                 ;; what the function `TeX-verbatim-p' returns dep. on
                 ;; the position of point:
                 ;;       \Verb{\ or { or } are not special}.
                 ;;     nil  <-^^-> t                  t <-^^-> nil
                 (cond ((memq char (append
                                    TeX-indent-open-delimiters
                                    '(?\{)))
                        ;; Point is one char after `{', if char before
                        ;; isn't inside a verb macro, then the brace
                        ;; is a real delimiter and we increase
                        ;; `count', otherwise not:
                        (if (TeX-verbatim-p (1- (point)))
                            t
                          (setq count (+ count TeX-brace-indent-level))))
                       ((memq char (append
                                    TeX-indent-close-delimiters
                                    '(?\})))
                        ;; Point if one char after `}', if not inside
                        ;; a verb macro, this is a real delimiter and
                        ;; we decrease `count', otherwise not:
                        (if (TeX-verbatim-p)
                            t
                          (setq count (- count TeX-brace-indent-level))))
                       ((eq char ?\\)
                        ;; Point is one char-after after `\', so check
                        ;; if the char before point is inside a verb
                        ;; macro:
                        (when (< (point) limit)
                          (unless (TeX-verbatim-p (1- (point)))
                            (forward-char))
                          t))))))
      count)))