[comp.emacs] Gnu C-mode indentation

gjditchfield@watrose.UUCP (01/15/87)

I'm using Gnu version 17.64.2 on a vax running BSD4.2. I can't quite
get C-mode to indent the way I want.

What I want is:		What I get is:

fn1(x)			|fn1(x)
    int x;		|    int x;
{			|{
    if (x) {		|    if (x) {
	x = 0;		|        x = 0;
	}		|        }
    }			|    }
main()			|    main()
{			|{
    int asdf = 1;	|    int asdf = 1;
    fn1( asdf);		|    fn1( asdf);
    }			|    }

The scheme is that indentation increases after '{', and decreases after '}'.
The problem is that indentation does not decrease after the '}' that closes a
function (although it does decrease for '}'s inside functions). My .emacs file
contains
	(setq c-indent-level 0)
	(setq c-brace-imaginary-offset 4)
	(setq c-continued-statement-offset 4)
	(setq c-argdecl-indent 4)
	(setq c-label-offset -2)
What have I done wrong?

By the way, does anyone out there have a C++ mode? (It would be just like
C mode, except that ':' is used for things other than labels.)
-- 
Glen Ditchfield                      {watmath,utzoo,ihnp4}!watrose!gjditchfield
Dept of Computer Science, U of Waterloo         (519) 885-1211 x6658
Waterloo, Ontario, Canada
"Flame not, lest thou be singed" - Mr. Protocol

guzzi@uicsrd.CSRD.UIUC.EDU (01/19/87)

> /* Written Jan 15, 1987 by gjditchfield@watrose.UUCP in uicsrd:comp.emacs */
> /* ---------- "Gnu C-mode indentation (and C++)" ---------- */
> I'm using Gnu version 17.64.2 on a vax running BSD4.2. I can't quite
> get C-mode to indent the way I want.
> 
> What I want is:	What I get is:
> 
> fn1(x)		|fn1(x)
>     int x;		|    int x;
> {			|{
>     }			|    }
> main()		|    main()
> {			|{
>     }			|    }
> 
> /* End of text from uicsrd:comp.emacs */
I have noticed the same problem, and I attribute it to a bug in the C
mode.  If you place a ";" after the "}" that closes the function fn1,
then the indentation works correctly.  It doesn't seem to see the "}" as
the end of the function, but needs a ";" to indicate the end.
	      --Mark Guzzi
		University of Illinois at Urbana-Champaign
	        ARPA:	guzzi@uicsrd.csrd.uiuc.edu   
			   guzzi%uicsrd@uiuc.arpa
		CSNET:	guzzi%uicsrd@uiuc 
	        USENET:	{siesmo,ihnp4,cmcl2,pur-ee}!uiucdcs!uicsrd!guzzi