0

electric pairing for () does not work in latex-mode.

I have included regular parentheses () in my electric-pair-pairs list in .emacs. The list also includes [], {}, and "". However, when editing LaTeX documents, pairing of () does not work, only the other electric pairs.

I already checked the variable electric-pair-pairs when in LaTeX mode, but it is unchanged compared to the .emacs definition.

Here is a snippet of my .emacs dealing with electric-pairing

(electric-pair-mode 1) (setq electric-pair-pairs '( (?\" . ?\") (?{ . ?}) (?( . ?)) (?[ . ?])))

I appreciate any help form you guys.

Ulrich

Emacs 25.1.1 on Debian Stretch

3
  • You do have electric-pair-mode enabled? – user16762 Sep 25 '19 at 7:57
  • Welcome to emacs.SE! Could you give more details about how you did change the value of electric-pair-pairs? – JeanPierre Sep 25 '19 at 8:16
  • Thanks for your replies so far. Here is a snippet of my .emacs dealing with electric-pairing (electric-pair-mode 1) (setq electric-pair-pairs '( (?\" . ?\") (?\{ . ?\}) (?( . ?)) (?[ . ?]))) – odefey Sep 26 '19 at 8:34
0

I encountered the same problem and solved it by adding

(setq electric-pair-preserve-balance nil)

It ignores the pairing logic that balances out the number of opening and closing delimiters. I can only guess the reason it works is that there is something specific in the tex file that causes a miscalculation of parentheses balancing. Even without the workaround, the problem does not occur in other tex files, e.g. an empty one.

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.