I use Emacs 24.3.1 and AUCTeX. I switched on the electric-pair-mode in LaTeX-buffers. The only time I would really like to disable it in the minibuffer while inserting math-mode parentheses via the \left and \right commands. For these commands in Emacs, I use \ as TeX-electric macro.

My question would be if there is an easy way to disable the electric-pair-mode inside the minibuffer? Or do I maybe use an inconvenient setup for putting parentheses into equations?

  • The echo area is for output, not input. Do you mean the minibuffer? If so, please edit. – Drew Jul 1 '15 at 15:24
  • You say that "The only time I would really like to disable it is while inserting math-mode parenthesis via the \left and \right commands." Did you mean enable? – elethan Dec 28 '15 at 17:14
  • I would like to disable the electric pairing, when I enter the minibuffer after inserting \left inside the ordinary latex-mode buffer. – jjokella Dec 28 '15 at 19:22

Here is a trick that I learned from this answer to only use electric-pair-mode with specifically whitelisted modes:

(defvar my-electic-pair-modes '(python-mode org-mode))

(defun my-inhibit-electric-pair-mode (char)
  (not (member major-mode my-electic-pair-modes)))

(setq electric-pair-inhibit-predicate #'my-inhibit-electric-pair-mode)

Then you can add any mode that you want to use electric-pair-mode for to my-electric-pair-modes.

I have tested this, and it removes the annoyance of having parens pair in the minibuffer. In your case you can replace python-mode with latex-mode or whatever modes you want.

  • 1
    I accepted your solution - it worked well for my problem: Since the minibuffer has its own major-mode, electric pairs are disabled by default. Additionally, I feel like I have better control over the electric-pair-mode through implementing the list of allowed modes like you suggested - thanks. – jjokella Dec 28 '15 at 19:32

To specifically disable electric-pair-mode in the minibuffer change elethan's example to use the minibufferp function. Below is the relevant part from my Emacs configuration:

;; Enable smart paring

(defun pvj/inhibit-electric-pair-mode (char)

(setq electric-pair-inhibit-predicate #'pvj/inhibit-electric-pair-mode)

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.