summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/sample.emacs40
1 files changed, 37 insertions, 3 deletions
diff --git a/tools/sample.emacs b/tools/sample.emacs
index 41a59acff3..53b75fd907 100644
--- a/tools/sample.emacs
+++ b/tools/sample.emacs
@@ -1,10 +1,44 @@
1;; $Id$ -*- emacs-lisp -*- 1;; $Id$ -*- emacs-lisp -*-
2 2
3;; Here's a sample .emacs file that might help you along the way. 3;; Here's a sample .emacs file that might help you along the way.
4;; Just copy this region and paste it into your .emacs file. You 4
5;; might not want to use this if you already use c-mode-hooks for 5;; First comes a setup that is ideal when you are only working with
6;; other styles. 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.)
7 9
8(load-file "<YOUR-PATH-TO-ROCKBOX>/tools/rockbox-style.el") 10(load-file "<YOUR-PATH-TO-ROCKBOX>/tools/rockbox-style.el")
9(add-hook 'c-mode-common-hook 'rockbox-c-mode-common-hook) 11(add-hook 'c-mode-common-hook 'rockbox-c-mode-common-hook)
10 12
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)
19...) It is used by my-mode-selective-mood-hook-function for choosing
20the 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
24HOOK in the pair should be executed. If the PREDICATE evaluate to non
25nil 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)