For some reason electric-pair-mode doesn't work well with AUCTeX: It works for ( and [ but not {. But it used to work.

So I disable electric-pair-mode and use tex-electric-left-right-brace instead. The annoying thing is that when I want to delete (), with electric-pair-mode turned on I can just press backspace once, but with electric-pair-mode turned off I need to press it twice to delete the whole pair. What do I need to do to be able to delete matching parens with a single key stroke?

To summarize, I need auto-closing for (, [, and { in AUCTeX, as well as the ability to easily delete pairs of matching parens.


  • I see the Emacs23 tag here. Emacs24.1 was released more than 2.5 years ago. How long does it take to make the switch? – abo-abo Feb 25 '15 at 11:37
  • I used emacs 24.4 but the tag wiki afraid me and i cannot find a tag emacs24 or some other things better. – seb Feb 25 '15 at 11:49
  • No need for the emacs24.4 tag -- the auctex tag is all you need. – Dan Feb 25 '15 at 12:26
  • 1
    I can not reproduce this behavior in vanilla Emacs 24.4 (started via emacs -Q): When I hit (, [, or { after enabling electric-pair-mode, Emacs correctly inserts a matching delimiter and leaves point after the opening delimiter. If I then hit Backspace, the whole pair gets deleted. So there is a chance that the issue you are having is caused by your personal configuration. Please try to reproduce the problem in emacs -Q and report your findings. We'll take it from there. – itsjeyd Feb 25 '15 at 12:57
  • 1
    @itsjeyd If LaTeX-electric-left-right-brace is on, electric-pair-mode is disabled. – giordano Feb 25 '15 at 14:06

The following two pieces of advice appear to result in the desired behavior:

(defadvice electric-pair-post-self-insert-function
    (around single-electricity activate)
  "If current command is an electric brace command, do nothing."
  (if (not (eq this-command 'LaTeX-insert-left-brace))

(defadvice LaTeX-common-initialization
    (after electric-pair-anyway activate)
  "Re-enable electric-pair-mode."
  (set (make-local-variable 'electric-pair-mode) t))
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.