Syntax highlighting for emacs » History » Version 5
Christopher Backhouse, 04/28/2011 12:46 PM
More fixes
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 | 5 | 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 | 2 | Christopher Backhouse | ;; All these names are magic, I think |
14 | 5 | Christopher Backhouse | ("process_name:\\|services:\\|source:\\|outputs:\\|physics:\\|producers:\\|filters:\\|analyzers:||\trigger_paths:||\end-paths:" . font-lock-builtin-face) |
15 | 1 | Christopher Backhouse | ("true\\|false" . font-lock-builtin-face) |
16 | 1 | Christopher Backhouse | ;; Variable definitions are followed by colons |
17 | 1 | Christopher Backhouse | ("[a-zA-Z0-9_]*:" . font-lock-variable-name-face) |
18 | 1 | Christopher Backhouse | ) |
19 | 1 | Christopher Backhouse | ) |
20 | 1 | Christopher Backhouse | |
21 | 1 | Christopher Backhouse | ;; Python mode gets us comment handling and indentation at colons |
22 | 1 | Christopher Backhouse | (define-derived-mode fcl-mode python-mode |
23 | 1 | Christopher Backhouse | (setq mode-name "FHICL") |
24 | 1 | Christopher Backhouse | (setq font-lock-defaults '(fclKeywords)) |
25 | 1 | Christopher Backhouse | ;; (setq tab-width 2) ;; Doesn't seem to work |
26 | 1 | Christopher Backhouse | ) |
27 | 1 | Christopher Backhouse | |
28 | 1 | Christopher Backhouse | (add-to-list 'auto-mode-alist '("\\.fcl\\'" . fcl-mode)) |
29 | 2 | Christopher Backhouse | </pre> |
30 | 2 | Christopher Backhouse | |
31 | 2 | Christopher Backhouse | h2. Known bugs |
32 | 2 | Christopher Backhouse | |
33 | 2 | Christopher Backhouse | * The comment syntax takes precedence, so #include gets incorrectly coloured as a comment |
34 | 2 | Christopher Backhouse | * The mode defaults to 4-space tabs, 2 seems to be our standard |
35 | 2 | Christopher Backhouse | * The mode thinks that blocks start at : not :{ , so the auto-indenting is a little off (but better than nothing). |
36 | 2 | Christopher Backhouse | * This doesn't help vi users |
37 | 2 | Christopher Backhouse | |
38 | 3 | Christopher Backhouse | Emacs/lisp experts are welcome to attempt to fix the first three. |