1 ;; $Id$ -*- emacs-lisp -*-
3 ;; Here's a sample .emacs file that might help you along the way.
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.)
10 (load-file "<YOUR-PATH-TO-ROCKBOX>/tools/rockbox-style.el")
11 (add-hook 'c-mode-common-hook 'rockbox-c-mode-common-hook)
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.
17 (defvar my-style-selective-mode-hook nil
18 "Holds a list of predicate and hooks pairs. (list (PREDICATE . HOOK)
19 ...) It is used by my-mode-selective-mode-hook-function for choosing
20 the right hook to run.")
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)))
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)
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)