0

这一定是在过去一两个月内发生的。我不确定谁应该为此负责,但是现在当我尝试对从 c-mode 派生的模式进行字节编译时,Emacs 找不到派生模式中引用的任何 c-mode 函数。我查看了 cc-bytecom.el 并且(我不确定它是否是新的,但看起来像是)它定义了两个宏:cc-requrecc-provide. 我不能真正理解他们在做什么,但他们似乎阻止 Emacs 发现这些功能必须可用。如果,在我的代码中,我尝试替换(requre 'cc-mode)(cc-requre 'cc-mode)没有任何变化。

上述宏似乎只适用于编译时间,但我不能确定,它们也调用(eval-when-compile (cc-bytecomp-restore-environment))and (eval-when-compile (cc-bytecomp-load (symbol-name ,cc-part)))。我很难弄清楚它有什么作用。

4

1 回答 1

1

我没有看到你描述的问题:当我编译 haxe-mode 文件时,我只看到一个关于几个 c-mode 函数的警告,说它们可能在运行时未定义,因为 haxe-mode.el 调用了这些函数但是仅加载eval-when-compile.

顺便说一句,这些警告似乎是由于一些奇怪的代码,可能是从臭名昭著的 cc-bytecomp 复制而来的。下面的补丁似乎导致了一个干净的编译:

=== modified file 'haxe-help.el'
--- haxe-help.el    2012-10-16 14:41:06 +0000
+++ haxe-help.el    2012-10-16 15:11:37 +0000
@@ -33,7 +33,6 @@

 ;;; Code:

-(eval-when-compile (require 'cl))
 (require 'cl)

 (defcustom haxe-help-location

=== modified file 'haxe-mode.el'
--- haxe-mode.el    2012-10-16 14:41:06 +0000
+++ haxe-mode.el    2012-10-16 15:21:23 +0000
@@ -77,7 +77,6 @@
 (require 'cc-bytecomp)
 (require 'cc-mode)
 (require 'cc-fonts)
-;; (cc-require-when-compile 'cc-langs)
 (require 'cc-langs)

 (require 'compile)
@@ -91,18 +90,6 @@
 (require 'haxe-log)
 ;; ------------------- my change -------------------------------------

-;; The language constants are needed when compiling.
-(eval-when-compile
-  (let ((load-path
-         (if (and (boundp 'byte-compile-dest-file)
-                  (stringp byte-compile-dest-file))
-             (cons (file-name-directory byte-compile-dest-file) load-path)
-           load-path)))
-    (load "cc-mode" nil t)
-    (load "cc-fonts" nil t)
-    (load "cc-langs" nil t)
-    (load "cc-bytecomp" nil t)))
-
 (eval-and-compile
   ;; Tell the language constant system about haXe and base it on Java.
   (c-add-language 'haxe-mode 'java-mode))
@@ -387,7 +374,7 @@
                   (c-fontify-types-and-refs
                       ((c-promote-possible-types t)
                        (parse-sexp-lookup-properties
-                        (cc-eval-when-compile
+                        (eval-when-compile
                           (boundp 'parse-sexp-lookup-properties))))
                     (save-restriction
                       (narrow-to-region (point) limit)
于 2012-10-16T15:09:52.513 回答