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: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: João Távora <joaotavora <at> gmail.com>
Cc: Alan Mackenzie <acm <at> muc.de>, bea <at> klebe.blog, 33794 <at> debbugs.gnu.org
Subject: bug#33794: 26.1; electric-pair-mode breaks auto-newline minor mode of cc-mode
Date: Fri, 21 Dec 2018 09:12:49 -0500
>> 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.

Since it's done from post-self-insert-hook, it's done at the very end of
inserting { so I'm not sure what you mean by "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.

I think you meant "due to the way CC-Mode hooks itself into the }
processing, ..." ;-)

>> 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?

Talking about brutal: how could electric-pair-mode run whichever command
is bound to } without taking the risk of running a much more brutal
command than one that inserts a character?

> FWIW, I think cc-mode should rather use post-self-insert-hook instead
> of redefining commands for keys whose expected behaviour is
> (with minor variations presumably covered by abundant hookage)
> self-insertion.

IIRC it should be able to just use electric-layout-mode for that (tho
maybe electric-layout's featureset doesn't currently cover 100% that of
CC-mode's auto-newline, in which case it would be nice to extend
electric-layout accordingly).

For things like electric-pair, electric-indent, and electric-layout to
work correctly together, they need to agree on some convention.

Note that CC-mode can also side-step that convention and use `insert`
instead of self-insert-command.


        Stefan




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.