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