1;; -*- lisp-interaction -*- 2;; -*- emacs-lisp -*- 3;; 4;; Set emacs up for editing code using CVS indentation conventions. 5;; See HACKING for more on what those conventions are. 6;; To use, put in your .emacs: 7;; (load "c-mode") 8;; (load "cvs-format.el") 9;; You need to load c-mode first or else when c-mode autoloads it will 10;; clobber the settings from cvs-format.el. Using c-mode-hook perhaps would 11;; be a cleaner way to handle that. Or see below about (set-c-style "BSD"). 12;; 13;; Credits: Originally from the personal .emacs file of Rich Pixley, 14;; then rich@cygnus.com, circa 1992. He sez "feel free to copy." 15;; 16 17;; 18;; 19;; This section sets constants used by c-mode for formating 20;; 21;; 22 23;; If `c-auto-newline' is non-`nil', newlines are inserted both 24;;before and after braces that you insert, and after colons and semicolons. 25;;Correct C indentation is done on all the lines that are made this way. 26 27(setq c-auto-newline nil) 28 29 30;;*Non-nil means TAB in C mode should always reindent the current line, 31;;regardless of where in the line point is when the TAB command is used. 32;;It might be desirable to set this to nil for CVS, since unlike GNU 33;; CVS often uses comments over to the right separated by TABs. 34;; Depends some on whether you're in the habit of using TAB to 35;; reindent. 36;(setq c-tab-always-indent nil) 37 38;;; It seems to me that 39;;; `M-x set-c-style BSD RET' 40;;; or 41;;; (set-c-style "BSD") 42;;; takes care of the indentation parameters correctly. 43 44 45;; C does not have anything analogous to particular function names for which 46;;special forms of indentation are desirable. However, it has a different 47;;need for customization facilities: many different styles of C indentation 48;;are in common use. 49;; 50;; There are six variables you can set to control the style that Emacs C 51;;mode will use. 52;; 53;;`c-indent-level' 54;; Indentation of C statements within surrounding block. The surrounding 55;; block's indentation is the indentation of the line on which the 56;; open-brace appears. 57 58(setq c-indent-level 4) 59 60;;`c-continued-statement-offset' 61;; Extra indentation given to a substatement, such as the then-clause of 62;; an if or body of a while. 63 64(setq c-continued-statement-offset 4) 65 66;;`c-brace-offset' 67;; Extra indentation for line if it starts with an open brace. 68 69(setq c-brace-offset -4) 70 71;;`c-brace-imaginary-offset' 72;; An open brace following other text is treated as if it were this far 73;; to the right of the start of its line. 74 75(setq c-brace-imaginary-offset 0) 76 77;;`c-argdecl-indent' 78;; Indentation level of declarations of C function arguments. 79 80(setq c-argdecl-indent 4) 81 82;;`c-label-offset' 83;; Extra indentation for line that is a label, or case or default. 84;; This doesn't quite do the right thing for CVS switches, which use the 85;; switch (foo) 86;; { 87;; case 0: 88;; break; 89;; style. But if one manually aligns the first case, then the rest 90;; should work OK. 91(setq c-label-offset -4) 92 93;;;; eof 94