Mats Lidell | 30cd644 | 2003-01-20 13:00:32 +0000 | [diff] [blame] | 1 | ;;;; Emacs Lisp help for writing rockbox code. ;;;; |
| 2 | ;;;; $Id$ |
| 3 | |
| 4 | ;;; The rockbox hacker's C conventions. |
| 5 | |
| 6 | ;;; After loading this file and added the mode-hook you can in C |
| 7 | ;;; files, put something like this to use the rockbox style |
| 8 | ;;; automatically: |
| 9 | ;; |
| 10 | ;; /* ----------------------------------------------------------------- |
| 11 | ;; * local variables: |
Daniel Stenberg | a239bb2 | 2007-01-24 15:32:39 +0000 | [diff] [blame] | 12 | ;; * eval: (c-set-style "rockbox") |
Mats Lidell | 30cd644 | 2003-01-20 13:00:32 +0000 | [diff] [blame] | 13 | ;; * end: |
| 14 | ;; */ |
| 15 | ;; |
| 16 | |
| 17 | (defconst rockbox-c-style |
| 18 | '((c-basic-offset . 4) |
| 19 | (c-comment-only-line-offset . 0) |
| 20 | (c-hanging-braces-alist . ((substatement-open before after))) |
| 21 | (c-offsets-alist . ((topmost-intro . 0) |
| 22 | (topmost-intro-cont . 0) |
| 23 | (substatement . +) |
| 24 | (substatement-open . 0) |
| 25 | (statement-case-intro . +) |
| 26 | (statement-case-open . 0) |
Mats Lidell | 18aa3f2 | 2003-01-20 13:26:16 +0000 | [diff] [blame] | 27 | (case-label . +) |
Mats Lidell | 30cd644 | 2003-01-20 13:00:32 +0000 | [diff] [blame] | 28 | )) |
| 29 | ) |
| 30 | "Rockbox C Programming Style") |
| 31 | |
| 32 | ;; Customizations for all of c-mode, c++-mode, and objc-mode |
| 33 | (defun rockbox-c-mode-common-hook () |
| 34 | "Rockbox C mode hook" |
| 35 | ;; add rockbox style and set it for the current buffer |
| 36 | (c-add-style "rockbox" rockbox-c-style t) |
| 37 | (setq tab-width 8 |
| 38 | indent-tabs-mode nil ; Use spaces. Not tabs. |
| 39 | comment-column 40 |
| 40 | c-font-lock-extra-types (append '("bool")) |
| 41 | ) |
Mats Lidell | 30cd644 | 2003-01-20 13:00:32 +0000 | [diff] [blame] | 42 | (define-key c-mode-base-map "\C-m" 'newline-and-indent) |
| 43 | (define-key c-mode-base-map "\M-q" 'c-fill-paragraph) |
Mats Lidell | 30cd644 | 2003-01-20 13:00:32 +0000 | [diff] [blame] | 44 | (setq c-recognize-knr-p nil) |
| 45 | ) |
| 46 | |
| 47 | ;; Set this is in your .emacs if you want to use the c-mode-hook as |
| 48 | ;; defined here right out of the box. |
| 49 | ; (add-hook 'c-mode-common-hook 'rockbox-c-mode-common-hook) |