When editing WebCL OpenCL kernels in Emacs I like to have the OpenCL kernel code highlighted as C code. This is easy to achieve using the multi-mode.el package.
The steps on Ubuntu (or any other modern Linux with Emacs 24) are
- Enable the http://marmalade-repo.org/ elpa package archive by adding the below to your .emacs file and restarting Emacs
(require 'package) (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) (package-initialize) - Install multi-web-mode by using “M-x package-list-packages” and scrolling down to “multi-web-mode”.
- Add the below to the bottom of your .emacs file and restart Emacs
(require 'multi-web-mode) (setq mweb-default-major-mode 'html-mode) (setq mweb-tags '((php-mode "<\\?php\\|<\\? \\|") (js-mode "]*>" "") (css-mode "]*>" "") (c-mode "]* +type=\"text/x-opencl\"[^>]*>" ""))) (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5")) (multi-web-global-mode 1)The important part is the “c-mode” section that will enable C highlighting for OpenCL kernels in html files.
- Start coding!