首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法正确要求c-common-init和其他c-mode函数

无法正确要求c-common-init和其他c-mode函数
EN

Stack Overflow用户
提问于 2012-10-14 20:36:25
回答 1查看 98关注 0票数 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))(eval-when-compile (cc-bytecomp-load (symbol-name ,cc-part)))。我很难弄清楚它是做什么的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-16 23:09:53

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

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

代码语言:javascript
复制
=== 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)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12882264

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档