Last update August 27, 2007

Editor Support / Emacs DMode /
Else Static If



If you're using the emacs D mode, you may have noticed that indentation of "else static if" clauses isn't handled properly.

There's a quick fix if you have access to the cc-mode files that come with your emacs installation.

This was tested with CC-mode 5.31.4. (see M-x c-version to get your version).

So to the main emacs lisp directory. And find lisp/progmodes/cc-engine.el. Open it and search for this comment:

	;; Special case to avoid deeper and deeper indentation
	;; of "else if" clauses.

Add an 'or' clause to that block of code that checks for 'static' following else. Should now look basically like this:

		       ((and (eq step-type 'up)
			     (>= (point) old-boi)
			     (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" clauses. // or "else static if"
			)

Now M-x byte-compile-file the file, and restart emacs. Should be fixed now.

FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: August 27, 2007 7:37 (diff))