Syntax highlighting for emacs » History » Version 4
Christopher Backhouse, 04/28/2011 12:44 PM
Reflect overly general title of page in text
1 | 1 | Christopher Backhouse | h1. Syntax highlighting for emacs |
---|---|---|---|
2 | 1 | Christopher Backhouse | |
3 | 4 | Christopher Backhouse | Emacs should automatically highlight C++ files, makefiles etc. for you (you may need to activate global-font-lock-mode). But it needs to be taught about FHCIL files. |
4 | 4 | Christopher Backhouse | |
5 | 4 | Christopher Backhouse | Copy and paste this onto the end of your .emacs file, to get syntax highlighting of files with a .fcl extension. |
6 | 1 | Christopher Backhouse | |
7 | 2 | Christopher Backhouse | <pre> |
8 | 1 | Christopher Backhouse | (setq fclKeywords |
9 | 1 | Christopher Backhouse | '( |
10 | 2 | Christopher Backhouse | ;; Unfortunately, the comment syntax takes precedence, so this doesn't work |
11 | 1 | Christopher Backhouse | ("#include" . font-lock-keyword-face) |
12 | 1 | Christopher Backhouse | ("@local" . font-lock-keyword-face) |
13 | 1 | Christopher Backhouse | ;; All these names are magic, I think |
14 | 2 | Christopher Backhouse | ("process_name:\\|services:\\|source:\\|outputs:\\|physics:\\|producers:\\|f\ |
15 | 2 | Christopher Backhouse | ilters:\\|analyzers:||\trigger_paths:||\end-paths:" . font-lock-builtin-face) |
16 | 1 | Christopher Backhouse | ("true\\|false" . font-lock-builtin-face) |
17 | 1 | Christopher Backhouse | ;; Variable definitions are followed by colons |
18 | 1 | Christopher Backhouse | ("[a-zA-Z0-9_]*:" . font-lock-variable-name-face) |
19 | 1 | Christopher Backhouse | ) |
20 | 1 | Christopher Backhouse | ) |
21 | 1 | Christopher Backhouse | |
22 | 1 | Christopher Backhouse | ;; Python mode gets us comment handling and indentation at colons |
23 | 1 | Christopher Backhouse | (define-derived-mode fcl-mode python-mode |
24 | 1 | Christopher Backhouse | (setq mode-name "FHICL") |
25 | 1 | Christopher Backhouse | (setq font-lock-defaults '(fclKeywords)) |
26 | 1 | Christopher Backhouse | ;; (setq tab-width 2) ;; Doesn't seem to work |
27 | 1 | Christopher Backhouse | ) |
28 | 1 | Christopher Backhouse | |
29 | 1 | Christopher Backhouse | (add-to-list 'auto-mode-alist '("\\.fcl\\'" . fcl-mode)) |
30 | 2 | Christopher Backhouse | </pre> |
31 | 2 | Christopher Backhouse | |
32 | 2 | Christopher Backhouse | h2. Known bugs |
33 | 2 | Christopher Backhouse | |
34 | 2 | Christopher Backhouse | * The comment syntax takes precedence, so #include gets incorrectly coloured as a comment |
35 | 2 | Christopher Backhouse | * The mode defaults to 4-space tabs, 2 seems to be our standard |
36 | 2 | Christopher Backhouse | * The mode thinks that blocks start at : not :{ , so the auto-indenting is a little off (but better than nothing). |
37 | 2 | Christopher Backhouse | * This doesn't help vi users |
38 | 2 | Christopher Backhouse | |
39 | 3 | Christopher Backhouse | Emacs/lisp experts are welcome to attempt to fix the first three. |