117721Speter;; -*- lisp-interaction -*- 217721Speter;; -*- emacs-lisp -*- 317721Speter;; 425839Speter;; Set emacs up for editing code using CVS indentation conventions. 525839Speter;; See HACKING for more on what those conventions are. 625839Speter;; To use, put in your .emacs: 725839Speter;; (load "c-mode") 825839Speter;; (load "cvs-format.el") 925839Speter;; You need to load c-mode first or else when c-mode autoloads it will 1025839Speter;; clobber the settings from cvs-format.el. Using c-mode-hook perhaps would 1125839Speter;; be a cleaner way to handle that. Or see below about (set-c-style "BSD"). 1217721Speter;; 1325839Speter;; Credits: Originally from the personal .emacs file of Rich Pixley, 1425839Speter;; then rich@cygnus.com, circa 1992. He sez "feel free to copy." 1517721Speter;; 1617721Speter 1717721Speter;; 1817721Speter;; 1917721Speter;; This section sets constants used by c-mode for formating 2017721Speter;; 2117721Speter;; 2217721Speter 2317721Speter;; If `c-auto-newline' is non-`nil', newlines are inserted both 2417721Speter;;before and after braces that you insert, and after colons and semicolons. 2517721Speter;;Correct C indentation is done on all the lines that are made this way. 2617721Speter 2717721Speter(setq c-auto-newline nil) 2817721Speter 2917721Speter 3017721Speter;;*Non-nil means TAB in C mode should always reindent the current line, 3117721Speter;;regardless of where in the line point is when the TAB command is used. 3217721Speter;;It might be desirable to set this to nil for CVS, since unlike GNU 3317721Speter;; CVS often uses comments over to the right separated by TABs. 3417721Speter;; Depends some on whether you're in the habit of using TAB to 3517721Speter;; reindent. 3617721Speter;(setq c-tab-always-indent nil) 3717721Speter 3817721Speter;;; It seems to me that 3917721Speter;;; `M-x set-c-style BSD RET' 4017721Speter;;; or 4117721Speter;;; (set-c-style "BSD") 4217721Speter;;; takes care of the indentation parameters correctly. 4317721Speter 4417721Speter 4517721Speter;; C does not have anything analogous to particular function names for which 4617721Speter;;special forms of indentation are desirable. However, it has a different 4717721Speter;;need for customization facilities: many different styles of C indentation 4817721Speter;;are in common use. 4917721Speter;; 5017721Speter;; There are six variables you can set to control the style that Emacs C 5117721Speter;;mode will use. 5217721Speter;; 5317721Speter;;`c-indent-level' 5417721Speter;; Indentation of C statements within surrounding block. The surrounding 5517721Speter;; block's indentation is the indentation of the line on which the 5617721Speter;; open-brace appears. 5717721Speter 5817721Speter(setq c-indent-level 4) 5917721Speter 6017721Speter;;`c-continued-statement-offset' 6117721Speter;; Extra indentation given to a substatement, such as the then-clause of 6217721Speter;; an if or body of a while. 6317721Speter 6417721Speter(setq c-continued-statement-offset 4) 6517721Speter 6617721Speter;;`c-brace-offset' 6717721Speter;; Extra indentation for line if it starts with an open brace. 6817721Speter 6917721Speter(setq c-brace-offset -4) 7017721Speter 7117721Speter;;`c-brace-imaginary-offset' 7217721Speter;; An open brace following other text is treated as if it were this far 7317721Speter;; to the right of the start of its line. 7417721Speter 7517721Speter(setq c-brace-imaginary-offset 0) 7617721Speter 7717721Speter;;`c-argdecl-indent' 7817721Speter;; Indentation level of declarations of C function arguments. 7917721Speter 8017721Speter(setq c-argdecl-indent 4) 8117721Speter 8217721Speter;;`c-label-offset' 8317721Speter;; Extra indentation for line that is a label, or case or default. 8425839Speter;; This doesn't quite do the right thing for CVS switches, which use the 8525839Speter;; switch (foo) 8625839Speter;; { 8725839Speter;; case 0: 8825839Speter;; break; 8925839Speter;; style. But if one manually aligns the first case, then the rest 9025839Speter;; should work OK. 9117721Speter(setq c-label-offset -4) 9217721Speter 9317721Speter;;;; eof 94