GNU bug report logs - #18158
Fix extra indent of d-mode "else static if" statements in cc-engine.el

Previous Next

Packages: emacs, cc-mode;

Reported by: Liran Zvibel <liranz <at> gmail.com>

Date: Thu, 31 Jul 2014 17:17:01 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Alan Mackenzie <acm <at> muc.de>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 18158 <at> debbugs.gnu.org, Liran Zvibel <liranz <at> gmail.com>
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
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 <liranz <at> gmail.com> 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 <liranz <at> gmail.com>
> >
> > 	* 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)




This bug report was last modified 4 years and 260 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.