Subject: bug#47936: AucTeX and electric-pair-mode

From: Tassilo Horn <[email-masked]>
Date: Wed, 21 Apr 2021 21:54:57 +0200

Philip Kaludercic <[email-masked]> writes:

Hi Philip,

> an annoyance I have with auctex is it's interaction with
> electric-pair-mode. If both LaTeX-electric-left-right-brace and
> electric-pair-mode are enabled, typing '(' inserts "())", because both
> AucTeX and the electric function insert a closing parentheses. I still
> want to keep LaTeX-electric-left-right-brace enabled, because it
> handles TeX-specific parentheses (\{, \left <something>, ...) better.

Ok, makes sense.

> The attached patch would propose a solution that respects
> electric-pair-mode and doesn't insert an extra closing pair if
> enabled.

> @@ -2979,6 +2979,8 @@ is nil, consult user which brace should be used."
>      (if rmacro
>          (insert TeX-esc rmacro))
>      (cond
> +     ((and (string= (char-to-string last-command-event) lbrace)
> +           electric-pair-mode))
>       ((and TeX-arg-right-insert-p rbrace)
>        (insert rbrace))
>       (rmacro

LGTM, I've applied it with slight modifications and a ChangeLog style
commit message following our/Emacs conventions.

Thanks a lot, Philip!

Bye,
Tassilo