Ubuntu Packages and PHP
(Hello, Planet Ubuntu Users! I'm looking for a second MOTU on my php-xdebug package as well as someone to revu my libapache-test-perl package. Any takers?)
Emacs CVS now includes XFT (i.e. smooth fonts) in the main branch, so I'm discontinuing my old emacs-xft-snapshot build. Still, the other emacs-snapshot package is targeted to Debian and I'm running Ubuntu Gutsy. So I've uploaded a snapshot build to my PPA on Launchpad.
One thing that I included is flymake support for PHP. Carl asked me earlier today if I knew how to get the compilation mode in Emacs to work with PHP's lint function to find highlight problems. I said flymake would be better, but didn't know how to do that right off, either.
After a bit of twiddling, I figured it out and, as a bonus, got compilation mode figured out, too.
If you want to enable flymake for PHP-mode (yes, I have a Debian package for that, too) in a version of Emacs you already have installed, add the following code to your .emacs file:
Emacs CVS now includes XFT (i.e. smooth fonts) in the main branch, so I'm discontinuing my old emacs-xft-snapshot build. Still, the other emacs-snapshot package is targeted to Debian and I'm running Ubuntu Gutsy. So I've uploaded a snapshot build to my PPA on Launchpad.
One thing that I included is flymake support for PHP. Carl asked me earlier today if I knew how to get the compilation mode in Emacs to work with PHP's lint function to find highlight problems. I said flymake would be better, but didn't know how to do that right off, either.
After a bit of twiddling, I figured it out and, as a bonus, got compilation mode figured out, too.
If you want to enable flymake for PHP-mode (yes, I have a Debian package for that, too) in a version of Emacs you already have installed, add the following code to your .emacs file:
;; Flymake PHP Extension
(require 'flymake)
(unless (fboundp 'flymake-php-init)
(defun flymake-php-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "php" (list "-f" local-file "-l")))))
(let ((php-ext-re "\\.php[345]?\\'")
(php-error-re
"\\(?:Parse\\|Fatal\\) error: \\(.*\\) i n \\(.*\\) on line \\([0-9]+\\)"))
(unless (assoc php-ext-re flymake-allowed-file-name-masks)
(add-to-list 'flymake-allowed-file-name-masks
(list php-ext-re
'flymake-php-init
'flymake-simple-cleanup
'flymake-get-real-file-name))
(add-to-list 'compilation-error-regexp-alist-alist
(list 'compilation-php
php-error-re 2 3 nil nil))
(add-to-list 'compilation-error-regexp-alist 'compilation-php)
(add-to-list 'flymake-err-line-patterns
(list php-error-re 2 3 nil 1))))
Now, whether you're using the emacs you started with or the latest emacs-snapshot, you need to tell emacs to use flymake on PHP files. Add:(add-hook 'php-mode-hook (lambda () (flymake-mode t)))
to your .emacs file and you're good to go.