From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#33794: 26.1; electric-pair-mode breaks auto-newline minor mode of cc-mode Date: 23 Dec 2018 14:48:37 -0000 Organization: muc.de e.V. Message-ID: <20181223144837.85715.qmail__33603.0775601559$1545576501$gmane$org@mail.muc.de> References: NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1545576501 12778 195.159.176.226 (23 Dec 2018 14:48:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 23 Dec 2018 14:48:21 +0000 (UTC) User-Agent: tin/2.4.2-20171224 ("Lochhead") (UNIX) (FreeBSD/11.2-RELEASE-p4 (amd64)) Cc: 33794@debbugs.gnu.org, =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= To: bea@klebe.blog Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 23 15:48:16 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 1gb539-0003D2-DK for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Dec 2018 15:48:15 +0100 Original-Received: from localhost ([::1]:37316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gb55F-00009F-UH for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Dec 2018 09:50:25 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gb551-00006G-Ji for bug-gnu-emacs@gnu.org; Sun, 23 Dec 2018 09:50:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gb53w-0005RA-Bb for bug-gnu-emacs@gnu.org; Sun, 23 Dec 2018 09:49:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56378) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gb53w-0005Qu-5q; Sun, 23 Dec 2018 09:49:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gb53u-0002C5-0d; Sun, 23 Dec 2018 09:49:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sun, 23 Dec 2018 14:49: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.15455765208403 (code B ref 33794); Sun, 23 Dec 2018 14:49:01 +0000 Original-Received: (at 33794) by debbugs.gnu.org; 23 Dec 2018 14:48:40 +0000 Original-Received: from localhost ([127.0.0.1]:60636 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gb53X-0002BS-P2 for submit@debbugs.gnu.org; Sun, 23 Dec 2018 09:48:40 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:15029 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1gb53W-0002BK-N8 for 33794@debbugs.gnu.org; Sun, 23 Dec 2018 09:48:39 -0500 Original-Received: (qmail 85716 invoked by uid 3782); 23 Dec 2018 14:48:37 -0000 In-Reply-To: X-Newsgroups: gnu.emacs.bug 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:153786 Archived-At: Hello again, 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 style > in particular, though it would be nice if these modes specifically did > work together. > 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... I think the following workaround will give you a lot of what you want. I've tried it out only on C Mode, however. The pertinent file is in .../emacs/lisp/progmodes/. Sadly it is only a workaround, since there doesn't seem to be any interface to electric-pair-mode usable by programs. However, it should help, whilst we at Emacs negotiate amongst ourselves. Happy Christmas, if you celebrate it! (And a good time, otherwise!). diff -r 7ec0a318802a cc-cmds.el --- a/cc-cmds.el Thu Dec 20 12:07:55 2018 +0000 +++ b/cc-cmds.el Sun Dec 23 14:34:51 2018 +0000 @@ -721,7 +721,9 @@ ;; Insert the brace. Note that expand-abbrev might reindent ;; the line here if there's a preceding "else" or something. - (self-insert-command (prefix-numeric-value arg)) + (let (post-self-insert-hook) ; the only way to get dependable + ; functionality from self-insert-command. + (self-insert-command (prefix-numeric-value arg))) (when (and c-electric-flag (not literal) (not arg)) (if (not (looking-at "[ \t]*\\\\?$")) @@ -844,6 +846,15 @@ (c-newline-and-indent)) )))) + ;; Emulate `electric-pair-mode'. + (when (and (boundp 'electric-pair-mode) + electric-pair-mode + (eq last-command-event ?{)) + (save-excursion + (newline) + (let ((last-command-event ?})) + (c-electric-brace nil)))) + ;; blink the paren (and (eq (c-last-command-char) ?\}) (not executing-kbd-macro) -- Alan Mackenzie (Nuremberg, Germany).