Enabling WebCL Highlighting in Emacs

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

  1. 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)
    
  2. Install multi-web-mode by using “M-x package-list-packages” and scrolling down to “multi-web-mode”.
  3. 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.

  4. Start coding!
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s