I expected the following code would toggle electric-pair-local-mode
every time I toggle LaTeX-math-mode
(CTRL+C ~
in LaTeX-mode
). It only works one way meaning it does turn on the electric pair mode locally after I have entered the math mode but then Emacs stays in this mode even though I disable the math mode.
(add-hook 'LaTeX-math-mode-hook 'electric-pair-local-mode)
I tried things like (setq electric-pair-local-mode -1)
but evaluating this expression does not make any expected effect meaning Emacs still uses electric pair mode.
I tried to search for similar solutions and it seems checking mode and setting +1
or -1
or t
and nil
works for other modes but this one. I might be missing something regarding the electric mode and I would appreciate any help. Thanks.