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

Previous Next

Packages: cc-mode, emacs;

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


View this message in rfc822 format

From: Alan Mackenzie <acm <at> muc.de>
To: bea <at> klebe.blog
Cc: 33794 <at> debbugs.gnu.org, João Távora <joaotavora <at> gmail.com>
Subject: bug#33794: 26.1; electric-pair-mode breaks auto-newline minor mode of cc-mode
Date: 21 Dec 2018 13:48:29 -0000
Hello, Beatrix.

In article <mailman.5894.1545155289.1284.bug-gnu-emacs <at> gnu.org> you wrote:
> When using cc-mode, turning on electric-pair-mode causes the
> auto-newline minor mode to stop inserting newlines where expected. This
> is relevant to the formatting of C# code with the Allman/BSD brace style
> in particular, though it would be nice if these modes specifically did
> work together.

Yes.  What is happening, from the viewpoint of CC Mode, is that on
inserting a {, electric-pair-mode is prematurely inserting its }, before
the processing for the { is complete.  Also, due to the way } gets
inserted, the CC Mode processing for the } isn't done at all.

@João: I think electric pair mode is intended to simulate the manual
insertion of a matching paren, etc., when a paren, etc., is typed.

Would it therefore be possible, rather than having a crude insertion on
post-self-insert-hook, to use something like post-command-hook to allow
the insertion of the { first to complete?  Then, rather than using the
brutal self-insert-command for } in electric-pair--insert, use the
command to which the key } is bound?  This should allow CC Mode's
auto-newline facility to work, and also more closely simulate the manual
insertion of the closing delimiter.

> In GNU Emacs 26.1 (build 1, x86_64-apple-darwin14.5.0, NS
> appkit-1348.17 Version 10.10.5 (Build 14F2511))
>  of 2018-05-30 built on builder10-10.porkrind.org
> Windowing system distributor 'Apple', version 10.3.1671
> Recent messages:
> Saving file /Users/bea/.emacs.d/lisp/dotnet.el...
> Wrote /Users/bea/.emacs.d/lisp/dotnet.el
> ; expected
> Undo!
> ; expected
> Undo! [2 times]
> ; expected
> Auto-saving...
> ; expected [2 times]
> Making completion list...

-- 
Alan Mackenzie (Nuremberg, Germany).





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.