From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= 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 13:57:21 +0000 Message-ID: References: <20181221134829.29135.qmail@mail.muc.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000f4bfee057d88a04c" X-Trace: blaine.gmane.org 1545400566 21883 195.159.176.226 (21 Dec 2018 13:56:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 21 Dec 2018 13:56:06 +0000 (UTC) Cc: bea@klebe.blog, 33794@debbugs.gnu.org, Stefan Monnier To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 21 14:56:01 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 1gaLHV-0005Xt-Lo for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Dec 2018 14:56:01 +0100 Original-Received: from localhost ([::1]:45855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaLJc-0000SX-9F for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Dec 2018 08:58:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaLJW-0000SG-1y for bug-gnu-emacs@gnu.org; Fri, 21 Dec 2018 08:58:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gaLJV-0003wP-5N for bug-gnu-emacs@gnu.org; Fri, 21 Dec 2018 08:58:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52991) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gaLJS-0003v8-2t; Fri, 21 Dec 2018 08:58:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gaLJS-0003PW-0H; Fri, 21 Dec 2018 08:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Fri, 21 Dec 2018 13:58:01 +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.154540066013074 (code B ref 33794); Fri, 21 Dec 2018 13:58:01 +0000 Original-Received: (at 33794) by debbugs.gnu.org; 21 Dec 2018 13:57:40 +0000 Original-Received: from localhost ([127.0.0.1]:57249 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gaLJ5-0003Oo-NC for submit@debbugs.gnu.org; Fri, 21 Dec 2018 08:57:39 -0500 Original-Received: from mail-qk1-f175.google.com ([209.85.222.175]:33140) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gaLJ4-0003OZ-IS for 33794@debbugs.gnu.org; Fri, 21 Dec 2018 08:57:38 -0500 Original-Received: by mail-qk1-f175.google.com with SMTP id o89so3112940qko.0 for <33794@debbugs.gnu.org>; Fri, 21 Dec 2018 05:57:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MG27Gzo1pD9ih49gTqkRksZO2BowmN74MMU8xx2C4BA=; b=K4oRug7cETke4/7oaiyhw6p2Vw2OY1y1H7g+6+oXiUJ5wsS1OuwzRHJS8CHuKnWPxW QjSG8DoqSHW92kHBeRtuZkTKsAhbkL6fqAoIUc4OkvghpYLsc1eU77wl/P3NEF34DRhX Hejv7c8ywTSQXfZeTEAGvorL8oGW/bedZdyNu92qxI0jWfJVuS9UEBL1Vo9e7bogtlMU hkQNQ+JY6Goi0L8+OXQdqEKXw7AHraOmwUmKMnq7g3BlJjVXgyK617Mye06Q69dS7xE2 hbczJauErGgPCEh+vhoPo1ScVhPrTTu3jiMR7QF+KDpzb59JDOD5miNtfATBDRfjrO0h qLcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MG27Gzo1pD9ih49gTqkRksZO2BowmN74MMU8xx2C4BA=; b=M5BtSU0QOGt104WHZ7F4Gu4qitHQtLBAS1mJGMZdHoI4WNILTlup3+ia9RbOqxv1k9 OJHu/Ok6SERArzp7ngdeiFTaj61KmDhc2OkDsvrvjaH/rq9hx0B/fwrAqqn5ls0ULC5e fTIX/0WiHE7L38bFDcNyirDwOAcrzHeFdp+UW+pdeN8JlSROkDmiRko93N4jBEMNXyw6 cvvfnvBDR1TYhuRmIA/6LDsZK+3+fe4X21pdgPsu099OZ+K/WjtuyQaZJiyxsvUxXkIn 7qW8EeWqogzUUsNF5Y72A0l5xtexthxES65cRqi1TLOlMh4ZaYmmEM4al2gMov3/vt9+ IWUQ== X-Gm-Message-State: AJcUukdTqSUR/W+pIiuuwJXjpiyusKVhpwj+T9HmYxdKcZteLLYMmo5u bWyLK/cPt/0pp8MYIrqMeSGb3tlADktON4K5+B0= X-Google-Smtp-Source: ALg8bN7MkH3LaJZkwmQl0QecklVoMHN6RJNA+NORfZA3bUH80jJSKstO5jiytQUhN0lKKkDZPUpfl4GyK28/aTR5Mes= X-Received: by 2002:a37:5e85:: with SMTP id s127mr2305455qkb.234.1545400652970; Fri, 21 Dec 2018 05:57:32 -0800 (PST) In-Reply-To: <20181221134829.29135.qmail@mail.muc.de> 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:153680 Archived-At: --000000000000f4bfee057d88a04c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 21, 2018 at 1:48 PM Alan Mackenzie wrote: > Hello, Beatrix. > > In article 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 styl= e > > 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=C3=A3o: 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. I don't know. We better ask Stefan (CC'ed) who I believe designed the original strategy of inserting closing delimiters in the previous electric-pair-mode. That didn't change in my redesign. 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. If you place your specific cc-mode processing late enough in the hook then its insertion will be "complete" for all practical purposes. Jo=C3=A3o --000000000000f4bfee057d88a04c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Dec 21, 2018 at 1:48 PM Alan Mackenzie <acm@muc.de> wrote:
Hello, Beatrix.

In article <mailman.5894.1545155289.1284.bug-gnu-emacs@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. Thi= s
> is relevant to the formatting of C# code with the Allman/BSD brace sty= le
> in particular, though it would be nice if these modes specifically did=
> work together.

Yes.=C2=A0 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.=C2=A0 Also, due to the way } gets
inserted, the CC Mode processing for the } isn't done at all.

@Jo=C3=A3o: 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?=C2=A0 Then, rather than using the=
brutal self-insert-command for } in electric-pair--insert, use the
command to which the key } is bound?=C2=A0 This should allow CC Mode's<= br> auto-newline facility to work, and also more closely simulate the manual insertion of the closing delimiter.

I don&#= 39;t know.=C2=A0 We better ask Stefan (CC'ed) who I believe designed th= e
original strategy of inserting closing delimiters in the p= revious
electric-pair-mode.=20 That didn't change in my redesign.

FWIW, I thi= nk cc-mode should rather use post-self-insert-hook instead
o= f redefining commands for keys whose expected behaviour is
(w= ith minor variations presumably covered by abundant hookage)
= self-insertion.=C2=A0 If you place your specific cc-mode processing late
enough in the hook then its insertion will be "complete&q= uot; for all
practical purposes.

Jo= =C3=A3o



--000000000000f4bfee057d88a04c--