Sunday 6 March 2011

Emacs Drupal Mode

I am trying to learn how to write Drupal modules for a new map rendering on demand web service (a bit like townguide, but distributed with a separate front end and rendering servers).

First thing is to get emacs23 working with php and drupal modes - the instructions here give me obscure errors about c-lang-def only being used in a file.   After a bit of hunting on the internet I found it is a problem with Emacs V23, and a simple work around is to put the php-mode.el and drupal-mode.el files in ~/.emacs.d, then add the following to ~/.emacs:
; make sure the target directory is on your load-path
(add-to-list 'load-path "~/.emacs.d")
(autoload 'php-mode "php-mode" "Major mode for editing php code" t)
(autoload 'drupal-mode "drupal-mode" "Major mode for editing drupal php " t)
(add-to-list 'auto-mode-alist '("\\.\\(module\\|test\\|install\\|theme\\)$" . drupal-mode))
  (add-to-list 'auto-mode-alist '("\\.\\(php\\|inc\\)$" . php-mode))
  (add-to-list 'auto-mode-alist '("\\.info" . conf-windows-mode))
With that in my .emacs file, loading a .php or .module file starts php or drupal mode - success!

No comments: