xref: /dflybsd-src/share/misc/dragonfly.el (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marino;;; This function switches C-mode so that it indents stuff according to
2*86d7f5d3SJohn Marino;;; our style(9) which is equivalent to FreeBSD's. Tested with emacs-22.3.
3*86d7f5d3SJohn Marino;;;
4*86d7f5d3SJohn Marino;;; Use "M-x bsd" in a C mode buffer to activate it.
5*86d7f5d3SJohn Marino;;;
6*86d7f5d3SJohn Marino;;; To make this the default, use a line like this, but you can't easily
7*86d7f5d3SJohn Marino;;; switch back to default GNU style, since the old state isn't saved.
8*86d7f5d3SJohn Marino;;;
9*86d7f5d3SJohn Marino;;; (add-hook 'c-mode-common-hook 'bsd)
10*86d7f5d3SJohn Marino;;;
11*86d7f5d3SJohn Marino;;; As long as you don't have this in the c-mode hook you can edit GNU
12*86d7f5d3SJohn Marino;;; and BSD style C sources within one emacs session with no problem.
13*86d7f5d3SJohn Marino;;;
14*86d7f5d3SJohn Marino;;; Posted to FreeBSD's cvs-all by DES (<867ifoaulz.fsf@ds4.des.no>).
15*86d7f5d3SJohn Marino
16*86d7f5d3SJohn Marino(defun bsd ()
17*86d7f5d3SJohn Marino  (interactive)
18*86d7f5d3SJohn Marino  (c-set-style "bsd")
19*86d7f5d3SJohn Marino
20*86d7f5d3SJohn Marino  ;; Basic indent is 8 spaces
21*86d7f5d3SJohn Marino  (setq c-basic-offset 8)
22*86d7f5d3SJohn Marino  (setq tab-width 8)
23*86d7f5d3SJohn Marino
24*86d7f5d3SJohn Marino  ;; Continuation lines are indented 4 spaces
25*86d7f5d3SJohn Marino  (c-set-offset 'arglist-cont 4)
26*86d7f5d3SJohn Marino  (c-set-offset 'arglist-cont-nonempty 4)
27*86d7f5d3SJohn Marino  (c-set-offset 'statement-cont 4)
28*86d7f5d3SJohn Marino  (c-set-offset 'cpp-macro-cont 8)
29*86d7f5d3SJohn Marino
30*86d7f5d3SJohn Marino  ;; Labels are flush to the left
31*86d7f5d3SJohn Marino  (c-set-offset 'label [0])
32*86d7f5d3SJohn Marino
33*86d7f5d3SJohn Marino  ;; Fill column
34*86d7f5d3SJohn Marino  (setq fill-column 74))
35