1 1.4 christos ;; $NetBSD: NetBSD.el,v 1.4 2007/09/22 16:17:52 christos Exp $ 2 1.4 christos 3 1.1 wiz (defconst netbsd-knf-style 4 1.1 wiz '( 5 1.1 wiz ;; (c-auto-newline . nil) 6 1.1 wiz ;; default indentation level 7 1.1 wiz (c-basic-offset . 8) 8 1.1 wiz ;; in which column to add backslashes when macroizing a region 9 1.1 wiz (c-backslash-column . 78) 10 1.1 wiz ;; automatically compact brace-else(if)-brace on one line and 11 1.1 wiz ;; semi-colon after closing struct brace 12 1.1 wiz (c-cleanup-list . (brace-else-brace 13 1.1 wiz brace-elseif-brace 14 1.1 wiz defun-close-semi)) 15 1.1 wiz ;; do not indent lines containing only start-of-comment more than default 16 1.1 wiz (c-comment-only-line-offset . 0) 17 1.1 wiz ;; start new lines after braces 18 1.1 wiz ;; default is: before and after (for all other cases) 19 1.1 wiz (c-hanging-braces-alist . ((defun-open . (before after)) 20 1.1 wiz (defun-close . (before after)) 21 1.1 wiz (block-open . (after)) 22 1.1 wiz (block-close . c-snug-do-while) 23 1.1 wiz (substatement-open . after) 24 1.1 wiz (statement-case-open . nil) 25 1.1 wiz (brace-list-open . after) 26 1.1 wiz (brace-list-close . nil) 27 1.1 wiz )) 28 1.1 wiz ;; where to put newlines around colons 29 1.1 wiz (c-hanging-colons-alist . (quote ((label after) 30 1.1 wiz (case-label after)))) 31 1.1 wiz ;; indent comments syntactically 32 1.1 wiz (c-indent-comments-syntactically-p . t) 33 1.1 wiz ;; no spaces needed before a label 34 1.1 wiz ;; (c-label-minimum-indentation . 0) 35 1.1 wiz ;; define offsets for some code parts 36 1.1 wiz (c-offsets-alist . ((arglist-cont-nonempty . 4) 37 1.1 wiz (block-open . 0) 38 1.1 wiz ;; (block-open . -) 39 1.1 wiz (brace-list-entry . 8) 40 1.1 wiz (brace-list-open . 8) 41 1.1 wiz (brace-list-close . 0) 42 1.1 wiz (knr-argdecl . 0) 43 1.1 wiz (knr-argdecl-intro . +) 44 1.1 wiz (label . -) 45 1.1 wiz (member-init-intro . ++) 46 1.1 wiz (statement-cont . 4) 47 1.1 wiz (substatement-open . 0) 48 1.1 wiz (case-label . 0))) 49 1.1 wiz ;; XXX: undocumented. Recognize KNR style? 50 1.1 wiz (c-recognize-knr-p . t) 51 1.1 wiz ;; indent line when pressing tab, instead of a plain tab character 52 1.1 wiz (c-tab-always-indent . t) 53 1.1 wiz ;; use TABs for indentation, not spaces 54 1.1 wiz (indent-tabs-mode . t) 55 1.1 wiz ;; set default tab width to 8 56 1.1 wiz (tab-width . 8) 57 1.1 wiz ) 58 1.1 wiz "NetBSD KNF Style") 59 1.1 wiz 60 1.2 christos (defun knf-write-contents-hook () 61 1.2 christos (if (and (string-equal c-indentation-style "netbsd knf") 62 1.4 christos (require 'whitespace nil t)) 63 1.2 christos (whitespace-cleanup)) 64 1.2 christos nil ;; XXX - make sure we return nil or the file will not be written. 65 1.2 christos ) 66 1.2 christos 67 1.1 wiz (defun knf-c-mode-hook () 68 1.1 wiz ;; Add style and set it for current buffer 69 1.1 wiz (c-add-style "NetBSD KNF" netbsd-knf-style t) 70 1.1 wiz ;; useful, but not necessary for the mode 71 1.1 wiz ;; give syntactic information in message buffer 72 1.1 wiz ;;(setq c-echo-syntactic-information-p t) 73 1.1 wiz ;; automatic newlines after special characters 74 1.1 wiz (setq c-toggle-auto-state 1) 75 1.1 wiz ;; delete all connected whitespace when pressing delete 76 1.1 wiz (setq c-toggle-hungry-state 1) 77 1.1 wiz ;; auto-indent new lines 78 1.1 wiz (define-key c-mode-base-map "\C-m" 'newline-and-indent) 79 1.2 christos ;; cleanup whitespace when saving 80 1.2 christos (add-hook 'write-contents-hooks 'knf-write-contents-hook) 81 1.1 wiz ) 82 1.1 wiz 83 1.1 wiz (add-hook 'c-mode-hook 'knf-c-mode-hook) 84