Emacs electric-pair-mode disable specific pairs

Viewed 328

I am using electric-pair-mode in org-mode with org-tempo, and so I would like to tell electric-pair-mode not to act on angle brackets < and > any longer.

Otherwise it messes up the template expansion of org-tempo. Two things are getting in the way: (1) For every opening <, it automatically adds the >; (2) When a region is active and I type <, it puts the < and > around that region and de-activates the region, preventing org-tempo from properly acting on that region.

How can I define a hook for org-mode that tells electric-pair-mode to stop treating angle brackets as pairs (but otherwise remain fully functional)?

Thanks for your help,

HPF

1 Answers

Thanks, the inhibit-predicate did the trick. I now use the following hook in my .emacs file:

(add-hook 'org-mode-hook (lambda ()
           (setq-local electric-pair-inhibit-predicate
                   `(lambda (c)
                  (if (char-equal c ?<) t (,electric-pair-inhibit-predicate c))))))
Related