When using 'electric braces' in Visual Studio, MonoDevelop and other
tools, I like the behaviour where the closing brace is auto-detected.
(In the example, I show the insertion point as a bar)
If I type
if (|
the screen shows
if (|)
I then key in my test expression, say isFalse (or whatever):
if (isFalse|)
At this point, Visual studio and MonoDevelop realise that the next ')'
key I hit, really represents the ')' which is already there. It does not
add an additional ')' :
if (isFalse)|
But in Emacs, currently using cperl, but also when using c#-mode, or
IIRC ruby-mode, emacs does add an additional ')' which leads to
following erroneous code:
if (isFalse)|)
I am pretty cinfident that Emacs can mimic the VS/MD behaviour. I just
did not find yet how to request it from good old Emacs.
Thanks in advance for any suggestions,
Guido
--
Expect a letter from a friend who will ask a favor of you.
> When using 'electric braces' in Visual Studio, MonoDevelop and other
> tools, I like the behaviour where the closing brace is auto-detected.
> (In the example, I show the insertion point as a bar)
> If I type
> if (|
> the screen shows
> if (|)
> I then key in my test expression, say isFalse (or whatever):
> if (isFalse|)
> At this point, Visual studio and MonoDevelop realise that the next ')'
> key I hit, really represents the ')' which is already there. It does not
> add an additional ')' :
> if (isFalse)|
> But in Emacs, currently using cperl, but also when using c#-mode, or
> IIRC ruby-mode, emacs does add an additional ')' which leads to
> following erroneous code:
> if (isFalse)|)
> I am pretty cinfident that Emacs can mimic the VS/MD behaviour. I just
> did not find yet how to request it from good old Emacs.
> Thanks in advance for any suggestions,
paredit-mode does that, but perhaps some more since it's for lisp
editing. You'll want to extract parts of it.
* is now hosted at github.com/capitaomorte/autopair
* out of the box, does a bit more than electric-pair-mode, like
deleting 0-width paren pairs when backspacing and helping to keep the
buffer balanced (for example typing 3 opening "{" consecutively makes
"{{{}}}" instead of electric pair's "{{{}".
* can be customized to behave differently in comments and strings,
pair characters, and more
I'm quite positively surprised how electric-pair-mode has evolved
though, but still find it awkward in how it sometimes pairs and
sometimes doesn't.