Function: LaTeX-insert-left-brace-electric
LaTeX-insert-left-brace-electric is a byte-compiled function defined
in latex.el.
Signature
(LaTeX-insert-left-brace-electric BRACE)
Documentation
Insert typed left BRACE and a corresponding right brace.
BRACE should be a character. See LaTeX-insert-left-brace for
allowed BRACE values.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/latex.el
(defun LaTeX-insert-left-brace-electric (brace)
"Insert typed left BRACE and a corresponding right brace.
BRACE should be a character. See `LaTeX-insert-left-brace' for
allowed BRACE values."
(when (and (TeX-active-mark) (> (point) (mark)))
(exchange-point-and-mark))
(let ((lbrace (char-to-string brace)) lmacro skip-p)
;; Use `insert' rather than `self-insert-command' so that
;; unexpected side effects from `post-self-insert-hook',
;; e.g. `electric-pair-mode', won't mess up the following
;; outcomes. (bug#47936)
(insert brace)
(save-excursion
(backward-char)
;; The brace "{" is exceptional in two aspects.
;; 1. "\{" should be considered as a single brace
;; like "(" and "[".
;; 2. "\left{" is nonsense while "\left\{" and
;; "\left(" are not.
(if (string= lbrace TeX-grop)
;; If "{" follows "\", set lbrace to "\{".
(if (TeX-escaped-p)
(progn
(backward-char)
(setq lbrace (concat TeX-esc TeX-grop)))
;; Otherwise, don't search for left macros.
(setq skip-p t)))
(unless skip-p
;; Obtain the name of preceding left macro, if any,
;; such as "left", "bigl" etc.
(setq lmacro (LaTeX--find-preceding-left-macro-name))))
(let ((TeX-arg-right-insert-p t)
;; "{" and "}" are paired temporally so that typing
;; a single "{" should insert a pair "{}".
(TeX-braces-association
(cons (cons TeX-grop TeX-grcl) TeX-braces-association)))
(save-excursion
(if (TeX-active-mark)
(goto-char (mark)))
(LaTeX-insert-corresponding-right-macro-and-brace
lmacro lbrace)))))