home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!warwick!str-ccsun!strath-cs!prlhp1!glenn
- From: glenn@prl.philips.co.uk (Glenn Coombs)
- Newsgroups: gnu.emacs.help
- Subject: Problem with indentation of switch statements in c-mode ?
- Message-ID: <1724@prlhp1.prl.philips.co.uk>
- Date: 3 Sep 92 16:58:20 GMT
- Sender: nntp@prlhp1.prl.philips.co.uk
- Organization: Philips Research Labs, Redhill, England
- Lines: 40
- Nntp-Posting-Host: prsun10j
-
-
- Does anyone know of a way to get the following indentation for
- switch statements in c-mode automatically ?
-
- switch (c) {
- case 1: blah ;
- break ;
- case 2: blah ;
- break ;
- default: blah ;
- break ;
- }
-
- I currently use:
-
- c-indent-level: 4
- c-continued-statement-offset: 4
- c-brace-offset: 0
- c-argdecl-indent: 0
- c-label-offset: 0
-
- which is acceptable. It just means that I have to manually indent
- the lines after the case: bit.
-
- I normally indent things by 4, so the case statement is 4 in from
- the switch. I then need another variable like c-case-offset or
- something that I can set to be the extra amount to indent lines
- by when inside a case statement (9 in this example).
-
- I have tried hacking the code in c-mode.el (specifically the
- functions c-indent-line, calculate-c-indent and electric-c-terminator)
- but have not yet managed to add such a feature successfully - the code
- in calculate-c-indent is not the easiest of things to understand !
-
- Has anyone out there modified c-mode.el so that it allows you
- to have switch statements indented like this ?
- --
-
- -
- Glenn ... glenn@prl.philips.co.uk
-