2009-05-22 3 views
29

Emacs 23 및 php-mode.el 1.5.0을 사용 중입니다. 내 .emacs이있을 때 : 이맥스 시작 후 나는 (require 'php-mode)을 평가하는 경우PHP 모드 (및 기타 cc 모드 파생 모드)를 Emacs와 호환되게 만들기 23

Warning (initialization): An error occurred while loading `/Users/kdj/.emacs':

error: `c-lang-defconst' must be used in a file

To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the `--debug-init' option to view a complete error backtrace.

, 나는 오류 메시지를 얻을하지 않습니다

(require 'php-mode) 

를 이맥스를 시작할 때이 오류 메시지가 표시됩니다.

blog entry이이 문제는 Emacs 23에만 해당됩니다 (즉, Emacs 22.x에는 오류가 없음). 그러나 해결책을 제공하지는 않습니다.

Mac OS X   X를 사용하고 있으며 현재 CVS 소스에서 Emacs를 빌드했으며 ./configure --with-ns을 사용했습니다.

여기에 무슨 일이 일어나고 있으며 어떻게 해결할 수 있습니까?

+0

나는 이맥스 스타터 키트 (또한 v1.5.0)와 함께 제공되는 이맥스 23과'php-mode'를 사용합니다. 그것은 작동합니다. .emacs에'php-mode '에 영향을주는 다른 모드가있을 수 있습니다. –

+0

필자는 .emacs를 "(add-to-list 'load-path"~/elisp ") (php-mode가 필요함)로 변경했으며 문제가 지속됩니다. –

+0

온라인 어딘가에 당신의 dotemac을 둘 수 있습니까? –

답변

51

csharp-mode를 실행하려고 할 때 동일한 문제가 발생했습니다. CSHARP 모드의 실제 이맥스 리스프 파일로 파고 때 나는 마침내 해결책을 발견 :

;; 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. 

그래서, 당신의 이맥스에 넣어 신속하고 더러운 수정 확장에 자동 부하이며 넣지 (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 모드 전환 작업을해야합니다. 행운을 빌어.

+0

굉장! 이것은 완벽하게 작동합니다. –

+0

도 저에게 효과적입니다 – Matt

+0

파티에 늦었습니다. Linux에서는 문제가 없지만 Windows에서는 nxhtml이 자체적으로 많은 정보를 자동로드하므로이 동일한 오류가 발생했습니다. cc - *. elc 파일을 삭제했는데 오류가 사라졌습니다. – monksp