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: João Távora
Subject: Re: [patch] make electric-pair-mode smarter/more useful
Date: Mon, 16 Dec 2013 00:35:59 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

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

Right.

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

I think that the current js-mode rules, when appended to the default
rule I proposed in the latest patch, will mostly supersede, but not
completely, the newline-between-pairs rule.

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

Funny, since I didn't know of that "intention", I appreciated the
`electric-layout-mode' immediately for its potential, but found those
rules really akward.

I personally would prefer that the current rules would *not* be the
default in js-mode, as they are now, or any other mode). They could be
enabled with some function like
`electric-layout-toggle-electric-braces`.

Anyway, the default value should really be the newline-between-pairs
rule, which currently only kicks in when electric-pair-mode is
additionally enabled (btw, should it not?).

The only mode I know where it doesn't make sense is lisp-based-modes
(though probably one can find others). Still, even in lisp one hardly
ever newlines after a opening parens right? And even then, when coupled
with a `chomp' value for `electric-pair-skip-whitespace', it's quite
harmless. And finally, lisp-mode.el, or any other mode where we find it
to be harmful, can simply choose to clear all the rules locally.

FWIW, and from my experience in autopair.el, this rule is probably also
natural for people coming from other editors where the "electric"
behaviour is built-in, namely textmate (and possibly some of its
descendants). So users desperate to get that behaviour can just enable
all three electric modes and be happy 99% of the time.

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

But, if we wanted, we could make it on by default provided the default
rules are not annoying in the vast majority of modes (while the minority
locally sets them).

> From this POV, maybe electric-pair-newline-between-pairs-rule should be
> made into a separate minor mode, indeed.

This is also possible, but overkill IMO. I like the current triad of
electric modes.

João



reply via email to

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