1 ;; -*- lisp-interaction -*-
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:
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").
13 ;; Credits: Originally from the personal .emacs file of Rich Pixley,
14 ;; then rich@cygnus.com, circa 1992. He sez "feel free to copy."
19 ;; This section sets constants used by c-mode for formating
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.
27 (setq c-auto-newline nil)
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
36 ;(setq c-tab-always-indent nil)
38 ;;; It seems to me that
39 ;;; `M-x set-c-style BSD RET'
41 ;;; (set-c-style "BSD")
42 ;;; takes care of the indentation parameters correctly.
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
50 ;; There are six variables you can set to control the style that Emacs C
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.
58 (setq c-indent-level 4)
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.
64 (setq c-continued-statement-offset 4)
67 ;; Extra indentation for line if it starts with an open brace.
69 (setq c-brace-offset -4)
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.
75 (setq c-brace-imaginary-offset 0)
78 ;; Indentation level of declarations of C function arguments.
80 (setq c-argdecl-indent 4)
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
89 ;; style. But if one manually aligns the first case, then the rest
91 (setq c-label-offset -4)