使PHP-模式(和其它CC-模式衍生模式)使用Emacs 23兼容
题
我使用Emacs 23和 PHP-mode.el 1.5.0。当我有这个在我的.emacs
:
(require 'php-mode)
我得到这个错误信息Emacs启动时:
警告(初始化):加载`/Users/kdj/.emacs'发生错误:
错误:`C琅defconst”必须在一个文件中使用
要确保正常运行,您应该调查并删除 在初始化文件中的错误原因。启动Emacs, 在`--debug-INIT”选项来查看完整的错误反向跟踪。
如果我评价(require 'php-mode)
Emacs启动后,我没有得到任何错误消息。
我发现了一个博客条目这表明这个问题是特定于Emacs的23(即,有使用Emacs 22.x暂时没有错误),但它没有给出任何解决方案。
我不知道这是否重要,但我使用的是Mac OS X和我建立的Emacs从目前的CVS源,使用./configure --with-ns
。
这是怎么回事,和/或如何解决它?
解决方案
我试图让csharp模式启动和运行的时候遇到了同样的问题。我终于找到了溶液挖成用于csharp模式的实际的Emacs Lisp文件时:
;; 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.
因此,快速和肮脏的修复就摆在你的.emacs被自动加载的扩展,而不是把(require 'php-mode)
或(load "php-mode")
在那里。事不宜迟,
(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))
我希望这有助于!现在我只需要获得PHP / HTML模式切换的东西工作。祝我好运。
其他提示
不隶属于 StackOverflow