xref: /openbsd-src/gnu/usr.bin/cvs/cvs-format.el (revision b6c0222275d7627ee4b3daf0c986f90dee05daa5)
11e72d8d2Sderaadt;; -*- lisp-interaction -*-
21e72d8d2Sderaadt;; -*- emacs-lisp -*-
31e72d8d2Sderaadt;;
4461cc63eStholo;; Set emacs up for editing code using CVS indentation conventions.
5461cc63eStholo;; See HACKING for more on what those conventions are.
6461cc63eStholo;; To use, put in your .emacs:
7461cc63eStholo;;   (load "c-mode")
8461cc63eStholo;;   (load "cvs-format.el")
9461cc63eStholo;; You need to load c-mode first or else when c-mode autoloads it will
10461cc63eStholo;; clobber the settings from cvs-format.el.  Using c-mode-hook perhaps would
11461cc63eStholo;; be a cleaner way to handle that.  Or see below about (set-c-style "BSD").
121e72d8d2Sderaadt;;
13461cc63eStholo;; Credits: Originally from the personal .emacs file of Rich Pixley,
14461cc63eStholo;;      then rich@cygnus.com, circa 1992.  He sez "feel free to copy."
151e72d8d2Sderaadt;;
161e72d8d2Sderaadt
171e72d8d2Sderaadt;;
181e72d8d2Sderaadt;;
191e72d8d2Sderaadt;;	This section sets constants used by c-mode for formating
201e72d8d2Sderaadt;;
211e72d8d2Sderaadt;;
221e72d8d2Sderaadt
231e72d8d2Sderaadt;;  If `c-auto-newline' is non-`nil', newlines are inserted both
241e72d8d2Sderaadt;;before and after braces that you insert, and after colons and semicolons.
251e72d8d2Sderaadt;;Correct C indentation is done on all the lines that are made this way.
261e72d8d2Sderaadt
271e72d8d2Sderaadt(setq c-auto-newline nil)
281e72d8d2Sderaadt
291e72d8d2Sderaadt
301e72d8d2Sderaadt;;*Non-nil means TAB in C mode should always reindent the current line,
311e72d8d2Sderaadt;;regardless of where in the line point is when the TAB command is used.
321e72d8d2Sderaadt;;It might be desirable to set this to nil for CVS, since unlike GNU
331e72d8d2Sderaadt;; CVS often uses comments over to the right separated by TABs.
341e72d8d2Sderaadt;; Depends some on whether you're in the habit of using TAB to
351e72d8d2Sderaadt;; reindent.
361e72d8d2Sderaadt;(setq c-tab-always-indent nil)
371e72d8d2Sderaadt
381e72d8d2Sderaadt;;; It seems to me that
391e72d8d2Sderaadt;;;    `M-x set-c-style BSD RET'
401e72d8d2Sderaadt;;; or
411e72d8d2Sderaadt;;;    (set-c-style "BSD")
421e72d8d2Sderaadt;;; takes care of the indentation parameters correctly.
431e72d8d2Sderaadt
441e72d8d2Sderaadt
451e72d8d2Sderaadt;;  C does not have anything analogous to particular function names for which
461e72d8d2Sderaadt;;special forms of indentation are desirable.  However, it has a different
471e72d8d2Sderaadt;;need for customization facilities: many different styles of C indentation
481e72d8d2Sderaadt;;are in common use.
491e72d8d2Sderaadt;;
501e72d8d2Sderaadt;;  There are six variables you can set to control the style that Emacs C
511e72d8d2Sderaadt;;mode will use.
521e72d8d2Sderaadt;;
531e72d8d2Sderaadt;;`c-indent-level'
541e72d8d2Sderaadt;;     Indentation of C statements within surrounding block.  The surrounding
551e72d8d2Sderaadt;;     block's indentation is the indentation of the line on which the
561e72d8d2Sderaadt;;     open-brace appears.
571e72d8d2Sderaadt
581e72d8d2Sderaadt(setq c-indent-level 4)
591e72d8d2Sderaadt
601e72d8d2Sderaadt;;`c-continued-statement-offset'
611e72d8d2Sderaadt;;     Extra indentation given to a substatement, such as the then-clause of
621e72d8d2Sderaadt;;     an if or body of a while.
631e72d8d2Sderaadt
641e72d8d2Sderaadt(setq c-continued-statement-offset 4)
651e72d8d2Sderaadt
661e72d8d2Sderaadt;;`c-brace-offset'
671e72d8d2Sderaadt;;     Extra indentation for line if it starts with an open brace.
681e72d8d2Sderaadt
691e72d8d2Sderaadt(setq c-brace-offset -4)
701e72d8d2Sderaadt
711e72d8d2Sderaadt;;`c-brace-imaginary-offset'
721e72d8d2Sderaadt;;     An open brace following other text is treated as if it were this far
731e72d8d2Sderaadt;;     to the right of the start of its line.
741e72d8d2Sderaadt
751e72d8d2Sderaadt(setq c-brace-imaginary-offset 0)
761e72d8d2Sderaadt
771e72d8d2Sderaadt;;`c-argdecl-indent'
781e72d8d2Sderaadt;;     Indentation level of declarations of C function arguments.
791e72d8d2Sderaadt
801e72d8d2Sderaadt(setq c-argdecl-indent 4)
811e72d8d2Sderaadt
821e72d8d2Sderaadt;;`c-label-offset'
831e72d8d2Sderaadt;;     Extra indentation for line that is a label, or case or default.
84*b6c02222Stholo;;  This doesn't quite do the right thing for CVS switches, which use the
85*b6c02222Stholo;;    switch (foo)
86*b6c02222Stholo;;    {
87*b6c02222Stholo;;        case 0:
88*b6c02222Stholo;;            break;
89*b6c02222Stholo;;  style.  But if one manually aligns the first case, then the rest
90*b6c02222Stholo;;  should work OK.
911e72d8d2Sderaadt(setq c-label-offset -4)
921e72d8d2Sderaadt
931e72d8d2Sderaadt;;;; eof
94