GNU bug report logs - #42319
28.0.50; c-mode issue with electric-pair-mode

Previous Next

Package: emacs;

Reported by: Ergus <spacibba <at> aol.com>

Date: Sat, 11 Jul 2020 08:31:01 UTC

Severity: normal

Found in version 28.0.50

Full log


Message #8 received at 42319 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Ergus <spacibba <at> aol.com>
Cc: 42319 <at> debbugs.gnu.org, acm <at> muc.de
Subject: Re: bug#42319: 28.0.50; c-mode issue with electric-pair-mode
Date: 11 Jul 2020 10:26:53 -0000
Hello, Ergus.

In article <mailman.82.1594456263.2306.bug-gnu-emacs <at> gnu.org> you wrote:
> In c-mode there is an issue of adding some extra spaces in
> electric-pair-mode after class definitions.

> For example

> emacs -Q main.cxx
> M-x electric-pair-mode
> M-x c-toggle-auto-newline
> and then insert:

> class A {

> you should get: (# means the cursor)

> class A
> {
>  #
> }

> now insert } and then you get

> class A
> {
>  
> }
>  #

> instead of:

> class A
> {
>  
> }
> #

This happens because of the missing semicolon after the class.  CC Mode
indents the otherwise empty line as a 'topmost-intro-cont line, since it
appears still to be within the class.  One workaround for this is to
configure CC Mode not to insert a newline after this particular type of
brace.  For example

(push '(class-close before) c-hanging-braces-alist)

, to try it out (it's a buffer local variable).

> The problem is actually worst if defun-close-semi is in c-cleanup-list
> because it doesn't work.

That surprises me.  It works for me, here.  What happens/fails to happen
in these circumstances?

> I need to remove the extra spaces first to make it work.

That indeed feels like a bug.  Could you perhaps post your CC Mode
configuration (generated by C-c C-b), please, which should help me to
reproduce the bug.

> In GNU Emacs 28.0.50 (build 12, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars)
> of 2020-07-10 built on ergus
> Repository revision: 7caf570662e41dd7cb90efaf8a335918cf1ac0da
> Repository branch: master
> System Description: Debian GNU/Linux 10 (buster)

[ .... ]

> Major mode: C++//la

> Minor modes in effect:
>  electric-pair-mode: t
>  tooltip-mode: t
>  global-eldoc-mode: t
>  electric-indent-mode: t
>  mouse-wheel-mode: t
>  tool-bar-mode: t
>  menu-bar-mode: t
>  file-name-shadow-mode: t
>  global-font-lock-mode: t
>  font-lock-mode: t
>  auto-composition-mode: t
>  auto-encryption-mode: t
>  auto-compression-mode: t
>  line-number-mode: t
>  transient-mark-mode: t
>  abbrev-mode: t

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).





This bug report was last modified 4 years and 338 days ago.

Previous Next


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