emacs-devel
[Top][All Lists]
Advanced

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

Re: [patch] make electric-pair-mode smarter/more useful


From: Dmitry Gutov
Subject: Re: [patch] make electric-pair-mode smarter/more useful
Date: Sat, 14 Dec 2013 18:56:06 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1

On 14.12.2013 17:18, Stefan Monnier wrote:
I'm not completely sure I understand our question w.r.t the code you
quoted: the code you quoted adds the behavior globally, so it obviously
wouldn't be set on a per-mode basis.

Yes, but if it's set via electric-layout-rules, to what value will this variable be set in e.g. js-mode?

If it'll include what's there currently, '((?\; . after) (?\{ . after) (?\} . before)), then to get the desired behavior I described previously (NOT to insert a newline after I just typed `{', or any other character), I'd have to modify it again in js-mode-hook.

IOW, turning on electric-layout-mode would turn on all electric-layout-related behaviors defined for a given major mode. Are we willing to remove electric newlines after `;', `{' and `}', by default, from any major mode where one of those might conceivably be followed by some character other than newline?

Speaking of cc-mode, I don't really program in C (though I'd like to continue learning it at some point), but if I did, I'm not sure I'd want the electric-layout-mode behavior there, but electric-pair-newline-between-pairs-rule would be useful.

For example, like described previously, if I want js-mode to only insert
electric newlines when I press return, will I have to modify
electric-layout-rules in js-mode-hook, and do so for any other mode I use
that sets this variable?

I think setting it on a per-mode basis would be OK, but it wouldn't be
set by the user but instead by the major mode, based on the usual coding
style used for that mode.  E.g. we wouldn't set it in Lisp, but we'd set
it in js-mode.

Yes. And similarly, if we have a separate minor mode, it will be disabled (maybe via some -inhibit variable) by some major modes.



reply via email to

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