home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / emacs / help / 3989 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  1.6 KB

  1. Path: sparky!uunet!pipex!warwick!str-ccsun!strath-cs!prlhp1!glenn
  2. From: glenn@prl.philips.co.uk (Glenn Coombs)
  3. Newsgroups: gnu.emacs.help
  4. Subject: Problem with indentation of switch statements in c-mode ?
  5. Message-ID: <1724@prlhp1.prl.philips.co.uk>
  6. Date: 3 Sep 92 16:58:20 GMT
  7. Sender: nntp@prlhp1.prl.philips.co.uk
  8. Organization: Philips Research Labs, Redhill, England
  9. Lines: 40
  10. Nntp-Posting-Host: prsun10j
  11.  
  12.  
  13. Does anyone know of a way to get the following indentation for
  14. switch statements in c-mode automatically ?
  15.  
  16. switch (c) {
  17.     case 1:  blah ;
  18.              break ;
  19.     case 2:  blah ;
  20.              break ;
  21.     default: blah ;
  22.              break ;
  23. }
  24.  
  25. I currently use:
  26.  
  27. c-indent-level:               4
  28. c-continued-statement-offset: 4
  29. c-brace-offset:               0
  30. c-argdecl-indent:             0
  31. c-label-offset:               0
  32.  
  33. which is acceptable.  It just means that I have to manually indent
  34. the lines after the case: bit.
  35.  
  36. I normally indent things by 4, so the case statement is 4 in from
  37. the switch.  I then need another variable like c-case-offset or
  38. something that I can set to be the extra amount to indent lines
  39. by when inside a case statement (9 in this example).
  40.  
  41. I have tried hacking the code in c-mode.el (specifically the
  42. functions c-indent-line, calculate-c-indent and electric-c-terminator)
  43. but have not yet managed to add such a feature successfully - the code
  44. in calculate-c-indent is not the easiest of things to understand !
  45.  
  46. Has anyone out there modified c-mode.el so that it allows you
  47. to have switch statements indented like this ?
  48. -- 
  49.  
  50. -
  51. Glenn   ...   glenn@prl.philips.co.uk
  52.