Subject: bug#33794: 26.1; electric-pair-mode breaks auto-newline minor mode of cc-mode

From: Alan Mackenzie <[email-masked]>
Date: Sat, 22 Dec 2018 02:41:43 +0000

Hello, Beatrix.

As maintainer of CC Mode, I earnestly recommend you NOT to follow João's
suggestion.  It will not work, and will waste your time.  Even if it
appears to work, you will end up picking out bugs for an indeterminate
period.

Basically, electric-pair-mode as it is currently built is incompatible
with CC Mode, as I have pointed out here, albeit somewhat
undiplomatically.

I suggest you do nothing until tempers amongst Emacs developers have
cooled down, and hopefully a genuine solution to the bug has been worked
out and implemented.

-- 
Alan Mackenzie (Nuremberg, Germany).

On Sat, Dec 22, 2018 at 02:16:03 +0000, João Távora wrote:
> Hi again Beatrix,

> In the latest version of the patch I am preparing, if you do

>     (add-hook 'c-mode-hook
> 	      (lambda ()
> 		(setq-local electric-layout-rules
> 			    '((?\{ . before})
>                               (?\{ . after)
> 			      (?\{ . after-stay)))))

> You should arive at Allman C-style electric layouts.  So typing
> int main () <spaces> then brace should give you:

> int main ()
> {
>   <cursor here>
> }

> I attach the two patches for convenience, which you can also find in the
> scratch/fix-33794-extend-electric-layout-mode branch.

> João