[Top][All Lists]

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

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

From: Yuri D'Elia
Subject: Re: electric-pair-mode as a minor mode?
Date: Fri, 27 Mar 2015 09:04:34 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.5.0

On 03/27/2015 03:18 AM, Stefan Monnier wrote:
>> 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.  ]

It's just a nuisance. If I'm performing an isearch, looking for
"foo(bar", the matching will, of course, stop to find anything at
"foo()" just before I kill the closing paren.

There's no harm done, but I realized I never truly had to close a paren
in isearch before, I just RET-ed away. And given that the cursor
momentarily goes back to the starting point, I find it distracting since
I'm scanning visually the buffer...

>> 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?

[ just terminology here, isn't anything which is not global-minor
  automatically buffer local? ]

> 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:

If it's not a big issue, I would definitely do it.

I'm actually thinking that's something I would selectively turn on in
the base 'prog-mode-hook myself.

>    (electric-pair-mode 1)
>    (setq-default electric-pair-mode nil)
>    (add-hook 'foo-mode-hook
>              (lambda () (setq-local electric-pair-mode t)))

That's basically what I'm doing, but in reverse at the moment (I turn it
off selectively).

reply via email to

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