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: Tue, 15 Jan 2019 16:10:52 +0000 Message-ID: <20190115161052.GA30619@ACM> References: <20181221134829.29135.qmail@mail.muc.de> <20190101192729.GA22315@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1547569214 10112 195.159.176.226 (15 Jan 2019 16:20:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 15 Jan 2019 16:20:14 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) Cc: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , 33794-done@debbugs.gnu.org To: bea@klebe.blog Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jan 15 17:20:09 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gjRRh-0002Tf-AV for geb-bug-gnu-emacs@m.gmane.org; Tue, 15 Jan 2019 17:20:09 +0100 Original-Received: from localhost ([127.0.0.1]:36952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjRTo-0003Ki-Dn for geb-bug-gnu-emacs@m.gmane.org; Tue, 15 Jan 2019 11:22:20 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjRTd-0003I0-9r for bug-gnu-emacs@gnu.org; Tue, 15 Jan 2019 11:22:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjRTb-0002nB-5C for bug-gnu-emacs@gnu.org; Tue, 15 Jan 2019 11:22:09 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:32790) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gjRTW-0002jK-S1; Tue, 15 Jan 2019 11:22:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gjRTW-0007U2-Ge; Tue, 15 Jan 2019 11:22:02 -0500 Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Tue, 15 Jan 2019 16:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 33794 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Mail-Followup-To: 33794@debbugs.gnu.org, acm@muc.de, bea@klebe.blog Original-Received: via spool by 33794-done@debbugs.gnu.org id=D33794.154756929828726 (code D ref 33794); Tue, 15 Jan 2019 16:22:02 +0000 Original-Received: (at 33794-done) by debbugs.gnu.org; 15 Jan 2019 16:21:38 +0000 Original-Received: from localhost ([127.0.0.1]:60304 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gjRT8-0007TG-2A for submit@debbugs.gnu.org; Tue, 15 Jan 2019 11:21:38 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:24362 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1gjRT6-0007T5-1o for 33794-done@debbugs.gnu.org; Tue, 15 Jan 2019 11:21:36 -0500 Original-Received: (qmail 3374 invoked by uid 3782); 15 Jan 2019 16:21:33 -0000 Original-Received: from acm.muc.de (p2E5D5BED.dip0.t-ipconnect.de [46.93.91.237]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 15 Jan 2019 17:21:32 +0100 Original-Received: (qmail 30643 invoked by uid 1000); 15 Jan 2019 16:10:52 -0000 Content-Disposition: inline In-Reply-To: <20190101192729.GA22315@ACM> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@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: 209.51.188.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:154450 Archived-At: Hello, Beatrix. I have committed the patch from two weeks ago (to the Emacs master branch), and I'm closing the bug as fixed. -- Alan Mackenzie (Nuremberg, Germany). On Tue, Jan 01, 2019 at 19:27:29 +0000, Alan Mackenzie wrote: > Hello, Beatrix, > Happy New Year! > On Fri, Dec 21, 2018 at 11:00:10 -0500, Beatrix Klebe wrote: > > What would be ideal, and what I'm looking for, is to get auto-pairing > > of brackets with braces being placed where they should be > > automatically and the insertion point getting put in between them at > > the correct indent level, such as what happens with Visual Studio, or > > Visual Studio Code, or several other editors with this functionality. > > Perhaps it is not emacslike to have such behavior be totally > > automated, but I am used to it and finds it decreases my ordinary > > levels of frustration when working with verbose and imperative > > languages. I am currently trying to write some insert specifiers for > > smartparens to do this, but it is proving more difficult to find an > > elegant solution than I had expected. > I think the following patch to CC Mode gives you nearly everything you > want, if not actually everything. > It turned out that the amendment didn't require any modification to > electric-pair-mode, so apologies to Joćo. > I don't know how much you've explored electric-pair-mode, but if the > answer is "not very much", can I suggest you try setting > electric-pair-skip-whitespace to 'chomp? The following editing pattern > is then available. With electric-pair-mode and c-auto-newline mode > enabled: > ("|" represents point.) > At the end of the line > if (foo)| > foo = bar; > , type {. This will give you something like: > if (foo) > { > | > } > foo = bar; > . Type in a statement ending with a semicolon: > if (foo) > { > foo = bar; > | > } > foo = bar; > . Now type in }. The effect is to "chomp" the space to the next }, and > CC Mode's auto-newline then inserts an empty line after the brace: > if (foo) > { > foo = bar; > } > | > foo = bar; > . So, please try out the patch, and please let us all know how well it > corresponds with what you were looking for. Also please let me know > about any bugs you notice, so that I can fix them. Thanks for such an > interesting problem! > Here's the patch, which should apply cleanly to the emacs-26.1 source: [ snip patch ].