From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <20181221134829.29135.qmail@mail.muc.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1545401472 28926 195.159.176.226 (21 Dec 2018 14:11:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 21 Dec 2018 14:11:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Alan Mackenzie , bea@klebe.blog, 33794@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 21 15:11:08 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gaLW7-0007OA-Aj for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Dec 2018 15:11:07 +0100 Original-Received: from localhost ([::1]:45943 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaLYD-0006B6-N0 for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Dec 2018 09:13:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaLY4-0006A6-08 for bug-gnu-emacs@gnu.org; Fri, 21 Dec 2018 09:13:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gaLXz-0006Fp-FL for bug-gnu-emacs@gnu.org; Fri, 21 Dec 2018 09:13:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52997) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gaLXz-0006FO-Aq; Fri, 21 Dec 2018 09:13:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gaLXy-00042d-5X; Fri, 21 Dec 2018 09:13:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Fri, 21 Dec 2018 14:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33794 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 33794-submit@debbugs.gnu.org id=B33794.154540157515519 (code B ref 33794); Fri, 21 Dec 2018 14:13:02 +0000 Original-Received: (at 33794) by debbugs.gnu.org; 21 Dec 2018 14:12:55 +0000 Original-Received: from localhost ([127.0.0.1]:57255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gaLXr-00042E-2Q for submit@debbugs.gnu.org; Fri, 21 Dec 2018 09:12:55 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:52187) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gaLXp-000423-5n for 33794@debbugs.gnu.org; Fri, 21 Dec 2018 09:12:54 -0500 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id wBLECnP7006885; Fri, 21 Dec 2018 09:12:49 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 5B7A76AAB6; Fri, 21 Dec 2018 09:12:49 -0500 (EST) In-Reply-To: ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Fri, 21 Dec 2018 13:57:21 +0000") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6444=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6444> : inlines <6988> : streams <1807775> : uri <2767939> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:153681 Archived-At: >> 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