mellon@ZAYANTE.PA.DEC.COM (Ted Lemon) (07/29/89)
I have my c-mode indentation set up as follows: (progn (setq c-indent-level 4) (setq c-continued-statement-offset 4) (setq c-brace-offset -4) (setq c-argdecl-indent 1) (setq c-auto-newline nil)) When I do a ``switch'' in C, emacs indents the case statements incorrectly. Similarly, emacs indents my label statements incorrectly. Sample: switch( foo ) { case bar : farf(); break; case blef : farkle(); break; default : printf( "foo bar!\n" ); } The correct indentation is: switch( foo ) { case bar : farf(); break; case blef : farkle(); break; default : printf( "foo bar!\n" ); } The problem turns out to be quite trivial. c-mode doesn't believe that there can be a space between the label and the colon. The following diff shows the required changes to fix this bug: ------------------------------------------------------------------------------- zayante% diff c-mode-new-somewhat.el /usr/local/emacs/lisp/c-mode.el 315d314 < (skip-chars-forward " \t\n") 406c405 < '(?w ?_ ? ))))) --- > '(?w ?_))))) 433c432 < (looking-at "#\\|/\\*\\|case[ \t\n].*:\\|[a-zA-Z0-9_$]*[ \t\n]*:")) --- > (looking-at "#\\|/\\*\\|case[ \t\n].*:\\|[a-zA-Z0-9_$]*:")) 644d642 < (skip-chars-forward " \t") ------------------------------------------------------------------------------- _MelloN_
rbj@DSYS.NCSL.NIST.GOV (Root Boy Jim) (08/03/89)
? From: mellon@zayante.pa.dec.com (Ted Lemon) ? When I do a ``switch'' in C, emacs indents the case statements ? incorrectly. Similarly, emacs indents my label statements ? incorrectly. Sample: ? switch( foo ) { ? case bar : ? farf(); ? break; ? [rest of example deleted] ? The problem turns out to be quite trivial. c-mode doesn't believe ? that there can be a space between the label and the colon. And neither do I. What, pray tell, prompted this bizarre style? To me, the colon looks like part of a ?: expression. What you do with parentheses is strange as well. Oh, well, I guess it takes all kinds. ? _MelloN_ Root Boy Jim Have GNU, Will Travel.