Emacs + php-mode in windows

19 11 2009
My development machine is having Ubuntu and I love to use Emacs than any other editor. Recently I need to work on windows.  I wrote a blog post about how to make Linux like environment in windows. I wanted to use Emacs in windows. To install Emacs in windows I followed the instructions as it is from http://www.claremontmckenna.edu/math/alee/emacs/emacs.html

I want to work on PHP, so I need a php-mode for Emacs, otherwise it will be very difficult. I tried a lot to install php-mode in windows as specified at https://prajwalaa.wordpress.com/2009/03/19/using-emacs-to-edit-php-files/ but I was getting “error: `c-lang-defconst’ must be used in a file” error message. Finally after searching for long time I figured out how to enable php-mode.

I downloaded php-mode and extracted and placed in my C:\emacs directory. And added following lines in my C:\emacs\.emacs.d\init.el file


(add-to-list 'load-path "C:\emacs\php-mode")
;;(load 'php-mode)
(autoload 'php-mode "php-mode" "Major mode for editing php code." t)
(defun clean-php-mode ()
(interactive)
(php-mode)
(setq c-basic-offset 2) ; 2 tabs indenting
(setq indent-tabs-mode nil)
(setq fill-column 78)
(c-set-offset 'case-label '+)
(c-set-offset 'arglist-close 'c-lineup-arglist-operators))
(c-set-offset 'arglist-intro '+) ; for FAPI arrays and DBTNG
(c-set-offset 'arglist-cont-nonempty 'c-lineup-math) ; for DBTNG fields and values
(add-to-list 'auto-mode-alist '("\\.php$" . php-mode))
(add-to-list 'auto-mode-alist '("\\.inc$" . php-mode))

After adding above lines and save. I restarted emacs. Then Php-mode is working fine. Hope this will help others to install Emacs and enable php-mode.

Advertisements

Actions

Information

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




%d bloggers like this: