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: Stefan Monnier
Subject: Re: [patch] make electric-pair-mode smarter/more useful
Date: Sat, 14 Dec 2013 20:39:57 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

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

The value which seems most useful for javascript.

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

If there can be various competing choices, then indeed we have a problem.
The intention of electric-layout-mode is that it should more or less
(tho in a naive way) insert the newlines for you if you just
naively/sequentially type in the code.

There might indeed be various options as to "when" to insert the
newlines as well as "where".

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

I don't understand the question: if there are cases where
electric-layout-mode would insert a newline but the user doesn't want
it, indeed the user will be annoyed.  I think in general there's no way
to be sure this never happens, other than turning off
electric-layout-mode.  Same happens for the suggested
electric-pair-newline-between-pairs-rule.

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

{ not followed by a newline are rare in C, but they do happen, indeed.
E.g. for "enum"s or for immediate values of structs/arrays.  So, indeed,
for those cases electric-layout-mode will be annoying.

For that reason electric-layout-mode is off by default, and I haven't
heard anyone argue to enable it by default.

>From this POV, maybe electric-pair-newline-between-pairs-rule should be
made into a separate minor mode, indeed.  It will reduce your use of RET
much less than electric-layout-mode but it's less likely to be annoying.
Less gain and less pain.


        Stefan



reply via email to

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