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