Project

General

Profile

Syntax highlighting for emacs » History » Version 3

Christopher Backhouse, 04/28/2011 12:42 PM
Minor fixups

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