From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#18158: Fix extra indent of d-mode "else static if" statements in cc-engine.el Date: Sun, 26 Jan 2020 15:29:31 +0000 Message-ID: <20200126152931.GA4829@ACM> References: <87blqxq12q.fsf@marxist.se> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="10629"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 18158@debbugs.gnu.org, Liran Zvibel To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 26 16:30:21 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ivjrh-0002jl-HP for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jan 2020 16:30:21 +0100 Original-Received: from localhost ([::1]:34610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ivjrg-0004tG-M0 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jan 2020 10:30:20 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51838) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ivjrQ-0004sC-JY for bug-gnu-emacs@gnu.org; Sun, 26 Jan 2020 10:30:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ivjrP-0007b3-AW for bug-gnu-emacs@gnu.org; Sun, 26 Jan 2020 10:30:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ivjrP-0007aU-6h; Sun, 26 Jan 2020 10:30:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ivjrP-0002a7-38; Sun, 26 Jan 2020 10:30: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, 26 Jan 2020 15:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18158 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: patch Original-Received: via spool by 18158-submit@debbugs.gnu.org id=B18158.15800525779864 (code B ref 18158); Sun, 26 Jan 2020 15:30:02 +0000 Original-Received: (at 18158) by debbugs.gnu.org; 26 Jan 2020 15:29:37 +0000 Original-Received: from localhost ([127.0.0.1]:57291 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ivjqz-0002Z2-H3 for submit@debbugs.gnu.org; Sun, 26 Jan 2020 10:29:37 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:57531 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1ivjqx-0002Yt-OE for 18158@debbugs.gnu.org; Sun, 26 Jan 2020 10:29:36 -0500 Original-Received: (qmail 35759 invoked by uid 3782); 26 Jan 2020 15:29:33 -0000 Original-Received: from acm.muc.de (p4FE153B6.dip0.t-ipconnect.de [79.225.83.182]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 26 Jan 2020 16:29:31 +0100 Original-Received: (qmail 18631 invoked by uid 1000); 26 Jan 2020 15:29:31 -0000 Content-Disposition: inline In-Reply-To: <87blqxq12q.fsf@marxist.se> 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:175303 Archived-At: Hello, Stefan and Liran. On Mon, Jan 20, 2020 at 22:18:05 +0100, Stefan Kangas wrote: > Hi Alan, > Could you please help review also the below patch for cc-engine.el? I'm less than happy about putting a special purpose workaround into a critical bit of CC Mode (c-add-stmt-syntax) without having even seen the problem. Liran, if you're still there and still interested, could you possibly supply me with a sample of D source code containing the problem? I would hope to be able to enhance CC Mode to handle it in a more general and useful fashion. > Thanks in advance. > Best regards, > Stefan Kangas -- Alan Mackenzie (Nuremberg, Germany). > Liran Zvibel writes: > > Hi, > > > > I’m not subscribed to this list (or to -devel), so please reply also to my email when responding. > > > > Thanks, > > Liran Zvibel. > > > > ** Description: > > > > Fix extra indent of d-mode  "else static if" statements  > > > > The D programming language has a notion of “static if” conditionals. > > The d-mode (from https://github.com/Emacs-D-Mode-Maintainers/Emacs-D-Mode.git) > > requires cc-mode. > > When writing “else static if” blocks, the code block is getting indented twice, > > as well as all future “else static if”s that come later. This is very annoying. > > > > This simple fix was originally suggested here:  > > http://www.prowiki.org/wiki4d/wiki.cgi?EditorSupport/EmacsDMode/ElseStaticIf > > The simple fix treats "static if" same as “if" that comes right after an “else". > > > > I fixed it locally in my installed emacs long time ago, but today when downloading  > > trunk to test 24.4 I was disappointed it was not already fixed by someone else.  > > I know many D programmers that apply this change locally to their installed Emacs,  > > hopefully not for long. > > > > ** ChangeLog > > > > 2014-07-31 Liran Zvibel > > > > * Small cc-mode change to make sure “else static if” does not get  > > deeper and deeper indentation the same way that “else if” is treated  > > for d-mode that requires cc-mode. > > > > ** The patch : > > > > === modified file 'lisp/progmodes/cc-engine.el' > > *** lisp/progmodes/cc-engine.el 2014-06-29 11:26:47 +0000 > > --- lisp/progmodes/cc-engine.el 2014-07-31 15:22:15 +0000 > > *************** comment at the start of cc-engine.el for > > *** 9053,9061 **** > >       (looking-at "else\\>[^_]") > >       (save-excursion > >         (goto-char old-pos) > > !       (looking-at "if\\>[^_]"))) > >   ;; Special case to avoid deeper and deeper indentation > > ! ;; of "else if" clauses. > >   ) > > > >         ((and (not stop-at-boi-only) > > --- 9053,9062 ---- > >       (looking-at "else\\>[^_]") > >       (save-excursion > >         (goto-char old-pos) > > !                                (or (looking-at "if\\>[^_]") > > !   (looking-at "static\\>[^_]")))) > >   ;; Special case to avoid deeper and deeper indentation > > ! ;; of "else if"/"static else if" clauses. > >   ) > > > >         ((and (not stop-at-boi-only)