GNU bug report logs - #33794
26.1; electric-pair-mode breaks auto-newline minor mode of cc-mode

Previous Next

Packages: emacs, cc-mode;

Reported by: bea <at> klebe.blog

Date: Tue, 18 Dec 2018 17:48:02 UTC

Severity: normal

Found in version 26.1

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #115 received at 33794-done <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: bea <at> klebe.blog
Cc: João Távora <joaotavora <at> gmail.com>,
 33794-done <at> debbugs.gnu.org
Subject: Re: bug#33794: 26.1; electric-pair-mode breaks auto-newline minor
 mode of cc-mode
Date: Tue, 15 Jan 2019 16:10:52 +0000
Hello, Beatrix.

I have committed the patch from two weeks ago (to the Emacs master
branch), and I'm closing the bug as fixed.

-- 
Alan Mackenzie (Nuremberg, Germany).



On Tue, Jan 01, 2019 at 19:27:29 +0000, Alan Mackenzie wrote:
> Hello, Beatrix,

> Happy New Year!

> On Fri, Dec 21, 2018 at 11:00:10 -0500, Beatrix Klebe wrote:
> > What would be ideal, and what I'm looking for, is to get auto-pairing
> > of brackets with braces being placed where they should be
> > automatically and the insertion point getting put in between them at
> > the correct indent level, such as what happens with Visual Studio, or
> > Visual Studio Code, or several other editors with this functionality.
> > Perhaps it is not emacslike to have such behavior be totally
> > automated, but I am used to it and finds it decreases my ordinary
> > levels of frustration when working with verbose and imperative
> > languages. I am currently trying to write some insert specifiers for
> > smartparens to do this, but it is proving more difficult to find an
> > elegant solution than I had expected.

> I think the following patch to CC Mode gives you nearly everything you
> want, if not actually everything.

> It turned out that the amendment didn't require any modification to
> electric-pair-mode, so apologies to João.

> I don't know how much you've explored electric-pair-mode, but if the
> answer is "not very much", can I suggest you try setting
> electric-pair-skip-whitespace to 'chomp?  The following editing pattern
> is then available.  With electric-pair-mode and c-auto-newline mode
> enabled:

> ("|" represents point.)

> At the end of the line

>     if (foo)|
>     foo = bar;

> , type {.  This will give you something like:

>     if (foo)
>       {
>         |
>       }
>     foo = bar;

> .  Type in a statement ending with a semicolon:

>     if (foo)
>       {
>         foo = bar;
> 	|
>       }
>     foo = bar;

> .  Now type in }.  The effect is to "chomp" the space to the next }, and
> CC Mode's auto-newline then inserts an empty line after the brace:

>     if (foo)
>       {
>         foo = bar;
>       }
>     |
>     foo = bar;

> .  So, please try out the patch, and please let us all know how well it
> corresponds with what you were looking for.  Also please let me know
> about any bugs you notice, so that I can fix them.  Thanks for such an
> interesting problem!

> Here's the patch, which should apply cleanly to the emacs-26.1 source:

[ snip patch ].




This bug report was last modified 6 years and 187 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.