Syntax highlighting for emacs » History » Version 4
« Previous -
Version 4/18
(diff) -
Next » -
Current version
Christopher Backhouse, 04/28/2011 12:44 PM
Reflect overly general title of page in text
Syntax highlighting for emacs¶
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.
Copy and paste this onto the end of your .emacs file, to get syntax highlighting of files with a .fcl extension.
(setq fclKeywords '( ;; Unfortunately, the comment syntax takes precedence, so this doesn't work ("#include" . font-lock-keyword-face) ("@local" . font-lock-keyword-face) ;; All these names are magic, I think ("process_name:\\|services:\\|source:\\|outputs:\\|physics:\\|producers:\\|f\ ilters:\\|analyzers:||\trigger_paths:||\end-paths:" . font-lock-builtin-face) ("true\\|false" . font-lock-builtin-face) ;; Variable definitions are followed by colons ("[a-zA-Z0-9_]*:" . font-lock-variable-name-face) ) ) ;; Python mode gets us comment handling and indentation at colons (define-derived-mode fcl-mode python-mode (setq mode-name "FHICL") (setq font-lock-defaults '(fclKeywords)) ;; (setq tab-width 2) ;; Doesn't seem to work ) (add-to-list 'auto-mode-alist '("\\.fcl\\'" . fcl-mode))
Known bugs¶
- The comment syntax takes precedence, so #include gets incorrectly coloured as a comment
- The mode defaults to 4-space tabs, 2 seems to be our standard
- The mode thinks that blocks start at : not :{ , so the auto-indenting is a little off (but better than nothing).
- This doesn't help vi users
Emacs/lisp experts are welcome to attempt to fix the first three.