When using Auctex to type tex files, round bracket ( can't auto-complete for me. But [ and { can do. How can I fix it?

According to introduction of LaTeX-electric-left-right-brace, this variable is set to t. But the problem also appears. Meanwhile, my auctex can't auto-complete \(, \[, \{, \left(, \bigl[, \Bigl\{.

Emacs is new and interesting for me. Please help me solve it. Thanks!

BTW: Is there any way to delete (), [], {} by pairs?

  • I can recommand smartparens. It has LaTeX support and there is pairwise deletion of brackets via sp-unwrap-sexp. – Timm Jul 4 '17 at 20:09
  • Dear Timm, smartparens works for auto-completion of (. But I can't delete () by pairs. My key <backspace> is bound to delete-backward-char and sp-autodelete-pair is t. How can I modify it to enable the automatic deletion of () by pairs? Thanks! – allenryb Jul 5 '17 at 9:59
  • Is smartparens-mode enabled? – Timm Jul 5 '17 at 19:09
  • Thanks! It seems no. At the beginning, I use (add-hook 'LaTeX-mode-hook 'smartparens-mode) and it fails. Then I modify it to (add-hook 'TeX-mode-hook 'smartparens-mode) and it works. I'm confused of LaTex-mode and Tex-mode since reftex is enabled by (add-hook 'LaTeX-mode-hook 'turn-on-reftex). – allenryb Jul 6 '17 at 1:30

If pressing open the curly or square bracket key completes with the closing bracket, you most probably have electric-pair-mode enabled . It is a built-in minor mode. You can see modes that are active in a buffer by pressing C-h m. This mode also removes the closing bracket when there are no internal characters left and you remove the opening bracket.

If the open curly and square brackets work as expected, but the open round bracket do not, you might have some other function bound to it. Check it by pressing C-h k (. By default, it runs function self-insert-command. If it runs something else, find out what mode has done the binding and disable it.

  • Thanks! Yes, you are right. The key is bound to cdlatex. After I turn off it, the auto-completion works in auctex. – allenryb Jul 5 '17 at 10:01
  • Great. If you at some point need to have cdlatex turned on, you can also rebind the '(' globally or for the given major mode to to override the cdlatex binding. – Heikki Jul 5 '17 at 13:04

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.