[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: electric-pair-mode as a minor mode?

From: Stefan Monnier
Subject: Re: electric-pair-mode as a minor mode?
Date: Thu, 26 Mar 2015 22:18:33 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> I'd like to disable electric-pair-mode in certain buffers.
> Probably the most important example is the minibuffer.

> Incremental searching with eletric-pairing is frustrating as opposed to
> being helpful as the search is "temporarily broken" as soon as the pair
> is inserted.

[ I'm curious to know more about those isearch and minibuffer cases
  because I haven't bumped into them.  Not that it makes any difference
  to the following.  ]

> I made eletric-pair-mode nil/buffer-local in the hooks that I need,
> but somehow I feel electric-pair-mode should be a regular minor mode.

Hmm, electric-pair-mode *is* a regular minor mode.  Maybe you mean
that it should be buffer-local because you'd only want to enable it in
a few specific major modes?

We could very well define an electric-pair-local-mode, like we did with
electric-indent-local-mode.  In the mean time, you should be able to
hack it with something like:

   (electric-pair-mode 1)
   (setq-default electric-pair-mode nil)

   (add-hook 'foo-mode-hook
             (lambda () (setq-local electric-pair-mode t)))

> When editing regular text, as opposed to code, I also occasionally
> switch it off because I find it distracting.

I think I would agree that it should be less eager in text modes
(i.e. in modes where syntax-ppss gives notoriously unreliable results).
I'm pretty sure that can be done fairly easily, by fixing a few
concrete cases.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]