Mats Lidell | 30cd644 | 2003-01-20 13:00:32 +0000 | [diff] [blame] | 1 | ;; $Id$ -*- emacs-lisp -*- |
| 2 | |
| 3 | ;; Here's a sample .emacs file that might help you along the way. |
Mats Lidell | 1b71742 | 2003-01-22 23:01:10 +0000 | [diff] [blame] | 4 | |
| 5 | ;; First comes a setup that is ideal when you are only working with |
| 6 | ;; rockbox. Just select the next few lines, paste it into your .emacs |
| 7 | ;; and change the path to the tools folder. (If you are using more |
| 8 | ;; than one style. Look further down the this file.) |
Mats Lidell | 30cd644 | 2003-01-20 13:00:32 +0000 | [diff] [blame] | 9 | |
| 10 | (load-file "<YOUR-PATH-TO-ROCKBOX>/tools/rockbox-style.el") |
| 11 | (add-hook 'c-mode-common-hook 'rockbox-c-mode-common-hook) |
| 12 | |
Mats Lidell | 1b71742 | 2003-01-22 23:01:10 +0000 | [diff] [blame] | 13 | ;; If you are using more than one style in maybe more than one project |
| 14 | ;; the example below might help out. It uses a predicate hook pair to |
| 15 | ;; select the right hook to use. |
| 16 | |
| 17 | (defvar my-style-selective-mode-hook nil |
| 18 | "Holds a list of predicate and hooks pairs. (list (PREDICATE . HOOK) |
Daniel Stenberg | 204ff7e | 2005-07-30 08:28:53 +0000 | [diff] [blame] | 19 | ...) It is used by my-mode-selective-mode-hook-function for choosing |
Mats Lidell | 1b71742 | 2003-01-22 23:01:10 +0000 | [diff] [blame] | 20 | the right hook to run.") |
| 21 | |
| 22 | (defun my-style-selective-mode-hook-function () |
| 23 | "Run each PREDICATE in `my-style-selective-mode-hook' to see if the |
| 24 | HOOK in the pair should be executed. If the PREDICATE evaluate to non |
| 25 | nil HOOK is executed and the rest of the hooks are ignored." |
| 26 | (let ((h my-style-selective-mode-hook)) |
| 27 | (while (not (eval (caar h))) |
| 28 | (setq h (cdr h))) |
| 29 | (funcall (cdar h)))) |
| 30 | |
| 31 | ;;; Example configuration. |
| 32 | ;; Add the selective hook to the c-mode-common-hook |
| 33 | (add-hook 'c-mode-common-hook 'my-style-selective-mode-hook-function) |
| 34 | |
| 35 | ;; Add your own hooks and predicates. The predicate should evaluate to |
| 36 | ;; non nil if the hook in the pair is supposed to be evaluated. In the |
| 37 | ;; example a part of the path is used to select what style to |
| 38 | ;; use. Choose what is appropriate for you. |
| 39 | (add-hook 'my-style-selective-mode-hook |
| 40 | '((string-match "rockbox" (buffer-file-name)) . rockbox-c-mode-common-hook)) |
| 41 | (add-hook 'my-style-selective-mode-hook |
| 42 | '((string-match "other" (buffer-file-name)) . other-c-mode-common-hook)) |
| 43 | ;; Make sure the default style is appended. |
| 44 | (add-hook 'my-style-selective-mode-hook '(t . my-c-mode-common-hook) t) |