diff options
author | Mats Lidell <matsl@rockbox.org> | 2003-01-22 23:01:10 +0000 |
---|---|---|
committer | Mats Lidell <matsl@rockbox.org> | 2003-01-22 23:01:10 +0000 |
commit | 1b71742d358ce37797dbc7390306de9461148471 (patch) | |
tree | e059c79dd8cccd18ab5d5382e73806c8e9e8c61c /tools/sample.emacs | |
parent | 8f1d3c944b509874be07a1f12387de37adf12626 (diff) | |
download | rockbox-1b71742d358ce37797dbc7390306de9461148471.tar.gz rockbox-1b71742d358ce37797dbc7390306de9461148471.zip |
Added support for supporting multiple project by using a predicate
hook pair list.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3152 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/sample.emacs')
-rw-r--r-- | tools/sample.emacs | 40 |
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 | ||
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) | ||