I ran into the same problem when trying to get the csharp-mode up and running. I finally found the solution when digging into the actual Emacs Lisp file for csharp-mode:
;; This code doesn't seem to work when you compile it, then
;; load/require in the Emacs file. You will get an error (error
;; "`c-lang-defconst' must be used in a file") which happens because
;; cc-mode doesn't think it is in a buffer while loading directly
;; from the init. However, if you call it based on a file extension,
;; it works properly. Interestingly enough, this doesn't happen if
;; you don't byte-compile cc-mode.
So, the quick and dirty fix to put in your .emacs is to auto load on extension and not put (require 'php-mode)
or (load "php-mode")
in there. Without further ado,
(autoload 'php-mode "php-mode" "Major mode for editing php code." t)
(add-to-list 'auto-mode-alist '("\\.php$" . php-mode))
(add-to-list 'auto-mode-alist '("\\.inc$" . php-mode))
I hope this helps! Now I just need to get the PHP/HTML mode switching stuff working. Wish me luck.
It works fine with http://mewde.googlecode.com/files/php-mode-new.el.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With